I use the following code to request a list of products as per the In-App Purchase Programming Guide. It used to work fine in my iPhone application, however now it crashes every time the product list is requested. The delegate method (void)productsRequest:(SKProductsRequest **)request didReceiveResponse:(SKProductsResponse **)response is never called.
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:#"my.product.identifier"]];
[request setDelegate:self];
[request start];
As I said, it worked perfectly fine, then just stopped working. This is the crash which occurs when the above code is called.
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000011
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x000034f8 objc_msgSend + 24
1 StoreKit 0x00003e18 -[SKProductsRequest handleFinishResponse:returningError:] + 40
2 StoreKit 0x000050c4 -[SKRequest _requestFinishedNotification:] + 152
3 Foundation 0x00019b9a _nsnote_callback + 150
4 CoreFoundation 0x0006c2de __CFXNotificationPost_old + 390
5 CoreFoundation 0x0001ab32 _CFXNotificationPostNotification + 122
6 Foundation 0x000048e4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
7 AppSupport 0x0000bb42 -[CPDistributedNotificationCenter deliverNotification:userInfo:] + 38
8 AppSupport 0x0000cf66 _CPDNDeliverNotification + 198
9 AppSupport 0x0000ba4a _XDeliverNotification + 110
10 AppSupport 0x00002e82 migHelperRecievePortCallout + 122
11 CoreFoundation 0x000742ac __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 22
12 CoreFoundation 0x000761d6 __CFRunLoopDoSource1 + 158
13 CoreFoundation 0x0007718e __CFRunLoopRun + 574
14 CoreFoundation 0x0001e0bc CFRunLoopRunSpecific + 220
15 CoreFoundation 0x0001dfca CFRunLoopRunInMode + 54
16 GraphicsServices 0x00003f88 GSEventRunModal + 188
17 UIKit 0x00007b40 -[UIApplication _run] + 564
18 UIKit 0x00005fb8 UIApplicationMain + 964
19 myapp 0x00002fae main (main.m:13)
20 myapp 0x00002f58 start + 32
Thread 1:
0 libSystem.B.dylib 0x00034e84 kevent + 24
1 libSystem.B.dylib 0x00102a48 _dispatch_mgr_invoke + 88
2 libSystem.B.dylib 0x00102494 _dispatch_queue_invoke + 96
3 libSystem.B.dylib 0x00102634 _dispatch_worker_thread2 + 120
4 libSystem.B.dylib 0x0008b53c _pthread_wqthread + 392
5 libSystem.B.dylib 0x00082b6c start_wqthread + 0
Thread 2:
0 libSystem.B.dylib 0x00000ab0 mach_msg_trap + 20
1 libSystem.B.dylib 0x00002f94 mach_msg + 60
2 CoreFoundation 0x00074b18 __CFRunLoopServiceMachPort + 88
3 CoreFoundation 0x000770e0 __CFRunLoopRun + 400
4 CoreFoundation 0x0001e0bc CFRunLoopRunSpecific + 220
5 CoreFoundation 0x0001dfca CFRunLoopRunInMode + 54
6 WebCore 0x0000370c RunWebThread(void*) + 552
7 libSystem.B.dylib 0x0008af80 _pthread_start + 364
8 libSystem.B.dylib 0x0007d014 thread_start + 0
Thread 3:
0 libSystem.B.dylib 0x00000ab0 mach_msg_trap + 20
1 libSystem.B.dylib 0x00002f94 mach_msg + 60
2 CoreFoundation 0x00074b18 __CFRunLoopServiceMachPort + 88
3 CoreFoundation 0x000770e0 __CFRunLoopRun + 400
4 CoreFoundation 0x0001e0bc CFRunLoopRunSpecific + 220
5 CoreFoundation 0x0001dfca CFRunLoopRunInMode + 54
6 Foundation 0x0003c316 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 210
7 Foundation 0x0000c612 -[NSThread main] + 42
8 Foundation 0x00092140 __NSThread__main__ + 908
9 libSystem.B.dylib 0x0008af80 _pthread_start + 364
10 libSystem.B.dylib 0x0007d014 thread_start + 0
Thread 4:
0 libSystem.B.dylib 0x00029f24 select$DARWIN_EXTSN + 20
1 CoreFoundation 0x0007aa54 __CFSocketManager + 340
2 libSystem.B.dylib 0x0008af80 _pthread_start + 364
3 libSystem.B.dylib 0x0007d014 thread_start + 0
I don't know what is causing the objc_msgSend crash, or how it is related to StoreKit. I also have no idea what I added or changed which caused this simple code to stop working.
A very likely explanation is whether the object you set as a delegate for the SKProductRequest object might have been deallocated already.
It is quite possible for the request to take a few seconds to complete, and this might be past the lifetime of your delegate object, so you may want to make sure it sticks around for long enough.
The answer above is technically correct but it is not complete. As Megastep said "the object you set as the delegate for the SKProductsRequest may have already been deallocated." Therefore you are sending a message to an object that has already been deallocated. Now onto the actual answer:
- (void)requestProUpgradeProductData {
NSSet *productIdentifiers = //Your Product IDs go here
productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
productsRequest.delegate = self;
[productsRequest start];
// we will release the request object in the delegate callback
}
#pragma mark -
#pragma mark SKProductRequest Delegate Methods
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse(SKProductsResponse *)response {
self.products = response.products;
//NSLog(#"%i",[products count]);
proUpgradeProduct = [products count] == 4 ? [[products objectAtIndex:0] retain] : nil;
if (proUpgradeProduct)
{
//Do your stuff here...
}
for (NSString *invalidProductId in response.invalidProductIdentifiers)
{
//NSLog(#"Invalid product id: %#" , invalidProductId);
}
// finally release the reqest we alloc/init’ed in requestProUpgradeProductData
[productsRequest release];
[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil];
}
So basically as you can see above you do not need to release productsRequest because it is already being released in the delegate callback method. Again you do not need to call productsRequest release or set it Nil in viewDidUnload/dealloc method because that could cause a crash if you dismiss the view before the callback method gets called.
I'm using an object like a delegate. So in the deinit method of this object i remove the delegate a and crash has been fixed.
private var currentProductRequest: SKProductsRequest?
deinit {
if let r = currentProductRequest {
r.delegate = nil
r.cancel()
currentProductRequest = nil
}
}
Related
I have a weird crash while using NSUserDefaults and I'm unable to reproduce this myself but I get this reported from Crashlytics from one of user's devices.
Exception: EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
Crashed: com.apple.NSURLConnectionLoader
0 libobjc.A.dylib 0x22613a76 objc_msgSend + 21
1 CoreFoundation 0x22e97a58 __CFBasicHashDrain + 448
2 CoreFoundation 0x22d77795 CFRelease + 424
3 CoreFoundation 0x22e979e8 __CFBasicHashDrain + 336
4 CoreFoundation 0x22d77795 CFRelease + 424
5 CoreFoundation 0x22e26b8f -[CFPrefsSearchListSource alreadylocked_copyDictionary] + 906
6 CoreFoundation 0x22e258ad -[CFPrefsSearchListSource alreadylocked_copyValueForKey:] + 52
7 CoreFoundation 0x22e9f6bb -[CFPrefsSource copyValueForKey:] + 50
8 CoreFoundation 0x22ea1e3d ___CFPreferencesCopyAppValueWithContainerAndConfiguration_block_invoke + 28
9 CoreFoundation 0x22e23969 __95+[CFPrefsSearchListSource withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 400
10 CoreFoundation 0x22e2377f normalizeQuintuplet + 354
11 CoreFoundation 0x22e23617 +[CFPrefsSearchListSource withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 106
12 CoreFoundation 0x22ea1dc9 _CFPreferencesCopyAppValueWithContainerAndConfiguration + 248
13 Foundation 0x235c436f -[NSUserDefaults(NSUserDefaults) objectForKey:] + 46
14 MyApp 0x12ddc49 -[MyStore getConfigValue:] (MyStore.m:43)
The code in MyStore is as below:
- (id) getConfigValue:(NSString *)key {
if (key) {
return [[NSUserDefaults standardUserDefaults] valueForKey:key];
}
return nil;
}
And I call this method as below
NSString *userId = [storeObj getConfigValue:#"UserID"];
Now, this value may not be set in some cases but that should just return nil. I'm unable to find any valid reason for this to crash.
Thanks for help.
I am currently working on an iOS app which crashes and generates the crash report provided below.We think that the app is crashing due to mutation while Fast Enumeration but the error is occurring in NSISEngine.
We also think that the issue is related to constraints of a Table View. This Table View shows info fetched from Rest Services and we are programmatically updating the DataSource in viewWillAppear().
Some of the constraints we are adding programmatically which are as follows:
Method:
1.cellForRowAtIndexPath()
Constraints:
a. Updated UILabel with attributed String to set line height:
[attributedString addAttribute:NSFontAttributeName value:self.font range:NSMakeRange(0, text.length)];
self.attributedText = attributedString;
b. Updated UIImage:
myCell.myLogo.layer.masksToBounds =YES;
myCell.myLogo.layer.opaque = NO;
[[myCell.myLogo layer] setCornerRadius:4.];
c. Border for Table View cell
mySecondCell.secondCellContainerView.layer.masksToBounds = YES;
[mySecondCell.secondCellContainerView.layer setCornerRadius:3.7];
[mySecondCell.secondCellContainerView addBorderWithColorRed:#214 Green:#214 Blue:#214];
[myCell.myLogo addBorderWithColorRed:#214 Green:#214 Blue:#214];
heightForRowAtIndexPath()
Constraints:
We are calculating height on the basis of the content which is dynamic.
We are using StoryBoard and some of the constraints are set there using Auto Layout.
I searched a lot however was unable to find a crash report similar to the one my app generated. I am new to iOS programming. Can somebody help me with debugging this crash report? If there is a constraint causing this issue, can somebody help me figure out the same? Thanks in advance.
Incident Identifier: F155875B-9FD3-425F-85B9-7595617AF52A
CrashReporter Key: aaa79870161ff1e371394b881a26e97f0066f464
Hardware Model: iPhone5,2
Process: myapp [611]
Path: /var/mobile/Applications/40D6D77C-1DBB-4F6B-BEE1-73A67C789C49/myapp.app/myapp
Identifier: com.myapp
Version: 1.0 (0.9)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-10-17 11:16:45.559 +0530
OS Version: iOS 7.0.2 (11A501)
Report Version: 104
Exception Type: EXC_CRASH (SIGTRAP)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x2fc9fe86 __exceptionPreprocess + 126
1 libobjc.A.dylib 0x39f9a6c2 objc_exception_throw + 34
2 CoreFoundation 0x2fc9f974 __NSFastEnumerationMutationHandler + 124
3 Foundation 0x30604f32 -[NSISEngine substituteOutAllOccurencesOfBodyVar:withExpression:] + 438
4 Foundation 0x30607ba2 -[NSISEngine pivotToMakeBodyVar:newHeadOfRowWithHead:andDropRow:] + 334
5 Foundation 0x3060594c -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 232
6 Foundation 0x3060546e -[NSISEngine optimize] + 170
7 Foundation 0x306011a8 -[NSISEngine withBehaviors:performModifications:] + 312
8 UIKit 0x32424490 -[UIView(Hierarchy) _postMovedFromSuperview:] + 292
9 UIKit 0x3243114e -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1398
10 UIKit 0x32447a9c -[UIView(Hierarchy) insertSubview:atIndex:] + 32
11 UIKit 0x325fb888 -[UINavigationBar _wrapView:inClippingViewWithLeftBoundary:rightBoundary:leftMaskImage:leftMaskIsChevron:rightMaskImage:] + 240
12 UIKit 0x325b505e -[UINavigationBar _startPopAnimationFromItems:fromBarStyle:toItems:toBarStyle:] + 1982
13 UIKit 0x324f1b88 -[UINavigationBar popNavigationItem] + 1316
14 UIKit 0x324f14a0 -[UINavigationBar _popNavigationItemWithTransition:] + 556
15 UIKit 0x326f02ac ___popViewControllerNormal_block_invoke + 152
16 UIKit 0x324d43a0 -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
17 UIKit 0x324d3fe4 -[UINavigationController __viewWillLayoutSubviews] + 40
18 UIKit 0x324d3f78 -[UILayoutContainerView layoutSubviews] + 180
19 UIKit 0x3242552e -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 342
20 QuartzCore 0x320acf3e -[CALayer layoutSublayers] + 138
21 QuartzCore 0x320a8762 CA::Layer::layout_if_needed(CA::Transaction*) + 346
22 QuartzCore 0x320a85f4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12
23 QuartzCore 0x320a8008 CA::Context::commit_transaction(CA::Transaction*) + 224
24 QuartzCore 0x320a7e1a CA::Transaction::commit() + 310
25 QuartzCore 0x320d5436 CA::Transaction::release_thread(void*) + 158
26 libsystem_pthread.dylib 0x3a5af9b0 _pthread_tsd_cleanup + 160
27 libsystem_pthread.dylib 0x3a5af732 _pthread_exit + 82
28 libsystem_pthread.dylib 0x3a5b04b8 pthread_exit + 24
29 Foundation 0x305d7ac6 +[NSThread exit] + 6
30 Foundation 0x30683de0 __NSThread__main__ + 1088
31 libsystem_pthread.dylib 0x3a5b0c58 _pthread_body + 136
32 libsystem_pthread.dylib 0x3a5b0bca _pthread_start + 98
33 libsystem_pthread.dylib 0x3a5aeccc thread_start + 4
Thread 0 Crashed:
0 libsystem_malloc.dylib 0x3a572596 szone_free_definite_size + 1510
1 UIFoundation 0x3754aab4 -[NSAttributeDictionaryEnumerator dealloc] + 68
2 libobjc.A.dylib 0x39fa5b06 objc_object::sidetable_release(bool) + 170
3 libobjc.A.dylib 0x39f9701e (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 354
4 QuartzCore 0x320a1b54 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 64
5 CoreFoundation 0x2fc6af6e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
6 CoreFoundation 0x2fc688fa __CFRunLoopDoObservers + 282
7 CoreFoundation 0x2fc68c46 __CFRunLoopRun + 734
8 CoreFoundation 0x2fbd353c CFRunLoopRunSpecific + 520
9 CoreFoundation 0x2fbd331e CFRunLoopRunInMode + 102
10 GraphicsServices 0x3490a2e6 GSEventRunModal + 134
11 UIKit 0x3248a1e0 UIApplicationMain + 1132
12 myapp 0x000aac16 main (main.mm:16)
13 libdyld.dylib 0x3a493ab4 start + 0
Thread 1:
0 libsystem_kernel.dylib 0x3a537838 kevent64 + 24
1 libdispatch.dylib 0x3a4860d0 _dispatch_mgr_invoke + 228
2 libdispatch.dylib 0x3a48063e _dispatch_mgr_thread + 34
Thread 2 name: com.apple.NSURLConnectionLoader
Thread 2:
0 libsystem_kernel.dylib 0x3a537a84 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3a53787c mach_msg + 36
2 CoreFoundation 0x2fc6a55c __CFRunLoopServiceMachPort + 152
3 CoreFoundation 0x2fc68c7c __CFRunLoopRun + 788
4 CoreFoundation 0x2fbd353c CFRunLoopRunSpecific + 520
5 CoreFoundation 0x2fbd331e CFRunLoopRunInMode + 102
6 Foundation 0x3060e64c +[NSURLConnection(Loader) _resourceLoadLoop:] + 316
7 Foundation 0x30683dc2 __NSThread__main__ + 1058
8 libsystem_pthread.dylib 0x3a5b0c5a _pthread_body + 138
9 libsystem_pthread.dylib 0x3a5b0bca _pthread_start + 98
10 libsystem_pthread.dylib 0x3a5aeccc thread_start + 4
Thread 3 name: com.apple.CFSocket.private
Thread 3:
0 libsystem_kernel.dylib 0x3a54a440 select$DARWIN_EXTSN + 20
1 CoreFoundation 0x2fc6e45e __CFSocketManager + 482
2 libsystem_pthread.dylib 0x3a5b0c5a _pthread_body + 138
3 libsystem_pthread.dylib 0x3a5b0bca _pthread_start + 98
4 libsystem_pthread.dylib 0x3a5aeccc thread_start + 4
[12:37:06 PM] Devika Deshmukh: Thread 4:
0 libsystem_kernel.dylib 0x3a537a84 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3a53787c mach_msg + 36
2 CoreFoundation 0x2fc6a55c __CFRunLoopServiceMachPort + 152
3 CoreFoundation 0x2fc68c7c __CFRunLoopRun + 788
4 CoreFoundation 0x2fbd353c CFRunLoopRunSpecific + 520
5 CoreFoundation 0x2fbd331e CFRunLoopRunInMode + 102
6 Foundation 0x305c1822 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7 Foundation 0x30612664 -[NSRunLoop(NSRunLoop) run] + 76
8 myapp 0x00197bdc +[AFURLConnectionOperation networkRequestThreadEntryPoint:] (AFURLConnectionOperation.m:160)
9 Foundation 0x30683dc2 __NSThread__main__ + 1058
10 libsystem_pthread.dylib 0x3a5b0c5a _pthread_body + 138
11 libsystem_pthread.dylib 0x3a5b0bca _pthread_start + 98
12 libsystem_pthread.dylib 0x3a5aeccc thread_start + 4
Thread 5:
0 libsystem_c.dylib 0x3a4fb09e __abort + 102
1 libsystem_c.dylib 0x3a4fb034 abort + 84
2 myapp 0x001bd8ea ___lldb_unnamed_function5196$$myapp + 22
3 CoreFoundation 0x2fca018a __handleUncaughtException + 578
4 libobjc.A.dylib 0x39f9a924 _objc_terminate() + 172
5 libc++abi.dylib 0x399601b0 std::__terminate(void (*)()) + 76
6 libc++abi.dylib 0x3995fa04 __cxa_throw + 112
7 libobjc.A.dylib 0x39f9a796 objc_exception_throw + 246
8 CoreFoundation 0x2fc9f974 __NSFastEnumerationMutationHandler + 124
9 Foundation 0x30604f32 -[NSISEngine substituteOutAllOccurencesOfBodyVar:withExpression:] + 438
10 Foundation 0x30607ba2 -[NSISEngine pivotToMakeBodyVar:newHeadOfRowWithHead:andDropRow:] + 334
11 Foundation 0x3060594c -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 232
12 Foundation 0x3060546e -[NSISEngine optimize] + 170
13 Foundation 0x306011a8 -[NSISEngine withBehaviors:performModifications:] + 312
14 UIKit 0x32424490 -[UIView(Hierarchy) _postMovedFromSuperview:] + 292
15 UIKit 0x3243114e -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1398
16 UIKit 0x32447a9c -[UIView(Hierarchy) insertSubview:atIndex:] + 32
17 UIKit 0x325fb888 -[UINavigationBar _wrapView:inClippingViewWithLeftBoundary:rightBoundary:leftMaskImage:leftMaskIsChevron:rightMaskImage:] + 240
18 UIKit 0x325b505e -[UINavigationBar _startPopAnimationFromItems:fromBarStyle:toItems:toBarStyle:] + 1982
19 UIKit 0x324f1b88 -[UINavigationBar popNavigationItem] + 1316
20 UIKit 0x324f14a0 -[UINavigationBar _popNavigationItemWithTransition:] + 556
21 UIKit 0x326f02ac ___popViewControllerNormal_block_invoke + 152
22 UIKit 0x324d43a2 -[UINavigationController _startDeferredTransitionIfNeeded:] + 870
23 UIKit 0x324d3fe4 -[UINavigationController __viewWillLayoutSubviews] + 40
24 UIKit 0x324d3f78 -[UILayoutContainerView layoutSubviews] + 180
25 UIKit 0x3242552e -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 342
26 QuartzCore 0x320acf3e -[CALayer layoutSublayers] + 138
27 QuartzCore 0x320a8762 CA::Layer::layout_if_needed(CA::Transaction*) + 346
28 QuartzCore 0x320a85f4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12
29 QuartzCore 0x320a8008 CA::Context::commit_transaction(CA::Transaction*) + 224
30 QuartzCore 0x320a7e1a CA::Transaction::commit() + 310
31 QuartzCore 0x320d5436 CA::Transaction::release_thread(void*) + 158
32 libsystem_pthread.dylib 0x3a5af9b2 _pthread_tsd_cleanup + 162
33 libsystem_pthread.dylib 0x3a5af732 _pthread_exit + 82
34 libsystem_pthread.dylib 0x3a5b04b8 pthread_exit + 24
35 Foundation 0x305d7ac6 +[NSThread exit] + 6
36 Foundation 0x30683de0 __NSThread__main__ + 1088
37 libsystem_pthread.dylib 0x3a5b0c5a _pthread_body + 138
38 libsystem_pthread.dylib 0x3a5b0bca _pthread_start + 98
39 libsystem_pthread.dylib 0x3a5aeccc thread_start + 4
Thread 6:
0 libsystem_kernel.dylib 0x3a54ac7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3a5aee06 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x3a5aecc0 start_wqthread + 4
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x00280a00 r1: 0xfffff000 r2: 0x17f9a000 r3: 0x0000000c
r4: 0x17f99650 r5: 0x3c32fe08 r6: 0x3c32fe00 r7: 0x27d5cb50
r8: 0x00000001 r9: 0x00000fff r10: 0x17f99650 r11: 0x0000008a
ip: 0x17f99db0 sp: 0x27d5cb4c lr: 0x39f96e39 pc: 0x3a572596
cpsr: 0x20000030
Update:
Following is the code by which we are populating our datasource:
(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
viewWillAppearFlag = true;
if(dataFetched) {
[self setupDatasourceDetails:self.myData];
}
}
(void) setupDatasourceDetails:(NSArray *)data {
self.datasource = [MyDatasource new];
self.datasource.data=data;
[self.myTable setDataSource:self.datasource];
[self.myTable setDelegate:self.datasource];
[self.myTable reloadData];
}
//Callback from REST services
(void) onDataFetched:(NSArray *)data{
dataFetched=true;
self.myData=data;
if(viewWillAppearFlag){
[self setupDatasourceDetails:self.myData]; //the event which will occur later(either viewWillAppear or dataFetched) calls setupDatasourceDetails
}
}
Update:
The error is occurring while transition back from one view controller to another (in navigation controller).
We are using [self.navigationController popViewControllerAnimated:YES]; to transition back to the previous view controller. The transition is happening on the Main thread.
Let us know if any more information is required.
Update
It seems that our problem has been resolved. We moved the functionality from viewWillAppear to viewDidAppear. This fix seems to have resolved the issue. Does anyone know the reason why this fix worked? Please let us know. Thanks.
Two suggestions:
Check that self.datasource is defined as strong property (not
weak) (and the data property on MyDatasource)
Make sure
onDataFetched:is called on the main queue. If unsure, use this
dispatching mechanism instead:
dispatch_async(dispatch_get_main_queue(), ^{
// all update code here
});
I don't think the error is directly in the code you posted, but:
NSFastEnumerationMutationHandler
is raised when you are editing an array or dictionary while enumerating it.
For example this is wrong:
for ( id obj in anArray ) {
if ( [obj shouldRemove == YES ) {
[anArray removeObject:obj];
}
}
If you need to do that you should work with a copy of an array or use filteredArrayUsingPredicate.
Can't see all of your code, but I am thinking you need to call layoutIfNeeded before setting the constraints as the views are not calculated before ViewWillAppear. The fact that it succeeds in ViewDidAppear is because the elements have been calculated. Alternately, you could try your code in DidLayoutSubviews.
This question already has answers here:
Core Data causing app to crash while migrating
(1 answer)
Why is App crashing when loading a pre populated DB into Core Data upon first open on Older Devices?
(1 answer)
Closed 9 years ago.
In my project, sometimes when call - (void)saveContext, the app crash, keep the screen locked, nothing could be done.
I found that in function - (void)saveContext below
- (void)saveContext
{
NSError *error = nil;
NSManagedObjectContext *managedObjectContext = _dataController.managedObjectContext;
if (managedObjectContext != nil) {
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(#"Unresolved error %#, %#", error, [error userInfo]);
abort();
}
else {
NSLog(#"save successful?");
}
}
if (error != nil) {
NSLog(#"Unresolved error %#, %#", error, [error userInfo]);
}
}
there is no output message. Core data's save function did not success and no failed error.
Why did that happen?Could somebody help me? Thanks!
crash report
Date/Time: 2013-10-03 18:05:31.016 +0800
OS Version: iOS 6.1.3 (10B329)
Report Version: 104
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 0
Elapsed total CPU time (seconds): 11.020 (user 11.020, system 0.000), 55% CPU
Elapsed application CPU time (seconds): 9.389, 47% CPU
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libobjc.A.dylib 0x3b8745ac objc_msgSend + 12
1 CoreData 0x337f6bf4 -[NSSQLCore createAdapterOperationsForDatabaseOperation:] + 232
2 CoreData 0x337f88c0 -[NSSQLCore performChanges] + 184
3 CoreData 0x337f9a56 -[NSSQLCore saveChanges:] + 630
4 CoreData 0x3376022a -[NSSQLCore executeRequest:withContext:error:] + 506
5 CoreData 0x3375f4c4 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1300
6 CoreData 0x337b76de -[NSManagedObjectContext save:] + 726
7 LFeCatalogue 0x000ff130 -[AppDelegate saveContext] (AppDelegate.m:329)
8 LFeCatalogue 0x00152432 -[ECatalogueDataController alertView:clickedButtonAtIndex:] (ECatalogueDataController.m:2316)
9 UIKit 0x3591dc4c -[UIAlertView(Private) _buttonClicked:] + 292
10 UIKit 0x358b10c0 -[UIApplication sendAction:to:from:forEvent:] + 68
11 UIKit 0x358b1072 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
12 UIKit 0x358b1050 -[UIControl sendAction:to:forEvent:] + 40
13 UIKit 0x358b0906 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 498
14 UIKit 0x358b0dfc -[UIControl touchesEnded:withEvent:] + 484
15 UIKit 0x357d95ec -[UIWindow _sendTouchesForEvent:] + 520
16 UIKit 0x357c67fc -[UIApplication sendEvent:] + 376
17 UIKit 0x357c6116 _UIApplicationHandleEvent + 6150
18 GraphicsServices 0x374d15a0 _PurpleEventCallback + 588
19 GraphicsServices 0x374d11ce PurpleEventCallback + 30
20 CoreFoundation 0x33993170 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
21 CoreFoundation 0x33993112 __CFRunLoopDoSource1 + 134
22 CoreFoundation 0x33991f94 __CFRunLoopRun + 1380
23 CoreFoundation 0x33904eb8 CFRunLoopRunSpecific + 352
24 CoreFoundation 0x33904d44 CFRunLoopRunInMode + 100
25 GraphicsServices 0x374d02e6 GSEventRunModal + 70
26 UIKit 0x3581a2fc UIApplicationMain + 1116
27 LFeCatalogue 0x000fdc72 main (main.m:16)
28 libdyld.dylib 0x3bcb0b1c start + 0
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x3bd67648 kevent64 + 24
1 libdispatch.dylib 0x3bc97974 _dispatch_mgr_invoke + 792
2 libdispatch.dylib 0x3bc97654 _dispatch_mgr_thread$VARIANT$mp + 32
Thread 2 name: WebThread
Thread 2:
0 libsystem_kernel.dylib 0x3bd66eb4 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3bd67048 mach_msg + 36
2 CoreFoundation 0x33993040 __CFRunLoopServiceMachPort + 124
3 CoreFoundation 0x33991d9e __CFRunLoopRun + 878
4 CoreFoundation 0x33904eb8 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x33904d44 CFRunLoopRunInMode + 100
6 WebCore 0x3990b500 _ZL12RunWebThreadPv + 440
7 libsystem_c.dylib 0x3bcd030e _pthread_start + 306
8 libsystem_c.dylib 0x3bcd01d4 thread_start + 4
Thread 3 name: com.apple.NSURLConnectionLoader
Thread 3:
0 libsystem_kernel.dylib 0x3bd66eb4 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3bd67048 mach_msg + 36
2 CoreFoundation 0x33993040 __CFRunLoopServiceMachPort + 124
3 CoreFoundation 0x33991d9e __CFRunLoopRun + 878
4 CoreFoundation 0x33904eb8 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x33904d44 CFRunLoopRunInMode + 100
6 Foundation 0x342513d0 +[NSURLConnection(Loader) _resourceLoadLoop:] + 304
7 Foundation 0x342d4e80 __NSThread__main__ + 968
8 libsystem_c.dylib 0x3bcd030e _pthread_start + 306
9 libsystem_c.dylib 0x3bcd01d4 thread_start + 4
Thread 4 name: com.apple.CFSocket.private
Thread 4:
0 libsystem_kernel.dylib 0x3bd77594 __select + 20
1 CoreFoundation 0x339971f2 __CFSocketManager + 674
2 libsystem_c.dylib 0x3bcd030e _pthread_start + 306
3 libsystem_c.dylib 0x3bcd01d4 thread_start + 4
Thread 5:
0 libsystem_kernel.dylib 0x3bd77d98 __workq_kernreturn + 8
1 libsystem_c.dylib 0x3bcc5cf6 _pthread_workq_return + 14
2 libsystem_c.dylib 0x3bcc5a12 _pthread_wqthread + 362
3 libsystem_c.dylib 0x3bcc58a0 start_wqthread + 4
Thread 6:
0 libsystem_kernel.dylib 0x3bd77d98 __workq_kernreturn + 8
1 libsystem_c.dylib 0x3bcc5cf6 _pthread_workq_return + 14
2 libsystem_c.dylib 0x3bcc5a12 _pthread_wqthread + 362
3 libsystem_c.dylib 0x3bcc58a0 start_wqthread + 4
Unknown thread crashed with unknown flavor: 5, state_count: 1
The latest version of my app has started to crash on startup for some users. There is only 1 crash report in itunes which is included below. I have been unable to reproduce on any devices.
The changes between the two version are
Integrated two third party libraries (iNotify, openUDID)
Switched from the GCC compiler to the Apple LLVM 3.1 compiler (new libraries need arc support)
Compiled the new libraries's code with arc enabled, left arc disabled for the rest of the project.
I added 1 line to the didFinishLaunchingWithOptions in my appdelegate for iNotify. From the stack trace through I do not think its crashing in there.
At a bit of a loss where to go with this. Any help would be appreciated. Thanks!
Hardware Model: iPhone4,1
Process: MyAPP [3251]
Path: /var/mobile/Applications/228BBF42-A374-4773-8C18-EFA47CE98C02/MyAPP.app/MyAPP
Identifier: MyAPP
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2012-05-03 19:50:07.917 -0500
OS Version: iPhone OS 5.1 (9B179)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x3729e88f __exceptionPreprocess + 163
1 libobjc.A.dylib 0x357a4259 objc_exception_throw + 33
2 CoreFoundation 0x372a1a9b -[NSObject doesNotRecognizeSelector:] + 175
3 CoreFoundation 0x372a0915 ___forwarding___ + 301
4 CoreFoundation 0x371fb650 _CF_forwarding_prep_0 + 48
5 UIKit 0x33aa9f93 -[UIAlertView(Private) _popoutAnimationDidStop:finished:] + 855
6 UIKit 0x3395fc53 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 471
7 UIKit 0x3396557d -[UIViewAnimationState animationDidStop:finished:] + 53
8 QuartzCore 0x341fbc2f CA::Layer::run_animation_callbacks(void*) + 203
9 libdispatch.dylib 0x344f6ee7 _dispatch_main_queue_callback_4CF$VARIANT$mp + 195
10 CoreFoundation 0x372712ad __CFRunLoopRun + 1269
11 CoreFoundation 0x371f44a5 CFRunLoopRunSpecific + 301
12 CoreFoundation 0x371f436d CFRunLoopRunInMode + 105
13 GraphicsServices 0x32101439 GSEventRunModal + 137
14 UIKit 0x33978e7d UIApplicationMain + 1081
15 MyAPP 0x00002bfb main (main.m:14)
16 MyAPP 0x00002bb4 0x00002bb4
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3571d32c __pthread_kill + 8
1 libsystem_c.dylib 0x3186b208 pthread_kill + 48
2 libsystem_c.dylib 0x31864298 abort + 88
3 libc++abi.dylib 0x34e70f64 abort_message + 40
4 libc++abi.dylib 0x34e6e346 _ZL17default_terminatev + 18
5 libobjc.A.dylib 0x357a4350 _objc_terminate + 140
6 libc++abi.dylib 0x34e6e3be _ZL19safe_handler_callerPFvvE + 70
7 libc++abi.dylib 0x34e6e44a std::terminate() + 14
8 libc++abi.dylib 0x34e6f81e __cxa_rethrow + 82
9 libobjc.A.dylib 0x357a42a2 objc_exception_rethrow + 6
10 CoreFoundation 0x371f4506 CFRunLoopRunSpecific + 398
11 CoreFoundation 0x371f4366 CFRunLoopRunInMode + 98
12 GraphicsServices 0x32101432 GSEventRunModal + 130
13 UIKit 0x33978e76 UIApplicationMain + 1074
14 MyAPP 0x00002bf4 main (main.m:14)
15 MyAPP 0x00002bac 0x00002bac
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x3570d3a8 kevent + 24
1 libdispatch.dylib 0x344f7f04 _dispatch_mgr_invoke + 708
2 libdispatch.dylib 0x344f7c22 _dispatch_mgr_thread + 30
Thread 2 name: WebThread
Thread 2:
0 libsystem_kernel.dylib 0x3570d004 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3570d1fa mach_msg + 50
2 CoreFoundation 0x372723ec __CFRunLoopServiceMachPort + 120
3 CoreFoundation 0x37271124 __CFRunLoopRun + 876
4 CoreFoundation 0x371f449e CFRunLoopRunSpecific + 294
5 CoreFoundation 0x371f4366 CFRunLoopRunInMode + 98
6 WebCore 0x32eb40f0 _ZL12RunWebThreadPv + 396
7 libsystem_c.dylib 0x3182c72e _pthread_start + 314
8 libsystem_c.dylib 0x3182c5e8 thread_start + 0
Thread 3:
0 libsystem_kernel.dylib 0x3571dcd4 __workq_kernreturn + 8
1 libsystem_c.dylib 0x31826f36 _pthread_wqthread + 610
2 libsystem_c.dylib 0x31826cc8 start_wqthread + 0
Thread 4 name: com.apple.CFSocket.private
Thread 4:
0 libsystem_kernel.dylib 0x3571d570 __select + 20
1 CoreFoundation 0x3727663a __CFSocketManager + 726
2 libsystem_c.dylib 0x3182c72e _pthread_start + 314
3 libsystem_c.dylib 0x3182c5e8 thread_start + 0
Thread 5:
0 libsystem_kernel.dylib 0x3571dcd4 __workq_kernreturn + 8
1 libsystem_c.dylib 0x31826f36 _pthread_wqthread + 610
2 libsystem_c.dylib 0x31826cc8 start_wqthread + 0
Some additional code.
There is an alertview defined in the appdelegate as follows:
#import <UIKit/UIKit.h>
#class MyAPPViewController;
#interface MyAPPAppDelegate : NSObject <UIApplicationDelegate> {
UIViewController *rvc;
UIAlertView *m_cAlertControl;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
-(BOOL)shouldNag;
-(void)shouldEnableUI:(BOOL)pIsEnable;
-(void)updateRunCount;
#end
and a method implemented in the app delegate as follows:
-(void)shouldEnableUI:(BOOL)pIsEnable
{
if(NO == pIsEnable)
{
if (nil == m_cAlertControl) {
m_cAlertControl = [[UIAlertView alloc] init];
}
m_cAlertControl.backgroundColor = [UIColor clearColor];
m_cAlertControl.opaque = NO;
[m_cAlertControl setHidden:YES];
[m_cAlertControl show];
}
else {
if (nil != m_cAlertControl) {
[m_cAlertControl dismissWithClickedButtonIndex:0 animated:YES];
}
}
}
The View controller's make calls to the method like this:
[appDelegate shouldEnableUI:NO];
On seeing crash logs issue seems like call has been made to UIAlertViewDelegate after it has been released.
You need to release that in the controller where you are using alert -
-(void)dealloc {
self.alertView.delegate = nil; //setting delegate to nil
self.alertView = nil; //if you have defined alert as property
//other release statements of your controller
[super dealloc];
}
You can add some code of your app if you want some other information, or this is not the case with your app.
EDIT 1 -
-(void)dealloc {
m_cAlertControl.delegate = nil; //setting delegate to nil
[m_cAlertControl release];
//other release statements of your controller
[super dealloc];
}
I would say that this is the biggest pointer you have
[NSObject doesNotRecognizeSelector:] + 175
Looks like you have a missing selector method somewhere.
I'm having a really hard time when trying to cancel requests in an NSOperationQueue.
Before deallocating my 'engine' object, I call a cancelOperations method to cancel everything in the queue, so this will include in flight ASIHTTPRequests and queued ones... e.g.
Engine.m
-(void)getContent {
if (![self queue]) {
[self setQueue:[[[NSOperationQueue alloc] init] autorelease]];
}
NSURL *url = [NSURL URLWithString:#"http://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request setDidFinishSelector:#selector(requestDone:)];
[[self queue] addOperation:request]; //queue is an NSOperationQueue
}
-(void)requestDone:(ASIHTTPRequest)*request {
// Do something with request
}
-(void)cancelOperations {
[self.queue cancelAllOperations];
[self.queue waitUntilAllOperationsAreFinished];
}
-(void)dealloc {
[super dealloc];
}
Now, In my engine I have a number of getContent type methods, so my queue has different request objects in it. The flow when using an Engine object is:
1) Open View Controller - view did load - alloc and init Engine object
2) // Call various getContent style methods to queue up some operations
3) Upon view exit, call [engine cancelOperations]; in order to (a) Stop any network requests in flight, and to also empty the queue
4) Deallocate the view, and with that the engine: [engine release];
This works fine if all requests have finished in the queue (as it's empty), however if I cancelOperations whilst a request is active, the application crashes with a EXC_BAD_ACCESS error... but AFTER the engine is deallocated successfully...
Any ideas why this would be?
--EDIT--
Adding Backtrace for error:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000b0000000
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Application Specific Information:
objc_msgSend() selector name: respondsToSelector:
iPhone Simulator 225, iPhone OS 4.1 (iPhone 4/8B117)
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x02cb5907 objc_msgSend + 27
1 CoreFoundation 0x02ac95cd __invoking___ + 29
2 CoreFoundation 0x02ac94a1 -[NSInvocation invoke] + 145
3 Foundation 0x0015a3ca __NSThreadPerformPerform + 251
4 CoreFoundation 0x02b39faf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
5 CoreFoundation 0x02a9839b __CFRunLoopDoSources0 + 571
6 CoreFoundation 0x02a97896 __CFRunLoopRun + 470
7 CoreFoundation 0x02a97350 CFRunLoopRunSpecific + 208
8 CoreFoundation 0x02a97271 CFRunLoopRunInMode + 97
9 GraphicsServices 0x0320c00c GSEventRunModal + 217
10 GraphicsServices 0x0320c0d1 GSEventRun + 115
11 UIKit 0x003e9af2 UIApplicationMain + 1160
12 Clicky 0x000027d4 main + 102 (main.m:14)
13 Clicky 0x00002765 start + 53
Thread 1: Dispatch queue: com.apple.libdispatch-manager
0 libSystem.B.dylib 0x97cfe942 kevent + 10
1 libSystem.B.dylib 0x97cff05c _dispatch_mgr_invoke + 215
2 libSystem.B.dylib 0x97cfe519 _dispatch_queue_invoke + 163
3 libSystem.B.dylib 0x97cfe2be _dispatch_worker_thread2 + 240
4 libSystem.B.dylib 0x97cfdd41 _pthread_wqthread + 390
5 libSystem.B.dylib 0x97cfdb86 start_wqthread + 30
Thread 2:
0 libSystem.B.dylib 0x97cfd9d2 __workq_kernreturn + 10
1 libSystem.B.dylib 0x97cfdf68 _pthread_wqthread + 941
2 libSystem.B.dylib 0x97cfdb86 start_wqthread + 30
Thread 3: WebThread
0 libSystem.B.dylib 0x97cd80fa mach_msg_trap + 10
1 libSystem.B.dylib 0x97cd8867 mach_msg + 68
2 CoreFoundation 0x02b3a436 __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x02a97984 __CFRunLoopRun + 708
4 CoreFoundation 0x02a97350 CFRunLoopRunSpecific + 208
5 CoreFoundation 0x02a97271 CFRunLoopRunInMode + 97
6 WebCore 0x034093a3 RunWebThread(void*) + 483
7 libSystem.B.dylib 0x97d0581d _pthread_start + 345
8 libSystem.B.dylib 0x97d056a2 thread_start + 34
Thread 4:
0 libSystem.B.dylib 0x97cfd9d2 __workq_kernreturn + 10
1 libSystem.B.dylib 0x97cfdf68 _pthread_wqthread + 941
2 libSystem.B.dylib 0x97cfdb86 start_wqthread + 30
Thread 5:
0 libSystem.B.dylib 0x97cd80fa mach_msg_trap + 10
1 libSystem.B.dylib 0x97cd8867 mach_msg + 68
2 CoreFoundation 0x02b3a436 __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x02a97984 __CFRunLoopRun + 708
4 CoreFoundation 0x02a97350 CFRunLoopRunSpecific + 208
5 CoreFoundation 0x02a9a614 CFRunLoopRun + 84
6 Clicky 0x0001fdb7 +[ASIHTTPRequest runRequests] + 167 (ASIHTTPRequest.m:4093)
7 Foundation 0x0014576c -[NSThread main] + 81
8 Foundation 0x001456f8 __NSThread__main__ + 1387
9 libSystem.B.dylib 0x97d0581d _pthread_start + 345
10 libSystem.B.dylib 0x97d056a2 thread_start + 34
Thread 6:
0 libSystem.B.dylib 0x97cd80fa mach_msg_trap + 10
1 libSystem.B.dylib 0x97cd8867 mach_msg + 68
2 CoreFoundation 0x02b3a436 __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x02a97984 __CFRunLoopRun + 708
4 CoreFoundation 0x02a97350 CFRunLoopRunSpecific + 208
5 CoreFoundation 0x02a97271 CFRunLoopRunInMode + 97
6 Foundation 0x0017ab86 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 398
7 Foundation 0x0014576c -[NSThread main] + 81
8 Foundation 0x001456f8 __NSThread__main__ + 1387
9 libSystem.B.dylib 0x97d0581d _pthread_start + 345
10 libSystem.B.dylib 0x97d056a2 thread_start + 34
Thread 7:
0 libSystem.B.dylib 0x97cf7086 select$DARWIN_EXTSN + 10
1 CoreFoundation 0x02acbb5e __CFSocketManager + 798
2 libSystem.B.dylib 0x97d0581d _pthread_start + 345
3 libSystem.B.dylib 0x97d056a2 thread_start + 34
Thread 8:
0 libSystem.B.dylib 0x97cfd9d2 __workq_kernreturn + 10
1 libSystem.B.dylib 0x97cfdf68 _pthread_wqthread + 941
2 libSystem.B.dylib 0x97cfdb86 start_wqthread + 30
Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x06641500 ebx: 0x000143f3 ecx: 0x0008e1c8 edx: 0x06606075
edi: 0xb0000000 esi: 0x066554c4 ebp: 0xbfffdef8 esp: 0xbfffdec4
ss: 0x0000001f efl: 0x00010206 eip: 0x02cb5907 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037
cr2: 0xb0000000
You do not release your operation queue in dealloc...
One suspect is the delegation pattern:
[request setDelegate:self];
If the self object is destroyed, and the request isn't, when the request 'completes', it will try to notify some garbage in memory, hence crash.
UPDATE: to patch this, add this code before canceling:
for (ASIHTTPRequest *request in queue.operations)
{
[request setDelegate: nil];
[request setDidFinishSelector: nil];
}
I think jv42 is correct about the cause. However, there's a handy helper for cleaning up delegates...
-(void)dealloc {
for (ASIHTTPRequest *request in queue.operations) {
[request clearDelegatesAndCancel];
}
[queue release];
[super dealloc];
}
Has anyone found a quicker method for this... maybe one that doesn't involve looping over the requests?
Make sure you are running a recent git version of ASIHTTPRequest - v1.7 contains a couple of race conditions that will causes crashes when cancelling requests.
I was having the same situation while running a ASINetworkQueue with multiple requests.
I removed the dealloc release for the queue, and the autorelease. I then applied Leah's excellent suggestion to loop through to nil the delegates. Then I put the queue's release in the queueRequestFinished delegate and it resolved my issue!
bulkQueue = [[ASINetworkQueue alloc] init];
[bulkQueue setQueueDidFinishSelector:#selector(queueRequestFinished:)];
-(void)queueRequestFinished:(ASINetworkQueue *)queue
{
for (ASIHTTPRequest *request in queue.operations)
{
[request setDelegate: nil];
[request setDidFinishSelector: nil];
}
}
Hope this helps someone out! :-)