nsdata

How would I save and retrieve a boolean into a file using NSData

I want to save a boolean into a file and also I want to know how you would retrieve it again. I mainly want to use this for when the iPhone terminates and finishes launching in their respected methods. ...

Can't initialize an NSMutableData with an NSData (which contains a png)

Hello, there is a error in my iPhone app. I use the CameraPicker to make and get a picture and then I give it to my methode sendPhoto, which will send the photo to TweetPhoto. Everything works great until I initialize an NSMutableDate with NSData. Here is the code: - (void)imagePickerController:(UIImagePickerController *)picker didFinis...

Saving song/movie file to iphone from Server (with didReceiveData?)

Hi everyone, I'm trying to download a song/movie file from server that host it, and after its download to the app --> save the file to the iphone. Here is my code: - (void)applicationDidFinishLaunching:(UIApplication *)application { [self beginDownloading]; [window addSubview:viewController.view]; [window makeKeyAndVisible]; } ...

How do I convert NSDictionary to NSData as a plist (without saving the dictionary)

Does anyone know how to convert a NSDictionary object into an NSData object as a plist without saving the dictionary first? I would like my iphone app to send an email with a plist containing my dictionary attached. I am currently using skpsmtpmessage, http://code.google.com/p/skpsmtpmessage/, to send email. Thanks in advance ...

[iPhone] release NSData in NSManagedObject

Hi, I use datamodel to store 2 objects : Video, Images. Video contain just string attributes and Images have 2 "Binary data" attributes. At the start the 2 binary data attributes was in the video object. But all videos are loading during initialization of UITableView. For 400 videos binary data represent 20 Mo, so imagine with 4000 vid...

iPhone and GZip

Now I know that xCode automaticly does the GZip decrompession for you within: NSData *data = [NSData dataWithContentsOfURL:URL]; And it does work if I point to a Gzip file on my server. But since my content is dynamic, I have a PHP script that rather then create a gzip file like so: $zp = gzopen($file, "r"); $data = gzread($zp, $fi...

How to download an .html file for local use?

I am trying to download an HTML file from the internet and store it in my app for later (offline) viewing. I use the following method to download the file but my NSLogs report that no data has been downloaded. Whats the problem here? (assume an active internet connection, assume a pre-defined path to local documents directory) urlAddres...

How to load a LOCAL .html file with a UIWebview?

I am trying to load an HTML file stored locally on the apps documents directory using the method shown below. It ain't workin. What am I doing wrong? NSLog(@"Loading Saved Copy!"); urlAddress = [[self documentsDirectory] stringByAppendingPathComponent:@"/Profile/profile.html"]; //Create a URL object. NSURL ...

Convert NSData to NSString

I am receiving a successful connection to the server and i am in my callback function: I am trying to get the name of the host and print that to my console: if(theType == kCFSocketConnectCallBack){ NSLog(@"Connection is accepted"); CFSocketNativeHandle nativeSocket = CFSocketGetNative(theSocket); uint8_t name[SO...

Remove first byte from NSMutableData

NSMutableData *requestData = (NSMutableData*)[request responseData]; returns "[{JSON_STRING}]" so I want to strip out the "[" / "]" without converting to NSString and then back to NSData. The easiest way to do this is to strip out the first and last byte. [requestData setLength:[requestData length]-1]; removes the last byte. How t...

Using NSKeyedArchiver and NSData to send UIImage over bluetooth

I was wondering if it is possible to send a UIImage over bluetooth after encoding it into a NSMutableData using NSKeyedArchiver. This is what I had in mind: NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; [archiver encodeObject:[UIImage imageN...

Separate NSData into smaller NSMutableData objects

I am unsure of how to separate a NSData object into smaller parts so that I can send it over bluetooth. I believe it is a method similar to this: - (void)getBytes:(void *)buffer range:(NSRange)range I do not know what to pass in for the buffer. Do I just pass in a NSMutableData object to hold the bytes that I pull out of the original ...

Send more than 32768 Bytes at once from one TCP-Socket to an other

Hey guys, I don't know if this question has been asked yet but imagine following situation: I have two TCP-Sockets (opened with NSSocketPort und listening with two NSFileHandle) and now I want to send some NSData between them. @try { [fileHandle writeData:data]; } @catch (NSException * e) { // Do some alert } Everything is ri...

UIImage created from CGImageRef fails with UIImagePNGRepresentation

I'm using the following code to crop and create a new UIImage out of a bigger one. I've isolated the issue to be with the function CGImageCreateWithImageInRect() which seem to not set some CGImage property the way I want. :-) The problem is that a call to function UIImagePNGRepresentation() fails returning a nil. CGImageRef origRef = [s...

NSData to UIImage

I'm trying to save a UIIMage and then retrieve it and display it. I've been successful by saving an image in the bundle, retrieving it from there and displaying. My problem comes from when I try to save an image to disk (converting it to NSData), then retrieving it. I convert the image to NSData like so... NSData* topImageData = UIImag...

How to Prevent Build Warning: " NSData may not respond to 'dataWithBase64EncodedString:' "

The following code produces this build warning: NSData may not respond to 'dataWithBase64EncodedString:' The code: NSString * message = @"string string string"; NSData *data= [NSData dataWithBase64EncodedString:(NSString *)message]; How do I fix this to remove this warning? ...

Need to convert NSData to NSArray

I am pulling down a plist from a URL using an NSURLConnection, which returns an NSData object. I would like to convert this to an NSArray. Can anyone help me? I am refactoring a method that currently does a synchronous request to the URL, using arrayWithContentsOfURL: to get the NSArray. Thanks!! ...

Encrypt nsdata in iphone and decrypt it in php

Hi All, I am new to Iphone development , I want to create an application in which I have to upload some data on php server using my Iphone application. For this I have an file on the Iphone whose content I have to upload on php server. For this I have converted the content of the file in NSData and now I want to encrypt this nsdata obje...

iPhone - encode Array of Data from CoreData Entity and store in Base64 String

I have a data model with three entities (Purchase, Items, Image) the purchase is the main with the other two as related attributes. I need to be able to send the data to a web server, and I must encode in base64, I have a couple of classes that take care of the encoding and decoding that i downloaded from the net, they are categories fo...

Why am I getting different values when reading bytes from NSData depending on what order I get the bytes in?

Ok, this is more of a 'What the hell is going on?' than an actual problem. But given my relative inexperience with C, it could alude to greater problems. Basically, I'm parsing a wav file's header and grabbing out the values. In my header file I have the class variables defined: short channels; int sampleRate; int bytesPerSecond; short...