Reference POST:
http://stackoverflow.com/questions/3681003/core-data-basic-questions
I am able to get the Managed object context from this piece of code. It bring me to another question. I have 2 VIEW CONTROLLERS and 1 NSObject
- Userlookup (VC)
- UserlookupSettings(VC)
- FetchProcessor (NSObject)
In sequence, Userlookup vc loads first and has a button to load the Userlookupsettings VC + a textbox and UiButton. When the app is loaded and I hit the SETTINGS uibutton, things work fine... however, when i do the search (FetchProcessor) and then load the settings, it gives me error (check below please) for
if (![[managedObject managedObjectContext] save:&error]) {
NSLog(@"Unresolved error %@, %@, %@", error, [error userInfo],[error localizedDescription]);
exit(-1); // Fail
}
ERROR:
2010-09-11 03:10:47.148 SAPBasis[975:207] *** -[NSCFString objectID]: unrecognized selector sent to instance 0x3d5d830
2010-09-11 03:10:47.170 SAPBasis[975:207] Serious application error. Exception was caught during Core Data change processing: *** -[NSCFString objectID]: unrecognized selector sent to instance 0x3d5d830 with userInfo (null)
2010-09-11 03:10:47.170 SAPBasis[975:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString objectID]: unrecognized selector sent to instance 0x3d5d830'
EDITED and added relevant codes..
UserLookup:
-(void) searchUser{
getUserDetailsService=[[GetUserDetailsSOAPService alloc]init]; // where AbstractServiceProvider *getUserDetailsService; and @interface GetUserDetailsSOAPService : AbstractServiceProvider
[getUserDetailsService setSettingPreference:settings];
[settings release];
[getUserDetailsService setDelegate:self];
RequestDO * request = [[RequestDO alloc]init];
request.userID=userIdInputField.text;
[getUserDetailsService setRequestDO:request];
[request release];
NSManagedObjectContext *context = self.referringObject;
[getUserDetailsService setReferringObject:context];
[getUserDetailsService execute]; // This is the user search function.
[getUserDetailsService release];
}
-(void) editUserLookupSettings{
UserLookupSettings *viewVC = [[UserLookupSettings alloc] initWithNibName:@"UserLookupSettings" bundle:nil];
viewVC.title = @"Settings for User Lookup";
NSManagedObjectContext *context = self.referringObject;
viewVC.referringObject = context;
[self.navigationController pushViewController:viewVC animated:YES];
// Manage memory
[viewVC release];
}
NOW @implementation GetUserDetailsSOAPService
-(void)execute{
TCodeSettings *fetch = [[TCodeSettings alloc] init]; // Where @interface TCodeSettings : NSObject <NSFetchedResultsControllerDelegate>
fetch.referringObject = self.referringObject;
resultsOfSettings = [fetch initCode]; // Code details given below. I think so is causing the error when this is called.
[fetch release];
self.userData = [[NSMutableDictionary alloc] init];
self.previewData = [[NSMutableArray alloc] init];
// Creates new Request object and sets its url
NSString *URLReq = [self.settingPreference getSOAPPrefix];
URLReq=[URLReq stringByAppendingString:@"Z_USERLOOKUPWS"];
URLReq=[URLReq stringByAppendingString:[self.settingPreference getSOAPSuffix]];
theRequest=[NSMutableURLRequest
requestWithURL:[NSURL URLWithString:URLReq]
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:30.0];
// Setting specific SOAP headers
// For SOAP content type is text/xml
.
.
.
[self makeReqest]; // AbstractServiceProvider we have makeRequest function and it works fine..
}
NOW @interface TCodeSettings : NSObject
- (NSFetchedResultsController *)initCode{
NSError *error;
if (![[self fetchedResultsController] performFetch:&error]) {
// Handle the error
}else {
return fetchedResultsController;
}
}
NOW @interface UserLookupSettings : UITableViewController
- (void)viewDidLoad {
NSError *error;
if (![[self fetchedResultsController] performFetch:&error]) {
// Handle the error
}
[super viewDidLoad];
}