nsdata

dataWithContentsOfURL returns NSCocoaErrorDomain Code=256 over cellular, but not wifi

北城以北 提交于 2019-11-29 23:54:48
问题 Really odd problem I'm having: dataWithContentsOfURL has begun returning an error code 256 over cellular, but not over wifi. The operation couldn’t be completed. (Cocoa error 256.) I do indeed have a cellular data connection, and it is functioning, so it is not a problem with my cellular connection. Plus the code works fine on wifi, so the basic code is not the issue. The code in question is: dispatch_queue_t queue = dispatch_queue_create("com.appName.FetchImage", DISPATCH_QUEUE_SERIAL);

NSData to [Uint8] in Swift

自闭症网瘾萝莉.ら 提交于 2019-11-29 22:01:28
I couldn't find a solution to this problem in Swift (all of them are Objective-C, and they deal with pointers which I don't think exist in Swift in the same form). Is there any way to convert a NSData object into an array of bytes in the form of [Uint8] in Swift? You can avoid first initialising the array to placeholder values, if you go through pointers in a slightly convoluted manner, or via the new Array constructor introduced in Swift 3: Swift 3 let data = "foo".data(using: .utf8)! // new constructor: let array = [UInt8](data) // …or old style through pointers: let array = data

Convert unsigned char array to NSData and back

℡╲_俬逩灬. 提交于 2019-11-29 20:57:21
How do you convert an unsigned char array to an NSData in objective c? This is what I am trying to do, but it doesn't work. Buffer is my unsigned char array. NSData *data = [NSData dataWithBytes:message length:length]; You can just use this NSData class method + (id)dataWithBytes:(const void *)bytes length:(NSUInteger)length Something like NSUInteger size = // some size unsigned char array[size]; NSData* data = [NSData dataWithBytes:(const void *)array length:sizeof(unsigned char)*size]; You can then get the array back like this (if you know that it is the right data type) NSUInteger size =

Data corruption when reading realtime H.264 output from AVAssetWriter

大兔子大兔子 提交于 2019-11-29 20:02:09
I'm using some tricks to try to read the raw output of an AVAssetWriter while it is being written to disk. When I reassemble the individual files by concatenating them, the resulting file is the same exact number of bytes as the AVAssetWriter's output file. However, the reassembled file will not play in QuickTime or be parsed by FFmpeg because there is data corruption. A few bytes here and there have been changed, rendering the resulting file unusable. I assume this is occurring on the EOF boundary of each read, but it isn't consistent corruption. I plan to eventually use code similar to this

UIImage created from CGImageRef fails with UIImagePNGRepresentation

白昼怎懂夜的黑 提交于 2019-11-29 17:28:03
问题 I'm using the following code to crop and create a new UIImage out of a bigger one. I've isolated the issue to be with the function CGImageCreateWithImageInRect() which seem to not set some CGImage property the way I want. :-) The problem is that a call to function UIImagePNGRepresentation() fails returning a nil. CGImageRef origRef = [stillView.image CGImage]; CGImageRef cgCrop = CGImageCreateWithImageInRect( origRef, theRect); UIImage *imgCrop = [UIImage imageWithCGImage:cgCrop]; ... NSData

What is NSConcreteData, and where is it defined?

空扰寡人 提交于 2019-11-29 17:24:22
问题 The following code: [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mapURL]] returns an instance of NSConcreteData as opposed to NSData (which I expected!). What does NSConcreteData represent, exactly, and why is it being returned instead of an instance of NSData? Further, where is this class defined? XCode is complaining that it hasn't been defined, but I don't know what I should include in order to get the class. Any help appreciated! 回答1: The Foundation framework uses class

Converting GIF images to nsdata

为君一笑 提交于 2019-11-29 16:45:07
I have an iPhone application that needs to save an image onto the database in BLOB format. The problem is that if the image is in .gif format then it cannot be converted to NSDATA format and hence i am not been able to save that onto the database in BLOB format. What should I do? Please help with some code.. Thanks in advance Joy A gif image can be converted into NSData...Here's the code snippet: NSString *pathForGif = [[NSBundle mainBundle] pathForResource: @"gifFile" ofType: @"gif"]; NSData *gifData = [NSData dataWithContentsOfFile: pathForGif]; NSLog(@"Data: %@", gifData); The log looked

Loading takes a while when i set UIImage to a NSData with a url.

穿精又带淫゛_ 提交于 2019-11-29 16:40:03
NSData *imageUrl = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[self.content objectAtIndex:indexPath.row] valueForKey:@"imageUrl"] ]]; cell.thumbnailImageView.image=[UIImage imageWithData:imageUrl]; this is how i use imageUrl to load them into UIImage but it takes a while to load and the program seems like it crashed or entered to an infinite loop. How can i make the content of UIImage with url but faster? use sdwebimage and down load the library file from here the few steps you do follow add the sdwebimage in your project after that in your .h file #import "UIImageView+WebCache.h" in

Move data/images between two iOS apps using custom URL handler

只愿长相守 提交于 2019-11-29 14:38:06
问题 After googling around and searching SO for a while, I stil couldn't find an answer - I've wondered, How could I transfer data between two of my apps using custom URL handlers? Specifically images or an NSData object for that matter. I know about being able to open specific parts of my app using custom handlers such as myapp1://start , myapp2://start , but I'm not sure how to go on transferring large amounts of data (~80k) through these handlers. Would love to hear any creative solutions :) p

convert UIImage to NSData and back to UIImage

自古美人都是妖i 提交于 2019-11-29 14:15:59
问题 I have to populate table cell from database and images are on device. I've to store that image in imageDataObject , how to convert that UIImage to NSData . Please suggest, I tried many solution but it's not converting back that NSData to UIImage . cell.textLabel.text = [[offlineImageListArray objectAtIndex:indexPath.row] imageName]; UIImage *thumbnail = [self retrieveImageFromDevice:[[offlineImageListArray objectAtIndex:indexPath.row] imageName]]; NSData* data = ??????????; ImageData