メソッドを呼び出すフォームに入力した顧客データをcreatePDFFileに保存するメソッドがあります。 PDFファイルを作成しました。現在、PDFファイルをレイアウトすることができるように、現在、そこにいくつかのフィラー文字列があります。そのため、NSTextFieldからstringValueを取り出し、それを元のタイルを含むStringに追加します。 "Name:" NSTextFieldからstringValueを追加します。保持するIBOutputを変更して、最初の項目では機能しますが、2番目以降の項目では機能しないため、最初の項目を取得できます。 BAD_AXCESSエラーが発生していますが、メソッドが完了したときだけです。ここでPDFファイルに印刷するためにNSTextFieldから別の文字列に文字列を追加しよう
は、PDFのdrawメソッドの開始である:ここで
-(void)drawPDFCustomerInfoWithContext:(CGContextRef)currentContext andWithPageSize:(CGSize)pageSize andCustomerObject:(Customer *)currentCustomer{
CTFontRef font = CTFontCreateWithName(CFSTR("Arial"), 12, NULL);
CFRange currentRange = CFRangeMake(0, 0);
CGContextSetTextMatrix(currentContext, CGAffineTransformIdentity);
NSString *customerName = [[[@"Name: " stringByAppendingString:self.firstNameTextField.stringValue] stringByAppendingString:@" "] stringByAppendingString:self.lastNameTextField.stringValue];
NSString *customerAddress = @"Address: ";
NSString *customerCity = @"City: ";
NSString *customerState = @"State: ";
NSString *customerZipcode = @"Zipcode: ";
NSString *customerPhone = @"Phone: ";
NSString *customerEmail = @"Email: ";
CFStringRef customerNameStringRef = (__bridge CFStringRef)customerName;
CFStringRef customerAddressStringRef = (__bridge CFStringRef)customerAddress;
CFStringRef customerCityStringRef = (__bridge CFStringRef)customerCity;
CFStringRef customerStateStringRef = (__bridge CFStringRef)customerState;
CFStringRef customerZipCodeStringRef = (__bridge CFStringRef)customerZipcode;
CFStringRef customerPhoneStringRef = (__bridge CFStringRef)customerPhone;
CFStringRef customerEmailStringRef = (__bridge CFStringRef)customerEmail;
は、メソッドを保存している:ここでは
- (IBAction)sendEstimateToCustomer:(id)sender {
float tempFloat = [[self.estimateNumberLabel stringValue]floatValue];
self.customerDataArray = [[NSMutableArray alloc]initWithArray:[self createCustomerDataArrayWithFirstName:self.firstNameTextField.stringValue andLastName:self.lastNameTextField.stringValue andAddress:self.customerAddress.stringValue andCity:self.customerCity.stringValue andState:self.customersState.stringValue andZipCode:self.customerZipcode.stringValue andPhone:self.customerPhone.stringValue andEmail:self.customerEmail.stringValue andEstimateNumber:tempFloat]];
self.customer = [[Customer alloc]initWithCustomerDataArray:self.customerDataArray];
[self createEstimatePDF];
がcreateEstimatePDF方法
-(void)createEstimatePDF{
NSLog(@"create Estimate Method Fired");
CGContextRef pdfContext;
CFURLRef url;
url = [self createPDFPath];
CFMutableDictionaryRef myDictionary = NULL;
myDictionary = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(myDictionary, kCGPDFContextTitle, CFSTR("My PDF File"));
CFDictionarySetValue(myDictionary, kCGPDFContextCreator, CFSTR("Ben"));
pdfContext = CGPDFContextCreateWithURL(url,NULL, myDictionary);
CFRelease(url);
CGPDFContextBeginPage(pdfContext,myDictionary);
CGSize pageSize = CGSizeMake(612, 792);
[self drawPDFJobDescriptionTableWithContext:pdfContext andWithPageSize:pageSize];
[self drawPDFContractualTextWithContext:pdfContext andPageSize:pageSize];
[self drawPDFCustomerInfoWithContext:pdfContext andWithPageSize:pageSize andCustomerObject:self.customer];
[self drawPDFEstimateNumberWithContext:pdfContext andWithPageSize:pageSize];
[self drawPDFJobTableHeadersWithContext:pdfContext andPageSize:pageSize];
[self drawPDFBorderWithContext:pdfContext andWithPageSize:pageSize];
[self drawPDFHeaderWithContext:pdfContext andWithPageSize:pageSize];
[self drawPDFLegalStatementWith:pdfContext andPageSize:pageSize];
[self drawPDFSignatureAndDateWith:pdfContext andPageSize:pageSize];
[self drawPDFSignLinesWithContext:pdfContext andPageSize:pageSize];
CFRelease(myDictionary);
CGPDFContextEndPage(pdfContext);
である私はいくつかのことを考えますがリリースされていますが、私はどこを見つけることができません。私は変数を見て、ステップを踏んで、値をすべて表示してブームし、メソッドの最後の閉じ括弧にヒットしてから、BAD_ACCESSエラーを表示します。私はスタンドの下にないことは、これが動作することで、
NSString *customerName = [[[@"Name: " stringByAppendingString:self.firstNameTextField.stringValue] stringByAppendingString:@" "] stringByAppendingString:self.lastNameTextField.stringValue];
アイブ氏は、渡される顧客オブジェクトと同様の方法を介してデータを渡すためにも上の値をコピーしようとしました。
さらに詳しい情報が必要な場合は、私が提供することができます。 NSTextfieldsのすべては、問題は、それは私は信じて描かれた前の値が失われることが原因となった私はCFStringRefを解放した関数の最後にあった私は
CFRelease(customerNameStringRef);
を取り除き、