I\'m writing an application to show some news from a portal. The news are fetched using a JSON file from the Internet and then stored into a NSMutableArray using the CoreDat
Verify that dataSet is an NSMutableArray. The exception is getting thrown because it doesn't respond to removeObjectAtIndex.
jdot is correct dataSet must be NSMutableArray..
you must do it this way..
dataSet = [NSMutableArray arrayWithArray:[[NewsFetcher sharedInstance]
fetchManagedObjectsForEntity:@"News"
withPredicate:predicate
withDescriptor:@"Titolo"]];
Now the dataSet is a mutable instance of the array you got from NewsFetcher and it won't crash on removing objects.
Your NewsFetcher
returns you an immutable array, not a mutable instance. Use the following instead for initialization:
NSArray *results = [[NewsFetcher sharedInstance]
fetchManagedObjectsForEntity:@"News"
withPredicate:predicate
withDescriptor:@"Titolo"];
dataSet = [results mutableCopy];
An expression like A *a = (A*)b;
only casts the pointer to a different type - it doesn't convert/change the actual type of the instance it points to.