NSData and its mutable subclass NSMutableData provide data objects, object-oriented wrappers for byte buffers. Data objects let simply allocated buffers (that is, data with no embedded pointers) take on the behavior of Foundation Objects.
NSData creates static Data Objects, and NSMutableData creates dynamic data objects. NSData and NSMutableData are typically used for data storage and are also useful in Distributed Objects applications, where data contained in data objects can be copied or moved between applications.
The size of the data is subject to a theoretical limit of about 8 ExaBytes (in practice, the limit should not be a factor).
UIImage *IMG =[UIImage imageNamed:@ “1.jpg”]; NSLog (@ “img is %@”,img);
[ Related Article: What is Swift ]
NSData*data = UIImage JPEG Representation (img,1); NSLog(@ “ image data is %@”,data);
NSData *data2 = UIImage PNGRepresentation (img); NSLog (@ “ png Image data is %@”, data2);
[ Related Article: IOS Development Interview Questions & Answers ]
Int size = [data length]; If (size /1024>0) NSLog (@ “ image size is %d kb”, size/1024); else NSLog (@ “image size is %d Bytes , size);
UIImage *img2 = [UIImage ImageWithData : data]; NSLog(@ “the image is %@”,img2);
NSMutableData*mutData= [[NSMutableData alloc]init]; [MutData appendData : data]; NSLog (@ “the mutable data is %@”, mutData);
NSData *URL data = [NSData datawithContentsOfURL : [NSURL URLwithString:@https://www.Cnet.co.uk/i/c/blg/cat/mobiles/ios5.jpg”]]; UIImage *URLImage =[UIImage ImageWithData : URL data]; NSLog (@ “data length is %d kb ,[URL data length]1024];
self view background color=[UIColor Color with PatternImage: URLImage];
Ravindra Savaram is a Content Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.