Ссылка POST:
Я могу получить контекст управляемого объекта из этого фрагмента кода.Это подводит меня к другому вопросу.У меня есть 2 КОНТРОЛЛЕРА ПРОСМОТРА и 1 NSObject
- Userlookup (VC)
- UserlookupSettings (VC)
- FetchProcessor (NSObject)
Поочередно Userlookup vc загружается первым и имеет кнопку для загрузки Userlookupsettings VC + текстовое поле и UiButton.Когда приложение загружено, и я нажимаю на кнопку НАСТРОЙКИ, все работает хорошо ... однако, когда я выполняю поиск (FetchProcessor) и затем загружаю настройки, это выдает мне ошибку (проверьте ниже, пожалуйста) для
if (![[managedObject managedObjectContext] save:&error]) {
NSLog(@"Unresolved error %@, %@, %@", error, [error userInfo],[error localizedDescription]);
exit(-1); // Fail
}
ОШИБКА:
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'
ИЗМЕНЕНО и добавлены соответствующие коды ..
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];
}
СЕЙЧАС @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..
}
СЕЙЧАС @interface TCodeSettings: NSObject
- (NSFetchedResultsController *)initCode{
NSError *error;
if (![[self fetchedResultsController] performFetch:&error]) {
// Handle the error
}else {
return fetchedResultsController;
}
}
СЕЙЧАС @interface UserLookupSettings: UITableViewController 10 * * * *