¡@

Home 

2014/10/15 ¤U¤È 10:03:54

iphone Programming Glossary: archiver

How to implement Deep copy for the Class in UIKit?

http://stackoverflow.com/questions/10188387/how-to-implement-deep-copy-for-the-class-in-uikit

a deep copy of UIImageView object you need to archive it using NSKeyedArchiver and then unarchive it with NSKeyedUnarchiver but there is a problem with this approach because UIImage does not conform to the NSCoding protocol. What you need to do.. @implementation UIImageView DeepCopy UIImageView deepCopy NSMutableData data NSMutableData alloc init NSKeyedArchiver archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject self forKey @ imageViewDeepCopy archiver.. data NSMutableData alloc init NSKeyedArchiver archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject self forKey @ imageViewDeepCopy archiver finishEncoding archiver release NSKeyedUnarchiver unarchiver NSKeyedUnarchiver..

How to serialize a UIView?

http://stackoverflow.com/questions/1169061/how-to-serialize-a-uiview

is quick example of how to do it NSData dataForView UIView view NSMutableData data NSMutableData data NSKeyedArchiver archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject view forKey @ view archiver finishEncoding.. data NSMutableData data NSKeyedArchiver archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject view forKey @ view archiver finishEncoding archiver release return id data UIView viewForData NSData data NSKeyedUnarchiver.. archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject view forKey @ view archiver finishEncoding archiver release return id data UIView viewForData NSData data NSKeyedUnarchiver unarchiver NSKeyedUnarchiver..

How to store custom objects with struct in Coredata

http://stackoverflow.com/questions/3492449/how-to-store-custom-objects-with-struct-in-coredata

method. void encodeWithCoder NSCoder encoder . But am getting this error NSKeyedArchiver encodeValueOfObjCType at this archiver cannot encode structs' What is the best practice to store this object to Coredata. Please help me. iphone objective c core.. iphone objective c core data share improve this question You can wrap the struct in a NSData ie To encode with archiver coder encodeObject NSData dataWithBytes my_struct length sizeof my_struct forKey @ my_struct and to decode with archiver.. coder encodeObject NSData dataWithBytes my_struct length sizeof my_struct forKey @ my_struct and to decode with archiver NSData data coder decodeObjectForKey @ my_struct data getBytes my_struct length sizeof my_struct share improve this answer..

Save own Class with NSCoder

http://stackoverflow.com/questions/4317164/save-own-class-with-nscoder

alloc init _tmpStore.highscorelist self.highscorelist.list NSMutableData data NSMutableData alloc init NSKeyedArchiver archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject tmpStore forKey kDataKey archiver finishEncoding.. data NSMutableData alloc init NSKeyedArchiver archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject tmpStore forKey kDataKey archiver finishEncoding data writeToFile self dataFilePath atomically YES archiver.. archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject tmpStore forKey kDataKey archiver finishEncoding data writeToFile self dataFilePath atomically YES archiver release data release @interface RSDataStore NSObject..

Application crashed while importing songs from Ipod library in Iphone for iOs 5.0

http://stackoverflow.com/questions/8077725/application-crashed-while-importing-songs-from-ipod-library-in-iphone-for-ios-5

MPMediaItemCollection mediaItemCollection NSMutableData data NSMutableData alloc init NSKeyedArchiver archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject mediaItemCollection forKey @ my_playlist.. data NSMutableData alloc init NSKeyedArchiver archiver NSKeyedArchiver alloc initForWritingWithMutableData data archiver encodeObject mediaItemCollection forKey @ my_playlist archiver finishEncoding NSArray paths NSSearchPathForDirectoriesInDomains.. alloc initForWritingWithMutableData data archiver encodeObject mediaItemCollection forKey @ my_playlist archiver finishEncoding NSArray paths NSSearchPathForDirectoriesInDomains NSDocumentDirectory NSUserDomainMask YES NSString documentsDirectory..

How to zip folders in iPhone SDK?

http://stackoverflow.com/questions/8150185/how-to-zip-folders-in-iphone-sdk

fileManager subpathsAtPath exportPath NSString archivePath docDirectory stringByAppendingString @ .zip ZipArchive archiver ZipArchive alloc init archiver CreateZipFile2 archivePath for NSString path in subpaths NSString longPath exportPath stringByAppendingPathComponent.. exportPath NSString archivePath docDirectory stringByAppendingString @ .zip ZipArchive archiver ZipArchive alloc init archiver CreateZipFile2 archivePath for NSString path in subpaths NSString longPath exportPath stringByAppendingPathComponent path.. exportPath stringByAppendingPathComponent path if fileManager fileExistsAtPath longPath isDirectory isDir isDir archiver addFileToZip longPath newname path BOOL successCompressing archiver CloseZipFile2 if successCompressing NSLog @ Success..