nsdata

PHPhotoLibrary save a gif data

☆樱花仙子☆ 提交于 2019-12-30 07:19:30
问题 I can't find a similar method to ALAssetsLibrary->writeImageDataToSavedPhotosAlbum in the new PHPhotoLibrary since ALAssetsLibrary deprecated in iOS 9 I can't save GIF probably I'm using this code [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ PHAssetChangeRequest *assetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:[UIImage imageWithData:gifdata]]; placeholder = [assetRequest placeholderForCreatedAsset]; photosAsset = [PHAsset fetchAssetsInAssetCollection:collection

Show NSData as binary in a NSString

风流意气都作罢 提交于 2019-12-30 06:46:43
问题 I have a binary file (file.bin) in the resources folder, I want to read it and show it as binary. The idea its to put the binary information into a array, but, at first, I'm trying to show it in a UILabel, like that: ` NSData *databuffer; NSString *stringdata; NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"bin"]; NSData *myData = [NSData dataWithContentsOfFile:filePath]; if (myData) { stringdata = [NSString stringWithFormat:@"%@",[myData description]]; labelfile

Parsing JSON response .

我是研究僧i 提交于 2019-12-29 02:11:06
问题 - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { response=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];} Here, I get the response in the "response value" --> [{"response":true,"danger":false}] The thing is: How can I rescue the "danger"(true/false) into a new variable to use it in other methods? I need to know if "danger" is true or false becouse if its true, i have to show an alert. I would really appreciate someone help, as I am stuck in

Convert hex data string to NSData in Objective C (cocoa)

前提是你 提交于 2019-12-28 04:14:07
问题 fairly new iPhone developer here. Building an app to send RS232 commands to a device expecting them over a TCP/IP socket connection. I've got the comms part down, and can send ASCII commands fine. It's the hex code commands I'm having trouble with. So lets say I have the following hex data to send (in this format): \x1C\x02d\x00\x00\x00\xFF\x7F How do I convert this into an NSData object, which my send method expects? Obviously this does not work for this hex data (but does for standard ascii

Convert NSData of Image from database to NSString in iPhone

☆樱花仙子☆ 提交于 2019-12-25 18:18:12
问题 I am converting NSData of Image from database to NSString in Iphone Here is my code imageData1 = [[NSData alloc] initWithBytes:sqlite3_column_blob(compiledStatement, 3) length: sqlite3_column_bytes(compiledStatement, 3)]; NSString * Str1 = [NSString base64StringFromData: imageData1 length: [imageData1 length]]; NSData *data1=[NSData base64DataFromString:Str1]; NSString* newStr1 = [[NSString alloc] initWithData:data1 encoding:NSUTF8StringEncoding]; the length of data is 6511 , but the newstr1

Arbitrary precision bit manipulation (Objective C)

和自甴很熟 提交于 2019-12-25 18:12:40
问题 I need to do bit operations on representations of arbitrary precision numbers in Objective C. So far I have been using NSData objects to hold the numbers - is there a way to bit shift the content of those? If not, is there a different way to achieve this? 回答1: Using NSMutableData you can fetch the byte in a char , shift your bits and replace it with -replaceBytesInRange:withBytes: . I don't see any other solution except for writing your own date holder class using a char * buffer to hold the

DidRecieveMemoryWarning called after viewDidAppear when displaying large image file

这一生的挚爱 提交于 2019-12-25 16:56:01
问题 My app has terminated due to memory pressure when I load a particular page. I am using an NSURLRequest to get data and load an image. I placed breakpoints throughout my code and traced the first didRecieveMemoryWarning call to right after viewDidAppear. Here is the code I am using to load the image: NSError *error = nil; NSURLResponse *response = nil; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.img]]; NSData *data = [NSURLConnection sendSynchronousRequest

swift : get the closest date stored in the core data

跟風遠走 提交于 2019-12-25 14:32:09
问题 I have two data in core data. Entity Name = "Contact", Attribute Name = "date"(selected datePicker.date), "content"(textFeild.text) It is that sort of information in a table view, was a success. I want to show only one content in the another view controller. The data of the closest time to the current time. I was asked to help with the following code. var stores: Contact? if ((stores?.date!.timeIntervalsince1970 ?? 0) > NSDate().timeIntervalSince1970) { labelName.text = stores?.content! } But

Convert NSData from local NSURL

南楼画角 提交于 2019-12-25 12:07:33
问题 I have a sound player which uses AVAudioPlayer class. I download some items in another view and store the filepath to it as NSURL, then pass the NSURL to the Player viewcontroller. But i get an error while trying to pass the object. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString path]: unrecognized selector sent to instance 0x1700c86c0' And here is the code: NSData *data = [NSData dataWithContentsOfFile:[podcastSource path]]; NSError *error

How to convert mp4 to NSData?

半城伤御伤魂 提交于 2019-12-25 09:35:07
问题 I have file in XCode with name vvideo.mp4. I am trying to convert it to NSData like below NSData *data = [NSData dataWithContentsOfFile:@"vvideo.mp4" options:nil error:nil]; But as I log data, it returns null. What is right way to convert any video to NSData? File is added and copies properly in Xcode, you can see here. EDITED QUESTION.... 回答1: dataWithContentsOfFile:options:error: takes a file path and not file name. If the video file is in application bundle you should do, NSString