NSInternalInconsistencyException with 'CGPDFDocumentRef == NULL' - iphone

I am building a Newsstand universal app. When I download a magazine issue and open it, it runs fine, but when I delete it, redownload, and open it it throws the following:
2013-04-01 22:06:07.672 Magazine[14353:707] *** Assertion failure in -[ReaderContentPage initWithURL:page:password:], /Volumes/Files/Work in progress/el-beit/Magazine/Sources/ReaderContentPage.m:471
2013-04-01 22:06:07.680 Magazine[14353:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'CGPDFDocumentRef == NULL'
*** First throw call stack:
(0x35a4788f 0x3366b259 0x35a47789 0x34e3b3a3 0x84e59 0x85ba7 0x96d47 0x976ad 0x34e6d933 0x35a1ba33 0x35a1b699 0x35a1a26f 0x3599d4a5 0x3599d36d 0x33738439 0x33175cd5 0x6cf81 0x6cf08)
terminate called throwing an exception(lldb)
I delete the file by deleting its issue:
NKLibrary *nkLib = [NKLibrary sharedLibrary];
NKIssue *issue = [nkLib issueWithName:[kBaseFeatureID stringByAppendingString:((NSNumber *)self.listOfMonths[index]).stringValue]];
NSString *name = issue.name;
[nkLib removeIssue:issue];
[nkLib addIssueWithName:name date:[self.dateFormatter dateFromString:((NSNumber *)self.listOfMonths[index]).stringValue]];
I am using Newsstand, iOS6, Xcode 4.6, MKStoreKit, and the template of this project: https://github.com/vfr/Reader
The reader seems to be trying to open the deleted file instead of the file I give to it.
Any help would be appreciated, thanks in advance.

I solved this issue by using
[[ReaderDocument alloc] initWithFilePath:file password:nil];
instead of
[ReaderDocument withDocumentFilePath:file password:nil];

I think that this post could solve your problem.
I get the same error, but from a different Workflow. If I download a file and save it to the filesystem the error appears, but if I add the same file to my AppBundle it gets displayed without any problem.
I hope that this helps, eventually you have any advice whats wrong at my case. I suggest that this is because of the same reason.

The plist file was the problem, it didn't get deleted automatically when you deleted your PDF. You have to either make sure all your PDF file names are unique, or remember to delete the plist file which is automatically generated by the Reader based on PDF file name.
E.g. /appid/Library/Application Support/yourPdfFileName.plist
Do it every time when you delete your PDF. It should solve your problem.

Related

My xcode project doesn't add me a .png image

I was trying to add new images into my xcode project in order to make my app universal, adding images for iphone. When compiling, this is the error:
2013-02-26 08:58:35.585 XXXX[2132:707] cocos2d: Couldn't add XXXX-XXX.png in CCTextureCache
2013-02-26 08:58:35.598 XXXXX[2132:707] *** Assertion failure in -[MainMenuLayer addChild:], /Users/XXXX/XXXXX/XXXXX/XXXXX/XXXX/cocos2d/CCNode.m:362
2013-02-26 08:58:35.632 XXXXXX[2132:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil'
*** First throw call stack:
(0x336c68bf 0x301ba1e5 0x336c67b9 0x30f0d3b3 0x4abef 0xf6495 0x49279 0xcbc8d 0x49279 0xca7cd 0x6413d 0x6bd6b 0x98ff9 0x9a39b 0x34dab423 0x34dab379 0x31940f93 0x36c46891 0x3368ff43 0x3369a553 0x3369a4f5 0x33699343 0x3361c4dd 0x3361c3a5 0x37d8efcd 0x3107f743 0xc90fb 0x3df8)
terminate called throwing an exception
someone knows what happens?
The file name you specified is more than likely not the same as the actual filename. You will see this error if you try adding a file that xcode cannot find. Double check the file names and make sure that you have:
added the file to your project (File->Add Files to xxxx)
The file name of the file added is exactly the same as the file you
are trying to add to MainMenulayer (It is case sensitive)
You have also included the file extension (.png) in the code used to add the png to
MainMenuLayer

How to use RegexKitLite in Xcode 4.3.1?

I'm having trouble to use RegexKitLite to match string like
NSString *encodedPoints=[apiResponse stringByMatching: #"\\\"([^\\\"]*)\\\"^[^:]*"
capture: 0];
and apiResponse is:
#"http://maps.google.com/maps?output=dragdir&saddr=20.001364,73.749283&daddr=19.991499,73.744095"
So, to do by this way i am getting following error:
__NSCFString stringByMatching:capture:]: unrecognized selector sent to instance 0x131fc0
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString
stringByMatching:capture:]: unrecognized selector sent to instance
0x131fc0'
* First throw call stack: (0x3422b8bf 0x3447b1e5 0x3422eacb 0x3422d945 0x34188680 0xb97b 0xad2f 0xaa2d 0xa617 0x34185435
0x375ef9eb 0x376b53cf 0x34185435 0x375ef9eb 0x375ef9a7 0x375ef985
0x375ef6f5 0x375f002d 0x375ee50f 0x375edf01 0x375d44ed 0x375d3d2d
0x30a06df3 0x341ff553 0x341ff4f5 0x341fe343 0x341814dd 0x341813a5
0x30a05fcd 0x37602743 0x4571 0x2838)
I have trying to find solution with googling but not getting exact solution.
Please help...
Ensure you have the correct library included into your project.
Go to your Project Navigator and selet the project.
Click on the Target and select the Build Phases tab, and open the Link Binary With Libraries.
Press the + Button, and search for libicucore.A.dylib. Add this library to your project.
Next, you will need to add the compile source, which is in Compile Sources just above Link Binary With Libraries. Once again, hit the + button and add RegexKitLite.m to the target. If you attempt to build the project at this state, you should get a lot of errors in the RegexKitLite.m file. To correct this, add the following compiler flag to the file by double clicking the RegexKitLite.m file in the Compile Sources area and then including -fno-objc-arc into the pop-up that appears. Hit done, and you will have hopefully added the library source to your project.
Just as a note, -fno-objc-arc removes the Automatic Reference Counting while compiling that source file. The errors the file gets without that compiler flag have to do with ARC, so it solves the problem.
This solved my issues when working with RegexKitLite, so hopefully it will for you.

including Kal.a (from Kal calendar) and including libidn.a (xmpp framework) causes app to crash

After trying really hard i am posting this qustion in the 2 o clock of night in my office.
The problem is :
1) i have included Kal calender (link here) in my application
2) And its really working fine before i decided to include xmpp framework(xmpp framework) in my application.
3) The Main problem is when i try to include libidn.a file and then compile the project it gives me 4 errors , and to remove these error i have to remove "Other linker flag -> -all_load".
4) Here the problem begins when i have removed -all_laod flag and compile , app compiles success fully. But i try to run my app and press calendar button to load calender it crashes with following error:
-[__NSDate cc_dateByMovingToFirstDayOfTheMonth]: unrecognized selector sent to instance 0x75b85c0 2012-06-12 01:38:47.483 BizPro[10251:11903]
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDate
cc_dateByMovingToFirstDayOfTheMonth]: unrecognized selector sent to
instance 0x75b85c0'
* First throw call stack: (0x209e022 0x22f0cd6 0x209fcbd 0x2004ed0 0x2004cb2 0x12bc3d 0x12bb91 0x13149e 0x1315f6 0x12961 0xa8d38f
0xa8d5eb 0xa9dff1 0xa9e85f 0xa9e9e1 0xbbc5c2 0xa02d21 0x209fe42
0x856679 0x860579 0x7e54f7 0x7e73f6 0x874160 0x9d4f30 0x207299e
0x2009640 0x1fd54c6 0x1fd4d84 0x1fd4c9b 0x26e67d8 0x26e688a 0x9c4626
0x2a9d 0x2a15 0x1) terminate called throwing an exception(lldb)
4) I know very well that this error is a misguide (NSDate is not causing the crash but the collision of static libraries is doing it , i think so) , because when i again add -all_load flag and remove the libidn.a file from my project , It compile and RUN successfully and calendar displays my data smoothly.
i googled a lot about it .. and got very little guidance .. relating the solution to workspaces and all that .. But i really dont know what could be the solution .. Plz help me
Thanks
cc_dateByMovingToFirstDayOfTheMonth
is an addition to NSDate that is defined in NSDateAdditions.h from the Kal Framework.
I had no end of problems and wanted more customisation of the Kal framework so I just dragged all the source code into my project.
If you still have issues with the framework then remove Kal.a and just bring in the source code :) then you can get dirty with it
If you rather keep Kal as a subproject, the way to fix this is to link the addition files.
Under
Project -> Build Settings -> Linking -> Other Linker Flags
add '-all_load'
sorry i am answering late ..
i solved the problem ..
removed kal.a file and just included src folder (all the header files required)
so that i will not collide with the other static library ...
Similar problem here. Because I'm using Parse Framework, can't add -all_load, so integrating static library will never work for me. The simplest way is to add all source files in src folder to my own project, rather than adding Kal.xcodeproj. Other steps to config "copy bundle files" or "header search path" etc are still necessary. I also need to add these lines from Kal_Prefix.pch to my own project.pch.
#import "NSDate+Convenience.h"
#define RGBCOLOR(R,G,B) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1]
#define RGBACOLOR(R,G,B,A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
#define kDarkGrayColor RGBCOLOR(51, 51, 51)
#define kGrayColor RGBCOLOR(153, 153, 153)
#define kLightGrayColor RGBCOLOR(185, 185, 185)

Need help fast -- CoreData error

need help desperately ahead of a demo in a few hours... App was working on my test device fine last night. Added some data (as I always do) this morning and now I get this error during a save operation:
Serious application error. Exception was caught during Core Data change processing:
*** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
(key: _ContentChange_OldIndexPathKey) with userInfo (null)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
(key: _ContentChange_OldIndexPathKey)'
The funny thing is that if I download my sqlite file to my Mac and feed it into the simulator, everything works just fine. The crash only occurs on the test device.
Any ideas?
I too was encountering this error. Nullifying the NSFetchedResultsController delegate does stop it from crashing, but is not a fix. The problem seems to be specifying a sort key in the NSFetchRequest which is null for some objects. Some sort call made in NSFetchedResultsController expects none null values.
This is an old post but I will give my comment anyway :)
I have experienced similar problem and deleting the cache for the NSFethedReultController solved the problem.
[NSFetchedResultsController deleteCacheWithName:<cacheName>];

Exception when running on simulator 3.2

I'm testing my app on simulator 3.1.3, it runs fine.
When it come to simulator 3.2, it crashes right from the beginning:
2010-06-24 16:35:29.208 MyTestApp[6991:207] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'
2010-06-24 16:35:29.213 MyTestApp[6991:207] Stack: (
46195275,
2520474889,
46194715,
46194554,
6387912,
6392266,
5568184,
6388086,
6386450,
6392266,
5564974,
5573454,
3555255,
3560368,
3586056,
3567777,
3599431,
52998524,
45735996,
45731912,
3559044,
3591649,
10824,
10678
)
As far as I know, I do not use the "initWithCoder" method (do not really know what this is though).
How can I know where the exception is thrown so I could have a better understanding of what is causing the problem?
ps: I have added an exception in Breakpoint: objc_exception_throw (with location libobjc.A.dylib, strangely I had to enter the location manually, I expected xcode to find it for me when I added objc_exception_throw). But still the same trace and no more information.
This page should provide some helpful info: Debugging Tips for Objective-C
Of particular interest is the console command info line *. Every one of those numbers listed by the exception log is an address on the stack. Those bottom ones in the 10,000 and below range are usually located in the app's main method, for example. The highest ranged addresses tend to represent the default libraries.
Using the command info line *10678 would likely return some info about a specific line in the main method, which doesn't help very much. Normally the trick is to find the highest address before the default libraries begin. I'm unsure how much this will help your problem in particular, seeing as there's a huge gap between the expected small addresses and the next highest up. In any case, start with the smallest address above the bottom two (3555255 from what I can see in the log you posted) and see if it returns a line from one of your own code files. If it does, check the one above it, and so on until you find the last address from your own code. Hope this helps.
I figured out the reason of this error. I had created an object of type NSDictionnary within IB and it seems it was not the correct way to do this. Instead I have programmatically created this same object in XCode and this works fine. Seems like it was some kind of persistent problem.