nsdata

how to convert NSArray to NSData...or something...

I am rather embarrassed to ask this, but I am on a time limit. basically, i need to get an array which can hold integers and then those integers can be used to plot a point on an image. I am trying to make a program where random objects travel down the screen following certain paths, but at random. So far this is my code: enemyPaths ...

convert an hex string to a NSData

How can I convert a string in hex format to retrieve from it an NSData and after that an UIImage inside of my iPhone app? I've got a string (str) that contains a value like X'FFD8FFE000104A46....01010000010001000'. That string is created from a xml file by the method: - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)st...

Receiving complete message from TCP socket

Hi, I read data from a TCP socket connection, but the server sends me \0 from time to time (which would mark the end of a message). Thus, I do not get the rest of the message. I read like this: uint8_t buf[tcpBufferSize]; unsigned int len = 0; len = [inputStream read:buf maxLength:tcpBufferSize]; if(len > 0) { NSMutableData* dat...

iPhone SDK: Converting/uploading an image to a SOAP service

I'm having issues converting/uploading a camera image to a remote SOAP web service. Here's the code for converting the image to a byte array: UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; if (image == nil) image = [info objectForKey:UIImagePickerControllerOriginalImage]; NSData *imageData = [NSDa...

Help with memory problem on iOS/iPad

Hello - In my app, I have a bunch of different image packs to download. The images are downloaded from my website one by one. The packs contain anywhere from 100-1500 images and each image is about 100KB-200KB. When downloading the images, I have a method that selects the images to download, then I have a second method that does the act...

NSKeyedArchiver archivedDataWithRootObject:

Is the parameter for NSKeyedArchiver archivedDataWithRootObject: supposed to be the array I am trying to save, or the array converted into NSData? ...

NSData to Java String

Hello all, 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/encryp...

ALAssetRepresentation as NSData for GIFs

I'm try to allow users to pull images out of their Photos collections using ALAssetsLibrary. Users can then upload these images. My goal is to allow users to upload any GIFs they may have in their library w/o loosing any animation they may have. For PNG and JPEG files I can grab the ALAssetRepresentation, use - (CGImageRef)fullResolut...

How do I validate that an NSData is a PDF?

In working on a feed-reading iPhone app which displays nsdata's (html and pdf) in a UIWebView. I am hitting a snag in some PDF validation logic. I have an NSData object which I know contains a file with .pdf extension. I would like to restrict invalid PDFs from getting any further. Here's my first attempt at validation code, which see...

is it possible to save NSMutableArray or NSDictionary data as file in iOS ?

i want to save NSMutableArray or NSDictionary to save as file and close application. then reopen application and read some data from that file to use. is it possible? ...

NSData dataWithBytesNoCopy from NSInputStream

I'm working on transcoding image data from a file to a base64 encoded string and then back to bytes as the file is read using NSStream. I think I'm almost there, but I keep running into EXC_BAD_ACCESS at various points during the conversion. I'm fairly new to the world of NSStream and buffers so feel free to let me know if I'm taking th...

how convert NSDictionary element to NSData (dataUsingEncoding cause crash)

Hi all, i try to convert NSDictionary element to a NSData element: ... while ((key = [enumerator nextObject])) { NSString *temp = [dictionary objectForKey:key]; if ([key isEqualToString:@"results"]) { //Crash HERE! -------------------------->>>> NSData *myData2 = [temp dataUsingE...

Base64 Encode File Using NSData Chunks

Update 4 Per Greg's suggestion I've created one pair of image/text that shows the output from a 37k image to base64 encoded, using 100k chunks. Since the file is only 37k it's safe to say the loop only iterated once, so nothing was appended. The other pair shows the output from the same 37k image to base64 encoded, using 10k chunks. Sinc...

NSData not working correctly

NSData *myRequest = [NSString stringWithFormat:(@"&site=%@&key=%@",tmpSite,tmpKey)]; Why is this not working ? Thanks ...

Object changes from NSMutableArray to NSData to NSString

I have a program which works normally. Then I downloaded some code from http://github.com/matej/MBProgressHUD to show a progress meter when doing something. This is the code that makes the progress meter pop up. [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; This will show a progress meter while...

convert .zip file into NSData

Hey, Is it correct to initialize an NSData with a zip file? I want to convert a zip file into NSData and construct another file with the data (in simple language 'copy it'). I have the code as: NSURL *theFileUrl = [NSURL URLWithString: @"file://localhost/Users/xxx/Desktop/testZippedFile.zip"]; NSData *data = [NSData dataWithContentsOfU...

Iphone Allocation with NSData

Hi - I have a method that downloads many images from the internet, then saves them to the device. Here is the code: -(IBAction) updateImages { for (x=0; x<[imagesToUpdate count]; x=x+1) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; NSMutableDictionary *tempDic = [dic objectForKey:[imagesToUpdate objectAtIndex:...

How to initialize an NSData in order to store MAX_SIZE_BUFFER bytes ?

Hi, I have just realized I lost 30 minutes searching in Xcode NSData Class reference how to do this in objc (sorry I explain this in C as this in the only language which comes without thinking too much): #define MAX_SIZE_BUFFER 500 byte *ptr; ptr = malloc(MAX_SIZE_BUFFER * sizeof(byte)); memset(ptr, 0, MAX_SIZE_BUFFER); I started to ...

reading binary data (rtf) to string

Hello, I've been working on a core data program for a while now. I'm trying to combine attributes of an entity in a text view for saving to PDF and Printing. One of the attributes of the entity uses binary data. When I execute this: NSData *myData = [object valueForKey:@"cueNotes"]; ...it returns this: typedstreamè@ NSMutabl...

Convert NSData to NSString and ignore null bytes?

I need to convert a NSData object to an NSString. It is meant to be gibberish but I need it for debbuging. When I use NSString's initWithData, it breaks as the data has NULL bytes. How can I make it ignore the null bytes and get a proper string? ...