2011-11-08 10 views
0

나는 이것을 몇 시간 동안보고 있었지만 무엇이 잘못되었는지를 알 수 없다. 버튼을 누르면 핵심 데이터를 통해 개체를 업데이트하려고합니다.왜 NSInvalidArgument 예외가 발생합니까?

Apple 설명서에서는 다음과 같이 설명합니다.이 메서드는 aSelector가 NULL 인 경우 NSInvalidArgumentException을 발생시킵니다.

어떻게 aSelector가 Null인지 알 수 없지만 누군가 내가 누락 된 부분을 지적 할 수 있다면 좋을 것입니다.

-(void)updatePaymentFields:(NSString*) aValue { 
NSLog(@"I'm inside Update Payment Fields"); 
[self setValue:aValue forKey:@"amountPaid"]; 
} 

이것은 제가있어서 내부 코드를 가져야한다고 생각 로그 출력

2011-11-08 17:14:45.708 Market[521:fb03] I'm inside saleCompleteButtonTapped 
2011-11-08 17:14:45.867 Market[521:fb03] array:(
"<Invoice: 0x8142340> (entity: Invoice; id: 0x8140f90 <x-coredata://AF2BBB5C-4135-45EB-A421-5036AE02D2A0/Invoice/p1> ; data: {\n GSTAmount = 1;\n amountPaid = nil;\n cardID = 0;\n customer = \"\";\n date = \"07/11/2011\";\n incTaxPrice = 11;\n incTaxTotal = 110;\n invoiceNumber = a1;\n itemCode = 1035;\n paymentMethod = nil;\n price = \"10.00\";\n quantity = \"10.00\";\n saleStatus = I;\n taxCode = GST;\n timeStamp = \"2011-11-06 17:22:04 +0000\";\n total = 100;\n})" 
) 
2011-11-08 17:14:45.869 Market[521:fb03] 110.00 
2011-11-08 17:14:45.870 Market[521:fb03] -[Invoice updatePaymentFields:]: unrecognized selector sent to instance 0x8142340 
2011-11-08 17:14:45.894 Market[521:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Invoice updatePaymentFields:]: unrecognized selector sent to instance 0x8142340' 
*** First throw call stack: 
(0x1549052 0x1afdd0a 0x154aced 0x14aff00 0x14afce2 0x154ae72 0x14a6c78 0xa980 0xaa49 0x154aec9 0x4995c2 0x49955a 0x53eb76 0x53f03f 0x53e2fe 0x4bea30 0x4bec56 0x4a5384 0x498aa9 0x2436fa9 0x151d1c5 0x1482022 0x148090a 0x147fdb4 0x147fccb 0x2435879 0x243593e 0x496a9b 0x1d6d 0x1ce5) 

인 상기 updatePaymentFields: 방법

- (IBAction)saleCompleteButtonTapped:(id)sender { 
Invoice_MarketAppDelegate* delegate = [[UIApplication sharedApplication] delegate]; 

NSManagedObjectContext* managedObjectContext = delegate.managedObjectContext; 

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; 
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Invoice"  inManagedObjectContext:managedObjectContext]; 
[fetchRequest setEntity:entity]; 
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"invoiceNumber == %@", invoiceNumberLabel.text]; 
NSLog(@"predicate is: %@",predicate); 
[fetchRequest setPredicate:predicate]; 

NSLog(@"I'm inside saleCompleteButtonTapped"); 
NSError* error; 
NSMutableArray *mutableFetchResults = [[[managedObjectContext executeFetchRequest:fetchRequest error:&error]mutableCopy ]autorelease]; 
NSLog(@"array:%@",mutableFetchResults); 
NSLog(@"%@",amountPaidStr); 
[mutableFetchResults makeObjectsPerformSelector:@selector(updatePaymentFields:) withObject:amountPaidStr]; 
} 

호출해야 버튼을 누를 방법

- (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject { 
NSLog(@"I'm inside the makeObjectsPerformSelector"); 
} 

하지만 그때 내 buttonPressedMethod 내부에서이 문제를 호출하는 방법을 모른다, 나는 단순히 어떤 도움을 주시면 감사하겠습니다

[self makeObjectsPerformSelector:withObject:]; 

할 수 없습니다. 감사합니다

답변

0

Invoice 클래스에는 인스턴스 메서드 updatePaymentFields:이 없습니다. 그 방법을 올바른 수업에 넣었습니까?

+0

감사합니다. 잘못된 지점에 인스턴스 메서드가 있습니다. 첫 번째보기 컨트롤러에 인스턴스 메서드가 있습니다. 이 오류는 이제 사라졌지 만 변경 사항이 내 데이터베이스로 전파되지 않습니다. 왜 그런 일이 일어날 지 모릅니다. 나는 aValue에 NSLog를했는데 값을 받았다. – msec

+0

사실 그것을 무시하고 나중에 저장을 구현해야했다! 고마워요 :) – msec

관련 문제