Tag: nsdata

Encrypted NSData to NSString in obj-c?

I have an iPhone app which encrypts an inputted NSString using CCCrypt (AES256) and a plaintext key. The string and key are given to the encryption method which returns an NSData object. Requesting [data description] where ‘data’ is the encrypted string data gives an NSString like: “<0b368353 a707e7de 3eee5992 ee69827e e3603dc2 b0dbbc0b 861ca87d f39ce72a>” but […]

How do I convert an NSString value to NSData?

How do I convert an NSString value to NSData?

Convert NSData to byte array

I want to convert the NSData into byte array and given below is the code that i have used NSData *imageData = UIImagePNGRepresentation(recipeImage.image); NSUInteger len = [imageData length]; Byte *byteData = (Byte*)malloc(len); memcpy(byteData, [imageData bytes], len); NSLog(@”%8s”,byteData); But its giving me an error when i post the byteData to the webservice which is given below […]

Get NSData for video file with NSUrl

I have file at path var/mobile/Media/DCIM/100APPLE/IMG_0292.MOV and I want to get NSData of this file but I got error Error Domain=NSCocoaErrorDomain Code=257 “The file “IMG_0292.MOV” couldn’t be opened because you don’t have permission to view it.” UserInfo={NSFilePath=/var/mobile/Media/DCIM/100APPLE/IMG_0292.MOV, NSUnderlyingError=0x178c9f90 {Error Domain=NSPOSIXErrorDomain Code=1 “Operation not permitted”}} I tried with NSError *error; NSData *videoData = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedAlways […]

How to get the size of a UIImage in KB?

Is there a way to get the filesize in KB from a UIImage, without getting that image from didFinishPickingMediaWithInfo? The images that are presented are coming from the photo album. I tried the following code, but this gives the following result: size of image in KB: 0.000000 – (void)setImage:(UIImage *)image { _image = image; self.imageView.image […]

How do I convert HTML NSData to an NSString?

I’m using [NSData dataWithContentsOfURL:] to create two NSData instances and I want to compare these instances to gauge how different they are. Since they’re both from the same website, using a string to find what is different will help me highlight the actual element(s) that has (have) changed. Is it possible to change this data […]

How can i convert a NSData to NSArray?

Possible Duplicates: How to convert NSArray to NSData? Need to convert NSData to NSArray HI, I have a NSData object named as “myNsData”(it is converted form of NSArray) and a NSarray named as “myNsArray. can any one provide me a code to convert a NSData to NSArray?

NSData on custom class?

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) […]

NSMutableArray Data Attachement With E-mail Body?

My NSMutableArray data are in NSData formate.I am trying to attached NSMutableArray data to E-mail body.Here is my NSMutableArray code: NSUserDefaults *defaults1 = [NSUserDefaults standardUserDefaults]; NSString *msg1 = [defaults1 objectForKey:@”key5″]; NSData *colorData = [defaults1 objectForKey:@”key6″]; UIColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData]; NSData *colorData1 = [defaults1 objectForKey:@”key7″]; UIColor *color1 = [NSKeyedUnarchiver unarchiveObjectWithData:colorData1]; NSData *colorData2 = [defaults1 objectForKey:@”key8″]; […]

NSData & NSURL – url with space having problem

I have following code in my application. NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:pathOfThumbNail]]; pathOfThumbNail has following path http://70.84.58.40/projects/igolf/TipThumb/GOLF 58B.jpg When I open above path in safari browser – path is changed automatically & image is successfully displayed. http://img.ioscake.com/iphone/GOLF 58B.jpg But in iPhone, due to space in path, image isn’t loaded in nsdata.