nsdata

Converting HEX NSString To NSData

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-16 21:29:32
问题 I'm trying to convert a Hex NSString to NSData (I'm using the below attached code). The following is the output: <00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000> which looks totally irrelevant to me. Any idea/ suggestions on where its going wrong? NSString *strData = @"72ff63cea198b3edba8f7e0c23acc345050187a0cde5a9872cbab091ab73e553"; NSLog(@"string Data length is %d",[strData length]); NSMutableData *commandToSend= [[NSMutableData alloc] init]; unsigned char whole

Literal converstion NSData to NSString [closed]

橙三吉。 提交于 2019-12-13 23:19:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am new to iOS programming and i am trying to get a textual representation of an NSData object as a NSString For example if the NSData object is: <07010013 01020000 09000100 000199c2> I want to convert that to: "070100130102000009000100000199c2" How can I do that? 回答1: HINT#1 // general answer NSString provides

How can I optimize UIImage resizes for a specific target filesize?

雨燕双飞 提交于 2019-12-13 18:52:44
问题 For any given file data size, I want to be able to resize (or compress) a UIImage to fit within that data limit. This question is NOT about how to resize, or how to check file sizes... it is about an algorithm to getting this in a performant way. Searching here already, I found this thread which talks about stepping down the image jpeg quality in a linear, or binary algorithm. This isn't very performant, taking dozens of seconds at best. I am working on iOS so images can be close to 10MB

Why does this AES128 Decryption take so long on iPhone?

匆匆过客 提交于 2019-12-13 18:46:28
问题 I am decrypting an image sent from a php server. I am using the CryptoSwift library to decrypt the image, the image comes in as NSData, and after the decryption, I create an UIImage from the NSData. But the decryption takes about 1minute and 10 seconds, which is very slow. The size of the image data: println(imageData.length) result: 32592 I believe that's not a big file right? This is the code I use to decrypt the image data: let aes = AES(key: keyData, iv: ivData, blockMode: .ECB) let

Convert NSData to byte array

风格不统一 提交于 2019-12-13 17:50:01
问题 I want to convert the NSData into byte array and given below is the code that i have used NSData *imageData = UIImagePNGRepresentation(recipeImage.image); NSUInteger len = [imageData length]; Byte *byteData = (Byte*)malloc(len); memcpy(byteData, [imageData bytes], len); NSLog(@"%8s",byteData); But its giving me an error when i post the byteData to the webservice which is given below "Server was unable to process request. ---> Parameter is not valid." and when i print the byteData this is what

How would I save an object of type DateComponents to a CloudKit field?

情到浓时终转凉″ 提交于 2019-12-13 17:47:28
问题 I am using Swift for an iOS app. I need to store a DateComponents object as a field in CloudKit. How would I do that? So far I think I need to set the CloudKit field to type Bytes, and convert the DateComponents object to a Data object. Looking at the documentation for the Data class, I can't figure out how to initialize the Data object. I have no idea how to use the UnsafeBufferPointer used in one of the initializers. The following code gives a runtime error: newRecord.setObject(

UIImage with NSData initWithData returns nil

前提是你 提交于 2019-12-13 08:37:55
问题 I have a new question here! As the real problem was not in the C++ conversion but rather that I need to convert the returned string data bytes into a CGImageRef. Anybody know how to do that please go to that link to answer the follow on to this question. Thank you. OK. Instead of muddying the question with protobuf stuff, I have simplified my test method to simulate the call that would be made to the protobuf stuff. This test method does the following two parts. Part 1 takes a UIImage and

How to retrieve string from NSData stored in sqlite?

爷,独闯天下 提交于 2019-12-13 06:59:45
问题 Note: I have stored NSData in local database. I want to use it back from local database. But as it is stored in local database as text ,facing issue in converting back it into NSData . strDbData is object of type NSString here. I have one NSData stored in local database like <a3829c97 3b1efacb c7680f7e 7e7a95a2> Now I want to retrive it back, so I am doing as mentioned below but I am receiving error. 1) First way NSData *myData = (NSData*)strDbData; NSLog(@"%@",[myData class]); Error : -[_

How to send an NSDictionary (or plist file) as NSData using GameKit bluetooth?

久未见 提交于 2019-12-13 06:48:52
问题 I'm trying to use [currentSession sendDataToAllPeers:data withDataMode:GKSendDataReliable error:nil]; to send an NSDictionary (or a plist file) containing data from 1 device to another, and - (void)receiveData:(NSData *)data fromPeer:(NSString *)peer inSession:(GKSession *)session context:(void *)context to receive it. How can I convert to and from NSData for this to happen? 回答1: You can use the following to transform Plist to NSData: + (NSData *)dataWithPropertyList:(id)plist format:

Storing NSImage and NSData in a Cocoa Core Data App

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 05:48:43
问题 I am writing a Cocoa App to display a 2-d floating array. I now want to assign these images to an entity attribute in Core Data, so I use the transformable data type. The problem starts when I try to store an NSImage (and / or NSData) within an Entity ("TheEntity") using a transformable attribute, call it "entityImage." Here is the error I get: CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of