EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000 on NSUserDefaults getValueForKey: method. - nsuserdefaults

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.

Related

Core Data : crash when merge change, due to 'objc_msgSend'

The last call objc_msgSend tells that it may be Zombie Messaged, but it's in the Core Data library code...
Exception Type: EXC_CRASH (SIGSEGV)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 1
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libobjc.A.dylib 0x37a6ef78 objc_msgSend + 16
1 CoreData 0x3601a748 -[_CDSnapshot dealloc] + 60
2 CoreData 0x3601a336 -[_CDSnapshot release] + 118
3 CoreData 0x3601a6c4 _NSQLRow_dealloc_standard + 52
4 CoreData 0x3601a67c _PFfastRowRelease + 24
5 CoreFoundation 0x35692936 __CFDictionaryReleaseValue + 26
6 CoreFoundation 0x356e6104 __CFBasicHashRemoveValue + 96
7 CoreFoundation 0x3561a7e4 CFBasicHashRemoveValue + 2900
8 CoreFoundation 0x35619c60 CFDictionaryRemoveValue + 172
9 CoreData 0x3601a62e -[NSPersistentStoreCache decrementRefCountForObjectID:] + 66
10 CoreData 0x3601a5b0 -[NSSQLCore managedObjectContextDidUnregisterObjectsWithIDs:] + 124
11 CoreData 0x3601a4f6 -[NSPersistentStoreCoordinator(_NSInternalMethods) _informAffectedStoresOfInterestByChildContextInObjectsWithObjectIDs:withSelector:] + 414
12 CoreData 0x3601af34 -[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 1800
13 CoreData 0x3606a1f6 -[NSManagedObjectContext _mergeChangesFromDidSaveDictionary:usingObjectIDs:] + 2078
14 CoreData 0x36069092 -[NSManagedObjectContext mergeChangesFromContextDidSaveNotification:] + 182
15 Messenger -[WXManagedObjectContextManager managedObjectContextDidSave:] (in Messenger) (WXManagedObjectContextManager.m:106)
16 CoreFoundation 0x3562c1f4 -[NSObject performSelector:withObject:] + 36
17 Foundation 0x351f0740 __NSThreadPerformPerform + 344
18 CoreFoundation 0x356a1acc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 8
19 CoreFoundation 0x356a1298 __CFRunLoopDoSources0 + 208
20 CoreFoundation 0x356a003e __CFRunLoopRun + 646
21 CoreFoundation 0x3562349e CFRunLoopRunSpecific + 294
22 CoreFoundation 0x35623366 CFRunLoopRunInMode + 98
23 GraphicsServices 0x372bf432 GSEventRunModal + 130
24 UIKit 0x3312fcce UIApplicationMain + 1074
25 Messenger 0x000034fc 0x1000 + 9468
26 Messenger 0x00003468 0x1000 + 9320
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x35f733a8 kevent + 24
1 libdispatch.dylib 0x3455df04 _dispatch_mgr_invoke + 708
2 libdispatch.dylib 0x3455dc22 _dispatch_mgr_thread + 30
May be its problem from begin so use any option from bellow ways..
set exception breakpoint in your application and for that follow this link ios-5-xcode-backtrace.
OR
2.Try to run the application with NSZombieEnabled from this link how-to-enable-nszombie-in-xcode also

iOS App Crash on startup

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.

How could this line possibly lead to a crash?

Trouble code:
NSDictionary *contactNameDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:item, #"contact", sortName, #"contactSortName", compositeName, #"compositeName", nil];
Error:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x00004420 objc_msgSend + 24
1 CoreFoundation 0x000042a6 CFRetain + 54
2 CoreFoundation 0x0000a9f0 __CFBasicHashStandardRetainValue + 8
3 CoreFoundation 0x000054c0 __CFBasicHashAddValue + 100
4 CoreFoundation 0x00006184 CFBasicHashAddValue + 276
5 CoreFoundation 0x00006cfe CFDictionaryCreate + 58
6 CoreFoundation 0x00033d7c -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 1456
7 CoreFoundation 0x000361bc -[NSDictionary initWithObjectsAndKeys:] + 776
8 iota 0x0000cb04 -[CorpDirViewController reloadDisplayList] (CorpDirViewController.m:833)
Perhaps one (or more) of item, sortName or compositeName have gone out of scope and been garbage collected, even though they're non-nil.
item, sortName or compositeName is nil

Application Crashing due to EXC_BAD_ACCESS

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x00004420 objc_msgSend + 24
1 CoreFoundation 0x000042a6 CFRetain + 54
2 CoreFoundation 0x0000a9f0 __CFBasicHashStandardRetainValue + 8
3 CoreFoundation 0x000054c0 __CFBasicHashAddValue + 100
4 CoreFoundation 0x00006184 CFBasicHashAddValue + 276
5 CoreFoundation 0x00006cfe CFDictionaryCreate + 58
6 CoreFoundation 0x00033d7c -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 1456
7 CoreFoundation 0x000361bc -[NSDictionary initWithObjectsAndKeys:] + 776
8 iota 0x0000c4cc 0x1000 + 46284
9 iota 0x00009282 0x1000 + 33410
10 iota 0x0000952a 0x1000 + 34090
11 Foundation 0x00015432 _nsnote_callback + 150
12 CoreFoundation 0x000271da __CFXNotificationPost_old + 390
13 CoreFoundation 0x00026e7a _CFXNotificationPostNotification + 122
14 Foundation 0x0000b9f6 -[NSNotificationCenter postNotification:] + 138
15 Foundation 0x0007ae02 postQueueNotifications + 258
16 Foundation 0x0007afae __NSPostIdleQueueNotes + 6
17 CoreFoundation 0x00031084 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 12
18 CoreFoundation 0x00030eb2 __CFRunLoopDoObservers + 494
19 CoreFoundation 0x00028206 __CFRunLoopRun + 934
20 CoreFoundation 0x00027d74 CFRunLoopRunSpecific + 220
21 CoreFoundation 0x00027c82 CFRunLoopRunInMode + 54
22 GraphicsServices 0x00004e84 GSEventRunModal + 188
23 UIKit 0x00004f8c -[UIApplication _run] + 564
24 UIKit 0x000024cc UIApplicationMain + 964
25 iota 0x0000533a 0x1000 + 17210
26 iota 0x000052fc 0x1000 + 17148
NSDictionary *contactNameDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:item, #"contact", sortName, #"contactSortName", compositeName, #"compositeName", nil];
The crashes are random. Like it happens once in 15 trials of a particular action.
KERN_PROTECTION_FAILURE - means that your program is accessing a shared memory that it didn't have access to. That's why kenel sent killed your process. I'm pretty sure that some of your pointers point to wrong location. E.g.
NSObject* obj;
obj would have garbage as it's value. You have to declare it like this:
NSObject* obj = nil;
Without more info, it's hard to say. Usually it's because you try to access/insert into your dictionary an object that doesn't exist anymore.
Check if you're not inserting something that is not an instance of NSObject, like an int or something.
Given that you are using initWithObjectsAndKeys:, make sure that you have nil-terminated the list of arguments, as that's a common mistake that can lead to crashes.

StoreKit SKProductsRequest Crash

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
}
}