I have been looking at this for hours but can’t find out what’s wrong.
I am trying to update objects via core data once a button is pressed.
Apple documentation states that: This method raises an NSInvalidArgumentException if aSelector is NULL.
I don’t see how aSelector is Null, it would be appreciated if someone could point out what I am missing.
-(void)updatePaymentFields:(NSString*) aValue {
NSLog(@"I'm inside Update Payment Fields");
[self setValue:aValue forKey:@"amountPaid"];
}
This is the button pressed method which should call the above updatePaymentFields: method
- (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];
}
This is the Log output
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)
I suspect that I should have the code inside the method
- (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject {
NSLog(@"I'm inside the makeObjectsPerformSelector");
}
But I then don’t know how to call this inside my buttonPressedMethod, I can’t simply do
[self makeObjectsPerformSelector:withObject:];
Any Help would be appreciated. Thanks
It looks like your
Invoiceclass doesn’t have an instance methodupdatePaymentFields:. Are you sure you put that method in the right class?