Reputation: 5438
I use url connection (http).
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSString *filePath; /* .../link.plist */
[data writeToFile:filePath atomically:YES];
}
After connection, I check result file (link.plist)
- (void)checkLinkResult {
NSString *filePath; //link.plist
NSString *result = [[NSString alloc] initWithContentsOfFile:filePath];
}
It works fine.
But I want to check Result String, directly, without making file.
"NSData -> file -> NSString" (now) ====> "NSData -> NSString" (i want)
Help me plz.
Upvotes: 0
Views: 2503
Reputation: 771
Follow the following steps:
Upvotes: 0
Reputation: 150
It's dependent your data.
If your data is Image
UIIMage * image = [[UIImage alloc] initWithData:Receivedata
If data is string
NSMutableString *string = [[NSMutableString alloc] initwithData:Receivedata encoding:nil]
Upvotes: 1
Reputation: 2907
In didReceiveData write to an NSMutableData object, then in checkLinkResult create a string from the NSMUtableData using the appropriate encoding.
It's actually how it's done in the apple NSConnection tutorial.
Upvotes: 0