Deleting Selected row in UITableview when Button click - ios

I'm getting an Exception while using removeObjectAtIndex.
I've searched in this forum but I haven't found the correct solution for this Exception. Actually, I'm getting the data from server when I click on button, I'm getting success and also I need to delete that row but the selected row is not deleting.
My Exception:- Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object'
*** First throw call stack:
(
0 CoreFoundation 0x000000010cfd1c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c46bbb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010cfd1b9d +[NSException raise:format:] + 205
3 CoreFoundation 0x000000010cfca70e -[__NSCFArray removeObjectAtIndex:] + 94
4 SkigitApplication 0x00000001097fab80 __20-[HomePage Confirm:]_block_invoke + 272
5 SkigitApplication 0x00000001098c8628 __64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke46 + 40
6 libdispatch.dylib 0x000000011160f186 _dispatch_call_block_and_release + 12
7 libdispatch.dylib 0x000000011162e614 _dispatch_client_callout + 8
8 libdispatch.dylib 0x0000000111616a1c _dispatch_main_queue_callback_4CF + 1664
9 CoreFoundation 0x000000010cf391f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
10 CoreFoundation 0x000000010cefadcb __CFRunLoopRun + 2043
11 CoreFoundation 0x000000010cefa366 CFRunLoopRunSpecific + 470
12 GraphicsServices 0x000000010db6da3e GSEventRunModal + 161
13 UIKit 0x000000010acf7900 UIApplicationMain + 1282
14 SkigitApplication 0x00000001098c65bf main + 111
15 libdyld.dylib 0x0000000111663145 start + 1
16 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Here is my code: request is my array
In .h
NSMutableArray *request;
In .m
-(void)Confirm:(id)sender
{
NSString *test = [NSString stringWithFormat:#"WebserviceUrl"];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:test parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(#"JSON: %#", responseObject);
if([[responseObject valueForKey:#"Success"]integerValue])
{
request=[[responseObject valueForKey:#"info"]mutableCopy];
NSLog(#"array=%#",request);
frndcount=[[[request valueForKey:#"is_new"]objectAtIndex:0]mutableCopy];
NSLog(#"frndcount=%#",frndcount);
notification_id= [[[request valueForKey:#"notification_id"]objectAtIndex:0]mutableCopy];
NSLog(#"notification_id=%#",notification_id);
item_id= [[[request valueForKey:#"item_id"]objectAtIndex:0]mutableCopy];;
NSLog(#"item_id=%#",item_id);
frnd_count.text=[NSString stringWithFormat:#"%#",frndcount];
if (deleteIndexPath==0) {
[request removeObjectAtIndex:deleteIndexPath.row];
[self.msg_table deleteRowsAtIndexPaths:[NSArray arrayWithObject:deleteIndexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(#"Error: %#", error);
}];
}

Your request object is a NSArray object, that is immutable. you should change it to NSMutableArray and your problem is resolved.
Update
I don't know how you are initialising this object, but if you are doing something like this:
NSMutableArray *request = someData;
the referencing object may be not mutable, so you should resolve it doing this:
NSMutableArray *request = [someData mutableCopy];
Now, you have a mutable data.

Related

Terminating app due to uncaught exception '_HKObjectValidationFailureException'

I am saving the blood glucose values into Health Kit application in iOS.
-(void)viewDidLoad
{
float bloodGlucose=20;
float bloodGlucoseValue= (int) bloodGlucose;
NSLog(#"Blood Glucose value is :%f",bloodGlucoseValue);
HKQuantityType *bloodGlucoseType=[HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBloodGlucose];
NSSet *requesObjects=[[NSSet alloc]initWithObjects:bloodGlucoseType, nil];
HKHealthStore * hStore = [HKHealthStore new];
[hStore requestAuthorizationToShareTypes: requesObjects readTypes:requesObjects completion:^(BOOL success, NSError *error) {
//user response processing goes here, i.e.
if(success) {
dispatch_async(dispatch_get_main_queue(), ^{
[[GSHealthKitManager sharedManager]saveBloodGlucosePercentageintoHealthStore:bloodGlucoseValue];
});
}
}];
}
-(void)saveBloodGlucosePercentageintoHealthStore:(float)bloodGlucoseValue
{
HKUnit *inches=[HKUnit gramUnit];
HKQuantity * glucoseQuantity = [HKQuantity quantityWithUnit:inches doubleValue:bloodGlucoseValue];
HKQuantityType *glucoseType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBloodGlucose];
NSDate *now = [NSDate date];
HKQuantitySample *bloodGlucosesample = [HKQuantitySample quantitySampleWithType:glucoseType quantity:glucoseQuantity startDate:now endDate:now];
[self.healthStore saveObject:bloodGlucosesample withCompletion:^(BOOL success, NSError *error){
if (!success)
{
NSLog(#"Error");
}
}];
}
If I run the application, I got following exception in this line of code:
HKQuantitySample *bloodGlucosesample = [HKQuantitySample quantitySampleWithType:glucoseType quantity:glucoseQuantity startDate:now endDate:now];
Trace:
Exception is: Terminating app due to uncaught exception '_HKObjectValidationFailureException', reason: 'HKQuantitySample 20 g 2016-04-07 15:39:44 +0530 2016-04-07 15:39:44 +0530 requires unit of type Mass/Volume. Incompatible unit: g'
*** First throw call stack:
(
0 CoreFoundation 0x00b73a14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00634e02 objc_exception_throw + 50
2 CoreFoundation 0x00b7393d +[NSException raise:format:] + 141
3 HealthKit 0x0010da70 -[HKObject _validateForCreation] + 149
4 HealthKit 0x0010d89e +[HKObject _newDataObjectWithMetadata:device:config:] + 273
5 HealthKit 0x0014e661 +[HKSample _newSampleWithType:startDate:endDate:device:metadata:config:] + 200
6 HealthKit 0x0013244f +[HKQuantitySample quantitySampleWithType:quantity:startDate:endDate:device:metadata:] + 324
7 HealthKit 0x0013265a +[HKQuantitySample quantitySampleWithType:quantity:startDate:endDate:] + 116
8 HealthKitProto 0x0005cda2 -[GSHealthKitManager saveBloodGlucosePercentageintoHealthStore:] + 274
9 HealthKitProto 0x0005f4c7 __34-[FirstViewController viewDidLoad]_block_invoke_9 + 103
10 libdispatch.dylib 0x0367a377 _dispatch_call_block_and_release + 15
11 libdispatch.dylib 0x0369d9cd _dispatch_client_callout + 14
12 libdispatch.dylib 0x03682f90 _dispatch_main_queue_callback_4CF + 910
13 CoreFoundation 0x00ac4fde __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
14 CoreFoundation 0x00a82cd4 __CFRunLoopRun + 2356
15 CoreFoundation 0x00a820e6 CFRunLoopRunSpecific + 470
16 CoreFoundation 0x00a81efb CFRunLoopRunInMode + 123
17 GraphicsServices 0x04523664 GSEventRunModal + 192
18 GraphicsServices 0x045234a1 GSEventRun + 104
19 UIKit 0x00f02bfa UIApplicationMain + 160
20 HealthKitProto 0x000603ba main + 138
21 libdyld.dylib 0x036c7a21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
It seems that grams is not an unit supported by healthkit.
Check the allowed units in the SDK documentation and here
Edit: You specify a bad unit for this value
HKUnit *inches=[HKUnit gramUnit]; // this is not the right unit (nor inches)
HKQuantity * glucoseQuantity = [HKQuantity quantityWithUnit:inches doubleValue:bloodGlucoseValue];
You should create a mass unit and volume unit then divide the first by the second one (in swift):
let milligramPerDeciLiter = HKUnit.gramUnitWithMetricPrefix(.Milli).unitDividedByUnit(HKUnit.literUnitWithMetricPrefix(.Deci))
In Objc :
HKUnit* milligramPerDeciLiter = [[HKUnit gramUnitWithMetricPrefix:HKMetricPrefixMilli] unitDividedByUnit:[HKUnit literUnitWithMetricPrefix:HKMetricPrefixDeci]];

NSMutableDictionary setobject: forkey: crashes with unrecognised selector message

For the below code snippet:
error occurs at setObject: forKey:
response <--is an NSDictionary
if(response){
NSMutableArray *lifeArray = [[NSMutableArray alloc] init];
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
responseDict = (NSMutableDictionary *)[response mutableCopy];
[responseDict setObject:#"life" forKey:#"label"]; <-- Error here
}
Note that variable responseDict is NSMutableDictionary since copied via mutableCopy.
Error message:
2014-11-12 12:16:08.534 Lifetape[84381:508759] -[__NSCFArray setObject:forKey:]: unrecognized selector sent to instance 0x7a296700
2014-11-12 12:16:08.536 Lifetape[84381:508759] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray setObject:forKey:]: unrecognized selector sent to instance 0x7a296700'
*** First throw call stack:
(
0 CoreFoundation 0x028fbdf6 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x02557a97 objc_exception_throw + 44
2 CoreFoundation 0x02903a75 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x0284c9c7 ___forwarding___ + 1047
4 CoreFoundation 0x0284c58e _CF_forwarding_prep_0 + 14
5 Lifetape 0x000dfb83 __50-[LTTimeLineTableViewController getTimeIntervals:]_block_invoke + 307
6 Lifetape 0x0014cedb -[MethodInvoker maybeInvokeCallback] + 395
7 Lifetape 0x0014d19f -[MethodInvoker receiveResultWithError:andResult:] + 399
8 Lifetape 0x00143e38 -[MeteorClient(Connection) livedata_result:] + 1544
9 Lifetape 0x00138674 __54-[MeteorClient(Connection) initConnectionWithOptions:]_block_invoke_3 + 2660
10 Lifetape 0x0014b2b5 -[MeteorClient didReceiveMessage:] + 197
11 Lifetape 0x0014eb7d -[ObjectiveDDP webSocket:didReceiveMessage:] + 269
12 Lifetape 0x0015d986 __30-[SRWebSocket _handleMessage:]_block_invoke + 102
13 libdispatch.dylib 0x031e941a _dispatch_call_block_and_release + 15
14 libdispatch.dylib 0x03209e1f _dispatch_client_callout + 14
15 libdispatch.dylib 0x031f0981 _dispatch_main_queue_callback_4CF + 610
16 CoreFoundation 0x02855f3e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
17 CoreFoundation 0x02814d40 __CFRunLoopRun + 2256
18 CoreFoundation 0x028141ab CFRunLoopRunSpecific + 443
19 CoreFoundation 0x02813fdb CFRunLoopRunInMode + 123
20 GraphicsServices 0x051a524f GSEventRunModal + 192
21 GraphicsServices 0x051a508c GSEventRun + 104
22 UIKit 0x00f41e16 UIApplicationMain + 1526
23 Lifetape 0x000ce36d main + 141
24 libdyld.dylib 0x03235ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Here your response dictionary is a NSDictionary type collection so it does not have any selector like setObject, that's why it is giving you this error use
if(response && [response isKindOfClass:[NSDictionary class]]){
NSMutableArray *lifeArray = [[NSMutableArray alloc] init];
NSMutableDictionary *responseDict = [NSMutableDictionary dictionaryWithDictionary:response];
[responseDict setObject:#"life" forKey:#"label"];
}
and it will work but make sure response is your dictionary type object. as the error you have posted clearly says that your response is an array not a dictionary.
Your response looks like NSArray class so try below code.
if([response isKindOfClass:[NSArray Class]]){
NSLog(#"Array");
}
else if([response isKindOfClass:[NSDictionary Class]]){
NSLog(#"Dictionary");
}
Now manage your code as per log.

iOS Core Data NSRangeException

I have an issue I cant solve. Im creating an iOS application with Core Data framework. Everything was going just fine until I got NSRangeException. This exception I get in function which checks if Application data needs to be updated.
My code is:
- (BOOL) isTimetableUpdatedWithJSONData:(NSMutableDictionary*) data
{
appDelegate = [[UIApplication sharedApplication] delegate];
managedObjectContext = [appDelegate managedObjectContext];
//Do database update check logic here
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:#"MobileTimetableDataHash" inManagedObjectContext:managedObjectContext]];
NSError *error = nil;
NSArray *results = [managedObjectContext executeFetchRequest:request error:&error];
if (error != nil)
{
[self printErrorAlert];
}
//THERE IS ERROR HERE
NSManagedObject* changesGrabbed = [results objectAtIndex:0];
NSString *changesFromDatabase = [changesGrabbed valueForKey:#"changes"];
NSString *changesFromService = [data valueForKeyPath:#"changes"];
if ([changesFromService isEqualToString:changesFromDatabase])
{
return YES;
}
else
{
[changesGrabbed setValue:changesFromService forKey:#"changes"];
[managedObjectContext save:&error];
if (error != nil)
{
[self printErrorAlert];
}
return NO;
}
}
Exception:
2014-06-12 21:36:12.034 MIF[437:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x0000000101cb3495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101a1299e objc_exception_throw + 43
2 CoreFoundation 0x0000000101c6be3f -[__NSArrayI objectAtIndex:] + 175
3 MIF 0x0000000100001942 -[MIFTimetableService isTimetableUpdatedWithJSONData:] + 514
4 MIF 0x000000010000219d -[MIFAppDelegate synchrinizeTimetableService] + 157
5 MIF 0x0000000100001dc2 -[MIFAppDelegate application:didFinishLaunchingWithOptions:] + 114
6 UIKit 0x00000001005ba3d9 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 264
7 UIKit 0x00000001005babe1 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1605
8 UIKit 0x00000001005bea0c -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 660
9 UIKit 0x00000001005cfd4c -[UIApplication handleEvent:withNewEvent:] + 3189
10 UIKit 0x00000001005d0216 -[UIApplication sendEvent:] + 79
11 UIKit 0x00000001005c0086 _UIApplicationHandleEvent + 578
12 GraphicsServices 0x0000000103ce671a _PurpleEventCallback + 762
13 GraphicsServices 0x0000000103ce61e1 PurpleEventCallback + 35
14 CoreFoundation 0x0000000101c35679 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
15 CoreFoundation 0x0000000101c3544e __CFRunLoopDoSource1 + 478
16 CoreFoundation 0x0000000101c5e903 __CFRunLoopRun + 1939
17 CoreFoundation 0x0000000101c5dd83 CFRunLoopRunSpecific + 467
18 UIKit 0x00000001005be2e1 -[UIApplication _run] + 609
19 UIKit 0x00000001005bfe33 UIApplicationMain + 1010
20 MIF 0x0000000100001d23 main + 115
21 libdyld.dylib 0x000000010234b5fd start + 1
22 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Guys, can anyone help me please? I realy need your help. Thank you.
Your troublemaker seems to be
NSManagedObject* changesGrabbed = [results objectAtIndex:0];
If results is an empty array, calling objectAtIndex:0 will cause a NSRangeException, because there is no object at index 0. You better call [results firstObject], which won't crash with an error if results is empty array. firstObject() just returns nil in this case.
You are attempting to retrieve an object from an empty array. You should first check to see if the array contains any objects. Use the count property:
if (results.count > 0) {
NSManagedObject* changesGrabbed = [results objectAtIndex:0];
//continue...
} else {
//Array is empty, object 0 will be beyond bounds
}
Just before
NSManagedObject* changesGrabbed = [results objectAtIndex:0];
Add a branch based on the returned results. Something like the following:
if (results && [results count] > 0) {
NSManagedObject* changesGrabbed = [results objectAtIndex:0];
...
}
Your array is empty. The stacktrace pretty much spells it out for you --
reason: '* -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for
empty array'

[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance - source code and screenshot attached

At GitHub I have a simple iPhone app, which fetches user information (by using OAuth) from the social network Mail.ru:
It does fetch and print the information, but then crashes.
As an iOS programming newbie I'm confused by the output below (also please see the full output at PasteBin):
2014-01-21 21:21:10.873 oauthMailru[8228:3307] -[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance 0x8a97290
2014-01-21 21:21:10.875 oauthMailru[8228:3307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance 0x8a97290'
*** First throw call stack:
(
0 CoreFoundation 0x01aa65e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018298b6 objc_exception_throw + 44
2 CoreFoundation 0x01b43903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01a9690b ___forwarding___ + 1019
4 CoreFoundation 0x01a964ee _CF_forwarding_prep_0 + 14
5 oauthMailru 0x00003a62 __47-[ViewController fetchMailruWithToken:ForUser:]_block_invoke + 402
6 Foundation 0x01545695 __67+[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]_block_invoke_2 + 151
7 Foundation 0x014a5945 -[NSBlockOperation main] + 88
8 Foundation 0x014fe829 -[__NSOperationInternal _start:] + 671
9 Foundation 0x0147b558 -[NSOperation start] + 83
10 Foundation 0x01500af4 __NSOQSchedule_f + 62
11 libdispatch.dylib 0x021344b0 _dispatch_client_callout + 14
12 libdispatch.dylib 0x02121018 _dispatch_async_redirect_invoke + 202
13 libdispatch.dylib 0x021344b0 _dispatch_client_callout + 14
14 libdispatch.dylib 0x02122eeb _dispatch_root_queue_drain + 287
15 libdispatch.dylib 0x02123137 _dispatch_worker_thread2 + 39
16 libsystem_pthread.dylib 0x024c0dab _pthread_wqthread + 336
17 libsystem_pthread.dylib 0x024c4cce start_wqthread + 30
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Does anybody please know what's happening and how to read such crashes?
My source files: ViewController.m, which displays UIWebView and then segues to DetailViewController.m
Your code thinks the JSON deserializes to an object (dictionary), but in fact it deserializes to an array containing one object. Try this:
NSMutableArray *topLevelArray = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingMutableContainers error:nil];
NSDictionary *dict = topLevelArray[0];
If you want to check what you're getting, you can use isKindOfClass: like this:
id jso = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingMutableContainers error:nil];
if (jso == nil) {
// Error. You should probably have passed an NSError ** as the error
// argument so you could log it.
} else if ([jso isKindOfClass:[NSArray class]]) {
NSArray *array = jso;
// process array elements
} else if ([jso isKindOfClass:[NSDictionary class]]) {
NSDictionary *dict = jso;
// process dictionary elements
} else {
// Shouldn't happen unless you use the NSJSONReadingAllowFragments flag.
}

Issue Paging with UITableView

Im trying to create an infinite scroll type thing with Instagram using UITableView and AFNetworking however I get this error when I get to the bottom of the View:
CRASH :
-[__NSCFArray insertObject:atIndex:]: mutating method sent to immutable object
2014-01-05 20:51:41.627 Floadt[1579:70b] STACK TRACE :
(
0 CoreFoundation 0x02b775e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x027a38b6 objc_exception_throw + 44
2 CoreFoundation 0x02b773bb +[NSException raise:format:] + 139
3 CoreFoundation 0x02bfe365 -[__NSCFArray insertObject:atIndex:] + 101
4 CoreFoundation 0x02b3b2d0 -[NSMutableArray insertObjects:count:atIndex:] + 208
5 CoreFoundation 0x02b3af69 -[NSMutableArray insertObjectsFromArray:range:atIndex:] + 425
6 CoreFoundation 0x02b3ad15 -[NSMutableArray addObjectsFromArray:] + 661
7 Floadt 0x0003f5ec __42-[StreamViewController nextInstagramPage:]_block_invoke + 284
8 Floadt 0x0001edfb __64-[AFJSONRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke91 + 43
9 libdispatch.dylib 0x035247f8 _dispatch_call_block_and_release + 15
10 libdispatch.dylib 0x035394b0 _dispatch_client_callout + 14
11 libdispatch.dylib 0x0352775e _dispatch_main_queue_callback_4CF + 340
12 CoreFoundation 0x02bdca5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
13 CoreFoundation 0x02b1d6bb __CFRunLoopRun + 1963
14 CoreFoundation 0x02b1cac3 CFRunLoopRunSpecific + 467
15 CoreFoundation 0x02b1c8db CFRunLoopRunInMode + 123
16 GraphicsServices 0x0453c9e2 GSEventRunModal + 192
17 GraphicsServices 0x0453c809 GSEventRun + 104
18 UIKit 0x01936d3b UIApplicationMain + 1225
19 Floadt 0x0006646d main + 141
20 libdyld.dylib 0x037cb70d start + 1
21 ??? 0x00000001 0x0 + 1
)
Here is how I am making my code, what confuses me is the fact that all my Arrays are Mutable but it states that the mutating method was sent to an immutable object:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.y == roundf(scrollView.contentSize.height-scrollView.frame.size.height)) {
NSDictionary *page = instagramResponse[#"pagination"];
NSString *nextPage = page[#"next_url"];
[[InstagramClient sharedClient] getPath:[NSString stringWithFormat:#"%#",nextPage] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
instagramResponse = [responseObject mutableCopy];
[instagramResponse addEntriesFromDictionary:responseObject];
[instaPics addObjectsFromArray:responseObject[#"data"]];
[self.tableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Failure: %#", error);
}];
}
}
before addEntriesFromDictionary the copy of Dictionarylike this
NSDictionary *copyOfDic = [[NSDictionary alloc] initWithDictionary: originalDic copyItems: YES];
if (copyOfDic ) {
[destination addEntriesFromDictionary: copyOfDic ];
[copyOfDic release];
}
or
[instaPics addObjectsFromArray:[responseObject[#"data"]mutable copy]];
or
Your #property yourarray is either initialized with an NSArray or declared copy.
because both would be lead to this error/exception message since the backing ivar would point to an (immutable) NSArray.
If you have declared your property to be of NSMutableArray type, use strong as the storage modifier instead of copy.

Resources