nsdata

Convert hex data string to NSData in Objective C (cocoa)

Hi, fairly new iPhone developer here. Building an app to send RS232 commands to a device expecting them over a TCP/IP socket connection. I've got the comms part down, and can send ASCII commands fine. It's the hex code commands I'm having trouble with. So lets say I have the following hex data to send (in this format): \x1C\x02d\x00\x...

Error saving NSImage as NSData

Hi there. I am using the following code to save a frame of a movie to my desktop: NSCIImageRep *imageRep = [NSCIImageRep imageRepWithCIImage:[CIImage imageWithCVImageBuffer:imageBuffer]]; NSImage *image = [[[NSImage alloc] initWithSize:[imageRep size]] autorelease]; [image addRepresentation:imageRep]; CVBufferRelease(imageBuffer); NSAr...

NSMutableData remove bytes?

I can add bytes to a NSMutableData instance easially by using the AddData method, however I do not see any similar method for removing data? Am I overlooking something, or do I need to create a new object and copy over only the bytes I need? ...

Get NSString/NSData object from hardcoded bytes saved as NSString object in webservice response

Hey all, I am working with the iPhone SDK and I have to process a webservice response I receive from an external service. The response data consists of an XML string that was UTF8-encoded to a byte array. This byte array is converted to string This string is put into a XML wrapper element The wrapper is returned via an HTTP response ...

iPhone: How to Write an Image to Disk in the App Directories

I am working on an iPhone project in which I need save camera images to disk and file but the code below fails: (**** -(void)imagePickerController:(UIImagePickerController *) picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; imageView.image = [info objectForKey:@"UIImagePicker...

Storing GIF's in SQLlite on iphone

Hi, I am looking for some advice on the best strategy for getting / putting GIF files in an SQLlite Database and how to initialize the ImageView. I have images stored on URLs that can be downloaded but I'm not sure the best method to get them stored into the SQlite database. should it be NSURLRequest - NSData - BLOB then retrieve ...

how can I translate a NSString to NSData? And the data has the same content as the string

NSString * theString=@"e88d"; NSData * data; // something I should implement NSLog(@"%@", theString); NSLog(@"%@",[data description]); I want the results of the two printings are the same. AES encryption and decryption: (1).The server: if the plaintext is :@"abcd"; the AES encrypted data(NSData data type) is :"d882830c dc892...

C-array to NSData and back

I'm attempting to save a c-style array of Vertex3D structs to an NSData object and get them back when reloading the app: NSData *vert = [NSData dataWithBytes:&vertices length:(sizeof(Vertex3D) * NUM_OF_VERTICES)]; This data is then saved and attempted to be read back into my c-array thusly: vertices = malloc(sizeof(Vertex3D) * NU...

NSData is being truncated when stored in sqlite database.

I am attempting to store NSMutableDictionaries as a blobs in sqlite, by first converting it into NSData via either NSPropertyListSerialization or NSKeyedArchiver. When I store the blob, the NSData object's length is in the thousands (KB range). When I get it back, it's been truncated to 10 bytes. When I check the DB through SQLite Brow...

Writing photos (and other things) to disk and getting them later in iphone

I'm trying to write an image to disk: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; NSString* savePath = [documentsPath stringByAppendingPathComponent:@"photo"]; BOOL result = [data writeToFile:savePath atomically:YES];...

Converting NSData to an NSString representation is failing

Hi there. I have an NSData object which I am trying to turn into an NSString using the following line of code: NSString *theData = [[NSString alloc] initWithData:photo encoding:NSASCIIStringEncoding]; Unfortunately I am getting the following result, instead of my desired binary output (can I expect a binary output here?); ÿØÿà I'd...

Elegant Algorithm for Parsing Data Stream Into Record

I am interfacing with a hardware device that streams data to my app over Wifi. The data is streaming in just fine. The data contains a character header (DATA:) that indicates a new record has begun. The issues is that the data I receive doesn't necessarily fall on the header boundary, so I have to capture the data until what I've capture...

Getting info from NSData object

How would I get returningResponse (into say, a NSString) from the following code: NSURLResponse* response; NSError* error; NSData* result = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error]; I think I can get the info that I need into a string but I can't call anything on response because it'...

Convert nsdata to nsstring

Hi, I have utf8 encoded nsdata from windows server. I want to convert it to nsstring for iphone. Since data contains characters(like degree symbol) which have different values on both platforms, how do I convert data to string. ...

iPhone: How to Embed NSData in XML for Upload to Server?

Hello, I want to pass data to a server and store the file there in a database as binary data. NSData *myData = [NSData dataWithContentsOfFile:pathDoc]; pathDoc = [NSString stringWithFormat:@"<size>%d</size><type>%d</type><cdate>%@</cdate><file>%c</file><fname>File</fname>",fileSizeVal,filetype,creationDate,myData]; Any idea abou...

NSData WriteToFile not synchronous

I'm trying to write data to the documents folder on the device. I'm getting the data from a subview that gets released the the file is written. The problem is that the view gets released before the file is written. I'm hoping that i'm doing something wrong in the code but i can't see it. (void)alertView:(UIAlertView *)alertView didDis...

Data loss when downloading data from LDAP server

Hi there. This question comes from a previous one I asked about handling NSData objects: http://stackoverflow.com/questions/2453785/converting-nsdata-to-an-nsstring-representation-is-failing. I have reached the point where I am taking an NSImage, turning it into NSData and uploading those data bytes to the LDAP server. I am doing this l...

NSSet to NSData, then back out again, for GameKit?

Hi guys, I'm trying to do some image edit syncing between two of the same app running on different iPhones. I would like to send an NSSet * from one device to another (which I imagine involves encapsulating in NSData) then decrypting this back to an NSSet, then using it in a touchesMoved type of function. Is this feasible, or should I w...

How to retrieve data from server and save into a file in [Objective-C] iPhone programming?

I've saved the contents of server into a NSData. How do I copy the contents of NSData into a file. ...

NSMutableUrlRequest eats plus signs

I create NSMutableUrlRequest for sending data to server, add all necessary fields to it and then add the string for sending like this: [theRequest setHTTPBody:[postString dataUsingEncoding: NSUTF8StringEncoding]]; postString is a usual NSString. The problem is, when I receive this request at the server, all the plus (+) signs disappe...