i have got a crash report for my app from apple it talks about crash due to some nspathstore2 leak, now i am finding it difficult to find that error in the code after reading the report, here i the report
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x31071f7e objc_msgSend + 22
1 Foundation 0x35ba2210 -[NSPathStore2 stringByAppendingPathComponent:] + 84
2 Photobook 0x000131d0 0x1000 + 74192
3 Photobook 0x0001333c 0x1000 + 74556
4 Photobook 0x000138a2 0x1000 + 75938
5 Photobook 0x0001200c 0x1000 + 69644
6 Photobook 0x000113ac 0x1000 + 66476
7 UIKit 0x36fc30b6 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 142
8 CoreFoundation 0x36ca51f4 -[NSObject performSelector:withObject:] + 36
9 QuartzCore 0x36481a9e -[CALayer layoutSublayers] + 210
10 QuartzCore 0x364816b6 CA::Layer::layout_if_needed(CA::Transaction*) + 210
11 QuartzCore 0x3648583c CA::Context::commit_transaction(CA::Transaction*) + 220
12 QuartzCore 0x36485578 CA::Transaction::commit() + 308
13 QuartzCore 0x3647d4b2 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 50
14 CoreFoundation 0x36d1ab14 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 12
15 CoreFoundation 0x36d18d50 __CFRunLoopDoObservers + 252
16 CoreFoundation 0x36d190aa __CFRunLoopRun + 754
17 CoreFoundation 0x36c9c49e CFRunLoopRunSpecific + 294
18 CoreFoundation 0x36c9c366 CFRunLoopRunInMode + 98
19 GraphicsServices 0x30d7e432 GSEventRunModal + 130
20 UIKit 0x36fede76 UIApplicationMain + 1074
21 Photobook 0x0000229c 0x1000 + 4764
22 Photobook 0x00002254 0x1000 + 4692
now i was assuming that this “1 Foundation 0x35ba2210 -[NSPathStore2 stringByAppendingPathComponent:] + 84” suugests that the crash is at line 84 somewhere in the project, so i try to find this, but there is no stringByAppendingPathComponent: used at line 84 any where in the project, so i am confused that how to find that leak in the project, can any one guide how to find this, thanx and regard. Saad
Problem:
When your application crashes with NSPathStore2 notification whether its contain any method like above it contains “length” then go my solution below its work fine for me i hope its also works for you.:)
Solution: The above error message means its have some problem with your “PATH” object variable.I explain it with you with an given example below:
Let us consider you have define the below code in your .m files any method where its need to define .Where “dbpath” is an NSString class variable that define in the .h file .Now you complete path is going to stored in “dbpath” variable as in below example descripted. Now when you are going use this “dbpath” variable in any other methods in .m file it then its get crash with the above message “-[NSPathStore2 length]:unrecognized selector sent to instance 0x80cea00” because you have not either “alloc” or “retain” the “dbpath“. So solution of this problem is please either alloc or retain the “dbpath” variable in given example below. THIS IS MY ANSWER WHEN I GOT THIS CRASH AND ITS WORK FOR ME WELL. ALL THE BEST TO YOU:)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [paths objectAtIndex:0];
dbpath = [path stringByAppendingPathComponent:@”mydb.sqlite”];