Assuming you are trying to write to file using writeToFile:atomically:
NSCoding creates a serialised archive which cannot be used with writeToFile:atomically:
. You need to use NSKeyedArchiver like following:
[NSKeyedArchiver archiveRootObject:levelObject toFile:@"path/level-object.txt"];