user174761
user174761

Reputation: 1829

Reading data from file and put into NSString

NSData *finaldata2 =[NSData dataWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"DefaultProfilePhoto.jpg"]];

now when i convert this NSData to NSString at that time i'm getting value null. How to resolve this problem

I need data of my png file into 1 NSString

Upvotes: 0

Views: 253

Answers (1)

Alex Reynolds
Alex Reynolds

Reputation: 96927

Every subclass of NSObject has a -description method, including NSData:

NSString *finaldata2String = [finaldata2 description];

For NSData this will create an NSString representation of the data, making a string of bytes in hexadecimal format.

Upvotes: 1

Related Questions