nsdata

iphone SDK : Upload image from iphone to a php Server send empty file ?(sample code link inside)

僤鯓⒐⒋嵵緔 提交于 2019-12-21 05:29:05
问题 I try to send a photo and GPS location to server via PHP here is the PHP part:Copy from here Saving the Uploaded File The examples above create a temporary copy of the uploaded files in the PHP temp folder on the server. The temporary copied files disappears when the script ends. To store the uploaded file we need to copy it to a different location: <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) &

Cannot track down [NSData getBytes:length:] crash

笑着哭i 提交于 2019-12-21 04:30:10
问题 I got a strange EXC_BAD_ACCESS crash inside Foundation's -[NSData(NSData) getBytes:length:] method. It happens quite often, but I cannot get any meaningful information out of stack trace. There are no calls to getBytes:length: inside my code, except for open-source libraries (one in SDWebImage and one in SocketRocket ), but it doesn't seem like they're causing the crash. The only hint is that crash happens inside com.apple.CFNetwork.addPersistCacheToStorageDaemon thread, but I have no idea

implementing AES256 encryption into IOS

大憨熊 提交于 2019-12-21 02:47:25
问题 This is my java code. Now I want to implement same functionality in Objective-C. Cipher encryptCipher; IvParameterSpec iv = new IvParameterSpec(key); SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); encryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); encryptCipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv); byte[] encrypted = encryptCipher.doFinal(dataToEncrypt.getBytes()); Log.d("TAG", "encrypted string:" + Base64.encodeToString(encrypted, Base64.DEFAULT)); return Base64

How do I convert an NSNumber to NSData?

跟風遠走 提交于 2019-12-20 17:34:35
问题 I need to transmit an integer through GameKit using sendDataToAllPeers:withDataMode:error: but I don't know how to convert my NSNumber to NSData in order to send. I currently have: NSNumber *indexNum = [NSNumber numberWithInt:index]; [gkSession sendDataToAllPeers:indexNum withDataMode:GKSendDataReliable error:nil]; but obviously the indexNum needs to be converted to NSData before I can send it. Does anyone know how to do this please? Thanks! 回答1: I would not recommend NSKeyedArchiver for such

NSData to NSString converstion problem!

别等时光非礼了梦想. 提交于 2019-12-20 15:49:55
问题 I'm getting an html file as NSData and need to parse it to extract some info. My approach was to convert it to NSString with UTF8 encoding (the html has non english characters, russian for example) - it failed. I used something like that: NSString *respData = [NSString stringWithUTF8String:[theData bytes]]; but it returned nil. The only thing that actually worked was [NSString stringWithCString:[theData bytes] length:[theData length]]; but when it encounters russian characters for example it

NSData to NSString converstion problem!

送分小仙女□ 提交于 2019-12-20 15:47:29
问题 I'm getting an html file as NSData and need to parse it to extract some info. My approach was to convert it to NSString with UTF8 encoding (the html has non english characters, russian for example) - it failed. I used something like that: NSString *respData = [NSString stringWithUTF8String:[theData bytes]]; but it returned nil. The only thing that actually worked was [NSString stringWithCString:[theData bytes] length:[theData length]]; but when it encounters russian characters for example it

NSImage from a 1D pixel array?

China☆狼群 提交于 2019-12-20 10:58:20
问题 I have a large 1D dynamic array in my program that represents a FITS image on disk i.e. it holds all the pixel values of the image. The type of the array is double . At the moment, I am only concerned with monochrome images. Since Cocoa does not support the FITS format directly, I am reading in the images using the CFITSIO library. This works - I can manipulate the array as I wish and save the result to disk using the library. However, I now want to display the image. I presume this is

Converting custom class object into NSData

…衆ロ難τιáo~ 提交于 2019-12-20 09:15:30
问题 I have a custom class that I want to save into NSUserDefaults . I am told that I need to convert the class object into data in order to save it to NSUserDefaults . I found a lot of discrete string or ints to NSData examples but nothing on custom class to NSData . I know very little about the intricacies of NSData encoding etc. Any help is appreciated EDIT: While I understand there are similar answers here, none of them are in Swift. Translating between the languages is doable, but it is

Converting custom class object into NSData

戏子无情 提交于 2019-12-20 09:13:01
问题 I have a custom class that I want to save into NSUserDefaults . I am told that I need to convert the class object into data in order to save it to NSUserDefaults . I found a lot of discrete string or ints to NSData examples but nothing on custom class to NSData . I know very little about the intricacies of NSData encoding etc. Any help is appreciated EDIT: While I understand there are similar answers here, none of them are in Swift. Translating between the languages is doable, but it is

Convert UIImage to NSData and save with core data

懵懂的女人 提交于 2019-12-20 08:55:41
问题 I have a UIImageView whose image gets set via UIImagePicker - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ [picker dismissViewControllerAnimated:YES completion:nil]; self.gImage.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; } I "attempt" to convert this image to NSData and save it with core data: NSData *imageData = UIImagePNGRepresentation(self.gImage.image); NSString *savedData = [[NSString alloc