Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

naphatkrit

macrumors member
Original poster
Jul 18, 2011
38
0
Hi,
I'm trying to archive an array of custom class objects. The array is found by calling the method "getArticles" from another class "parser." This is my code for archiving:

Code:
NSMutableData *data = [[NSMutableData alloc] init];
        NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
        [archiver encodeObject:[parser getArticles] forKey:@"Articles"];
        [archiver finishEncoding];
        [data writeToFile:[self articlesCachePath] atomically:YES];

It archives without a problem. However, when I try to unarchive it, I run into an EXC_BAD_ACCESS error. This is my code for unarchiving:

Code:
NSData *loadedData = [[NSData alloc] initWithContentsOfFile:[self articlesCachePath]];
        NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:loadedData];
        articlesArray = [unarchiver decodeObjectForKey:@"Articles"];
        [unarchiver finishDecoding];

"articlesArray" is an empty mutable array. This is the log:

Code:
Current language:  auto; currently objective-c
Canceling call as the ObjC runtime would deadlock.
Issue the command:
    set objc-non-blocking-mode off 
to override this check if you are sure your call doesn't use the ObjC runtime.
(gdb)

Does anyone know what's going on? I'm running Xcode 4.2.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.