forum

Home / DeveloperSection / Forums / Unrecognized selector when setting NSArray property

Unrecognized selector when setting NSArray property

Anonymous User178628-Jul-2015

I have a method that returns an array:

-(NSArray*)fetchStoresFromContext {

     NSManagedObjectContext *context = [RKManagedObjectStore

                                                        defaultStore].mainQueueManagedObjectContext;

    NSFetchRequest *fetchRequest = [NSFetchRequest

fetchRequestWithEntityName: @"Store"];

    NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:

@"name"ascending:YES];

    fetchRequest.sortDescriptors = @[descriptor];

    NSError *error = nil;

    NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:

&error];

    return fetchedObjects;

}

If create a new NSArray and call this method like this: 

NSArray *test = [self fetchStoresFromContext]; 

everything works fine. [test count] returns 6. 

I have the following property: 

@property (nonatomic, strong) NSArray* stores; 

if I call _stores = [self fetchStoresFromContext] I get the following error: 

-[__NSCFNumber length]: unrecognized selector sent to instance 0x15e3c2f0 

 

What's going on here? The property is an NSArray and the object is an NSArray as well so why am I having this problem?


Updated on 29-Jul-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By