nsdata

Combining Audio Files as One Properly on iPhone with NSData

I am using AVAudioRecorder to save an audio file every 15 seconds by stopping the recording appending that data to the previously recorder file using a NSMutableData object and using the appendData method. I then record again in the same method so the recording is "continuous". The problem is as soon as you do [recorder stop] it saves...

iphone sdk see size of local file (one created by application)

Is there anyway I can look at the size of a file the application creates in bytes then store that number to use later? OR is there any way I can tell if an object in an NSArray is empty, I've tried everything, but it just doesn't work! ...

Creating files in Objective-C

Hi all, Which is the faster way of creating files ? Case 1: ====== NSData *data = [Some data]; [data writeToFile:filePath atomically:YES]; Case 2: ======= NSFileManager *fileManager = [NSFileManager defaultManager]; [fileManager createFileAtPath:filePath contents:data attributes:nil]; Thanks Biranchi ...

Unzip NSData without temporary file

Hello, I've found a couple of libs (LiteZip and ZipArchive) that allow to unzip files on iPhone. But both of them require an input as a file. Is there a library that allows to directly unzip NSData containing zip-archived data without writing it to temporary file? I've tried to adopt mentioned above libs for that, but with no success s...

Can't free memory of NSData object

Hi, i'm new to xcode / cocoa and even objective-c thus my question might be stupid. Im trying to write a program that will hash files in a folder. I looked around and found a way to load a file via a NSData object and than hash it's bytes with CC_SHA512. If i try to hash a few more files i noticed my memory running out. Using the Run -...

How to archive and unarchive images in iphone

I am coding an iphone application where images are transferred from one iphone to another using bluetooth. can anyone tell me how to archive an image and send it to another iphone Then unarchive the image back . Archiving the image directly using NSKeyedarchiver doesnt work. Can anyone post sample code ...

Convert NSData [UIImage] to a NSString

Hi, I am aware this question has been asked several times, but I was unable to find a definate answer that would best fit my situation. I want the ability to have the user select an image from the library, and then that image is converted to an NSData type. I then have a requirement to call a .NET C# webservice via a HTTP get so ideally...

iPhone - dataWithContentsOfURL: does not work for some URLs

Hi I am using NSData to get content from a URL (RSS feed) and then parse it. While most of the URLs are loaded fine, some of them don't return any data. These URLs open on the web so I know they are valid, but they just don't return any NSData. One such URL - feed://jpl.nasa.gov/multimedia/rss/rovers.xml Here's how I am using it (the ...

NSData writeToFile gives a "may not respond to" message on iPhone SDK

I have a problem with an NSData object -writeToFile: method, and the same with the NSString object as well. When I compile to software, it gives the NSData (or NSString) may not respond to -writeToFile: message. When I run the software it reaches this line and make an exception. The data, I try to write into a file, is containing an A...

Find Character String In Binary Data

I have a binary file I've loaded using an NSData object. Is there a way to locate a sequence of characters, 'abcd' for example, within that binary data and return the offset without converting the entire file to a string? Seems like it should be a simple answer, but I'm not sure how to do it. Any ideas? Thanks. UPDATE: I'm doing this o...

How do we clear out contents in NSMutatableData

how do were clear an NSMutatableData wihtout using release and then re-alloc/init again to be used again? I was looking at resetBytesInRange to be set at zero but I am unsure of this. Anyone can help? ...

How to get image data from a WebView into an NSData object?

I have a Cocoa app that embeds a WebView. The WebView loads html elements including images. I have the textual links for the images (e.g. "http://www.domain.com/path/image.jpg"), but what I want is the image data itself so I can put it in an NSData object and ship it off to Growl. The WebView must have this data since it has downloaded a...

char * to NSData to display in UIImageView

I am getting image data in form of char * (stored on sql server). I want to convert those data to NSData to display image in UIImage view. char * data is a bytearray for source image. how can i convert char * to NSData to display to get an UIImage instance for displaying in UIImageView? Thanks.. ...

iPhone pushNotification DeviceToken - How to "decrypt"

I've already managed to get the devicetoken from APNs. It's type of NSData. So i want to write this deviectoken into my mysql db. I've already tried to convert it to a string without luck. That was my way: NSString *tokenTMP = [[NSString alloc] initWithData:devToken encoding:NSASCIIStringEncoding]; If i have the deviceToken in a rea...

What Am I Missing? : iPhone Objective-C NSInputStream initWithData

I'm creating an NSInputStream from an NSData object but once created the stream reports NO for hasBytesAvailable: NSData* data = [outputStream propertyForKey: NSStreamDataWrittenToMemoryStreamKey]; NSLog(@"creating stream with data 0x%x length %d", [data bytes], [data length]); NSInputStream *insrm = [[NSInputStream alloc] initWithDat...

iPhone NSURLConnection: What to do with returned NSData Object? Google Docs API

I'm working with the Google Docs API in my iPhone application. I've sent the proper POST request, and received a response along with some NSData. If I NSLog the NSData object, I get this: NSData *returnedData = [NSURLConnection sendSynchronousRequest:request returningResponse:theResponse error:NULL]; NSLog(@"%@",returnedData); //outpu...

NSData datawithcontentsOfURL not working in my project

While I m trying to get data from the URL it returns nil. But the same line works in other projects. I have tested it with by creating new project. My code is here NSData *imgData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://image.projectnext.eu/RBXF_Icon.jpg"]]; it gets data perfectly in my test project but not working ...

How can I derive an address and port from -[NSNetService addresses] so I can use it with NSURL

I'd like to use CocoaHTTPServer to set up peer-to-peer communication between different instances of an application on a network. Setting up the server was quite easy, but writing the client is another story. I have the server broadcasting over Bonjour. My client is able to find and resolve the service, but I'm stuck when it comes to get...

How do I download contents into an NSData using a Secure URL?

I'm starting with the following snip to download an image NSError *error = nil; NSString *url = @"https://..."; [NSData dataWithContentsOfURL:[NSURL urlWithString:url] options:nil error:&error]; When this code runs, the error instance contains an error without a whole lot of information in the userInfo. It's just the secure url that ...

Sending NSDictionary between phones

I have an application where a user creates settings that are stored in an NSMutableDictionary. I have to send this to a server, where it can be later retrieved by a recipient. I can serialize the dictionary, and send it to the server. My question is, if I send it as NSData, store it in a blob field in my postgresql db, and then send it...