nsdata

Convert Gif image to NSData

99封情书 提交于 2019-12-01 15:58:36
I have a gif image in my photo album. When I use the UIImagePickerController to select that image, I need to convert the image to NSData for storing. Earlier, I used NSData *thumbData = UIImageJPEGRepresentation(thumbnail, 0.5); but it will not work with gif images. thumbData will be nil. How can I get NSData from the gif image? How can I know that it is a gif image that needs special handing? The key here is to save the GIF file or URL download directly into a NSData instead of making it a UIImage. Bypassing UIImage will let the GIF file keep the animation. Here is some code to convert a GIF

Convert Gif image to NSData

白昼怎懂夜的黑 提交于 2019-12-01 14:35:47
问题 I have a gif image in my photo album. When I use the UIImagePickerController to select that image, I need to convert the image to NSData for storing. Earlier, I used NSData *thumbData = UIImageJPEGRepresentation(thumbnail, 0.5); but it will not work with gif images. thumbData will be nil. How can I get NSData from the gif image? How can I know that it is a gif image that needs special handing? 回答1: The key here is to save the GIF file or URL download directly into a NSData instead of making

NSData to Java String

喜你入骨 提交于 2019-12-01 13:41:26
I've been writing a Web Application recently that interacts with iPhones. The iPhone iphone will actually send information to the server in the form of a plist. So it's not uncommon to see something like... <key>RandomData</key> <data>UW31vrxbUTl07PaDRDEln3EWTLojFFmsm7YuRAscirI=</data> Now I know this data is hashed/encrypted in some fashion. When I open up the plist with an editor (Property List Editor), it shows me a more "human readable" format. For example, the data above would be converted into something like... <346df5da 3c5b5259 74ecf683 4431249f 711630ba 232c54ac 9bf2ee44 0r1c8ab2> Any

Good practices for Game Center matchData

*爱你&永不变心* 提交于 2019-12-01 10:36:02
I am new to GKTurnBasedMatch and i'm trying to figure out what are good practices for the "matchData" sent between players during turns. All the tutorials i've found mainly cover sending a string of text and I would like to send a lot more than that. It would be great if someone could pint me to a more advanced tutorial. An example of what I would like to do is a battle. The two players have their avatars and they have different details (health, attack, defence, etc), how should I send this data? The only way I see possible is to codify all the match details (a lot of them) into an

NSData on custom class?

早过忘川 提交于 2019-12-01 09:40:39
问题 I am about to look into bluetooth interaction on the iPhone. Now, i read that the only object that can be transferred is an NSData object. Now, i wanna transfer my "character" objects. The class looks something like this: @interface Character : NSObject <NSCoding> { UIImage *characterImage; int health; NSString *name; } -(void) initWithStats; -(void) addToViewController: (UIViewController *)theView; -(void) encodeWithCoder:(NSCoder *)encoder; -(void) initWithCoder:(NSCoder *)decoder; @end Now

NSData on custom class?

久未见 提交于 2019-12-01 09:34:53
I am about to look into bluetooth interaction on the iPhone. Now, i read that the only object that can be transferred is an NSData object. Now, i wanna transfer my "character" objects. The class looks something like this: @interface Character : NSObject <NSCoding> { UIImage *characterImage; int health; NSString *name; } -(void) initWithStats; -(void) addToViewController: (UIViewController *)theView; -(void) encodeWithCoder:(NSCoder *)encoder; -(void) initWithCoder:(NSCoder *)decoder; @end Now, i know that i have to conform to the NSCoding protocol and implement those 2 methods, however, i am

iOS - Download file only if modified (NSURL & NSData)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 09:18:17
I am downloading a bunch of image files from a server, and I want to ensure that they are downloaded only if they are newer. This method currently downloads the images just fine. However, I don't want to waste time or energy re-downloading images every time the user logs into the app. Instead, I want to only download any files that A) Don't exist B) Are newer on the server than on the device Here is how I am downloading the images: *The image url is saved in Core Data with the video it is associated to. The url is generated using a simple conversion method I build (generateThumbnailURL) -(void

Converting hex string to hex data

旧街凉风 提交于 2019-12-01 08:09:12
I currently have an NSString containing hex values. I need to convert this NSString object into an NSData object, without changing its contents at all. I use this code to "parse" the debug output of an NSData object (what you get in the console if you just NSLog an NSData object) back into NSData: -(NSData*) bytesFromHexString:(NSString *)aString; { NSString *theString = [[aString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] componentsJoinedByString:nil]; NSMutableData* data = [NSMutableData data]; int idx; for (idx = 0; idx+2 <= theString.length; idx

Good practices for Game Center matchData

烈酒焚心 提交于 2019-12-01 07:56:55
问题 I am new to GKTurnBasedMatch and i'm trying to figure out what are good practices for the "matchData" sent between players during turns. All the tutorials i've found mainly cover sending a string of text and I would like to send a lot more than that. It would be great if someone could pint me to a more advanced tutorial. An example of what I would like to do is a battle. The two players have their avatars and they have different details (health, attack, defence, etc), how should I send this

How To get Image URL From PHAsset? Is it possible To save Image using PHAsset URL to document Directory?

荒凉一梦 提交于 2019-12-01 07:28:58
问题 I used `NSURL *urlA = [info valueForKey:@"PHImageFileURLKey"];` but when i try to save image using URL then URL is nil. `NSData *pngData =[NSData dataWithContentsOfURL:urlA options:NSDataReadingMapped error:nil];` 回答1: asset = Here you have to pass your PHAsset . PHImageRequestOptions * imageRequestOptions = [[PHImageRequestOptions alloc] init]; [[PHImageManager defaultManager] requestImageDataForAsset:asset options:imageRequestOptions resultHandler:^(NSData *imageData, NSString *dataUTI,