I am trying to populate a UIPickerView with the results of a NSFetchRequest pulling data from a managedObjectContext. When I start my UIPickerView with the following, * Expected 'NSInvalidArgumentException' Because of their end application: The first 'throw' [account copyWithZone:] sent to non-recognized selector example 0x7a60ec70 'call stack: Before you say this error, CopyWithZone are not applicable to the method, I have to say that somewhere in my class files I am using the keyword I was told that the The reason for the crash is that it is related to the What do I need to change / add / add to prevent this app from crashing? Update _usernames is an NSArray ... results below, Just by using the appropriate attribute from its core data object, one of NSStrings Create an array There are probably clever ways to do this, but this would be a clear solution: I have just seen that you have set the KCModalPickerView * pickerView = [[KCModalPickerView alloc] initWithValues: _userNames];
Xcode does not throw errors or errors, but when I run the build and the application I am running, the following error is taking place copy
KCModalPicker
class implementation file. The method looks like the following:
// Edit this method - (NSString *) pickerView: (UIPickerView *) pickerView titleForRow: (NSInteger) line forComponent: (NSInteger) component {return [Self.values objectAtIndex: line]; }
NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription * entity = [NSEntityDescription EntityForName: @ Managed Object Contact in "Account": _MediaAid Object Contain]; [FetchRequest Set Entity: Entity]; FetchRequest.propertiesToFetch = [NSArray arrayWithObject: [[ObjectForKey by name of entity properties]: @ "Username"]]; NSError * Error = Zero; NSArray _usernames = [self.managedObjectContext executeFetchRequest: fetchRequest error: & amp; Error];
casemod picture view
to NSString
, You give it an array of account
. The structure tries to copy your example because it assumes that it is a NSString
, which corresponds to the NSCopying
protocol and copyWithZone:
Applies. Your object is not there, and will be a [account copywitzone]: for example sent to an unrecognized selector
exception
NSMutableArray * name = [NSMutableArray arrayWithCapacity: [_ User name count]]; (For account * account in _usernames) {NSString * accountName = account.name; If (! AccountName) {accountName = @ "& lt; Unknown account»;); } [To add names: accountName]; } CaseyMold Pictureview * PickView = [[Casey Model Picture Alcohol] Init With Values: Name];
propertiesToFetch
. In addition, you have to set the result type
from fetchRequest to NSDictionaryResultType
. In this case, executeFetchRequest: error:
returns an array of dictionaries and you NSArray * names = [_usernames valueForKey: @ "username"];
should be able to use.
Friday, 15 June 2012
ios - How to populate a UIPickerView with results from a NSFetchRequest using Core Data -
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment