nsdata

Store images in sqlite or just a reference to it?

大兔子大兔子 提交于 2019-12-07 12:28:49
问题 I have made couple of apps using coredata and I was storing images in sqlite, but somewhere i found that it is bad. I've searched the net but all I've found is this suggestion: image size < 100kb store in the same table as the relevant data image size < 1mb store in a separate table attached via a relationship to avoid loading unnecessarily image size > 1mb store on disk and reference it inside of Core Data So my question is: what are pros and cons of saving an image in sqlite db as NSData ,

convert base64 decoded NSData to NSString

和自甴很熟 提交于 2019-12-07 08:57:16
问题 I'm trying to encode and decode base64 data. but while decoding the base64 data, it returns bunch of hex values, but i couldn't display or printout using NSlog to the original readable strings. The below code couldn't print anything, just empty. Can anyone help ? thanks > > NSString* msgEncoded = [[NSString alloc] initWithFormat:@"Q1NNKE1DTC9TTUEgUkNWL2FkbWluQHNldGVjcy5jb20gT1JHLyBUVkIvNDNkYzNlMzQwYWQ3Yzkp:"]; NSData* decoded = [[NSData alloc] initWithData:[self decodeBase64WithString

Converting Image to BASE64 String in swift

拈花ヽ惹草 提交于 2019-12-07 03:07:50
问题 I am trying to convert the Image which is picked by user either from his Photos or Take New from Camera. I am able to convert the image into base64 string but the problem is that it takes too much time and prints a long infinite string Here is the output of String which i am getting here is my code: // Image picker from Gallery func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) { imagePicker

NSKeyedArchiver archivedDataWithRootObject:

可紊 提交于 2019-12-07 02:56:31
问题 Is the parameter for NSKeyedArchiver archivedDataWithRootObject: supposed to be the array I am trying to save, or the array converted into NSData? 回答1: To convert a generic array to an NSData , you need an archiver! If you know how to feed the NSData , you know how to use NSKeyedArchiver . So: NSArray* array= ... ; NSData* data=[NSKeyedArchiver archivedDataWithRootObject:array]; Of course all elements in your array needs to implement encodeWithCoder: . 回答2: Yuji's answer is right. but more

How to convert NSData value to UIImage [duplicate]

强颜欢笑 提交于 2019-12-07 02:39:34
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: NSData to UIImage How do I convert a NSData value to UIImage? 回答1: You can get UIImage from NSData as follows: NSData *data = yourData; UIImage *image = [UIImage imageWithData:data]; or NSData *data = yourData; UIImage *image = [[UIImage alloc] initWithData:data]; .... [image release]; 来源: https://stackoverflow.com/questions/10101526/how-to-convert-nsdata-value-to-uiimage

Upload large video via NSURLSession causes memory pressure crash

↘锁芯ラ 提交于 2019-12-07 01:42:30
问题 I use the following codes to upload video to server, which requires me to convert the video from video format to NSData . However, when the video is large (e.g. 10 minute video), the App crashes due to memory pressure. How can I resolve this? - (void)uploadVideo { NSDictionary *params = nil; NSString *NSURLSessionIdentifier = [NSString stringWithFormat:@"%@%@",@"my.bundle.identifier.",[self getTimeString]]; NSURLSessionConfiguration *sessionConfig; // SessionConfiguration With iOS Version if

Getting data out of NSData with Swift

。_饼干妹妹 提交于 2019-12-07 00:02:38
问题 I am finding Swift and NSData to be an unholy matrimony of frustration. I find I feel like all the supposed new found Swift safety goes out the window every time I deal with this thing. The amount of crashes (with unhelpful traces) don't help. So, I've learned, that I can avoid the scary UnsafeMutablePointer stuff by doing things like the following: var bytes = [UInt8](count: 15, repeatedValue: 0) anNSData.getBytes(&bytes, length=15) I also discovered, that I can extract directly into

Unzip NSData without temporary file

浪尽此生 提交于 2019-12-06 20:11:19
问题 I've found a couple of libs (LiteZip and ZipArchive) that allow to unzip files on iPhone. But both of them require an input as a file. Is there a library that allows to directly unzip NSData containing zip-archived data without writing it to temporary file? I've tried to adopt mentioned above libs for that, but with no success so far. 回答1: In this answer to this question, I point out the CocoaDev wiki category on NSData which adds zip / unzip support to that class. This would let you do this

iOS Caching images with AFImageCache doesn't seem to work

微笑、不失礼 提交于 2019-12-06 16:13:23
问题 I'm trying to cache some images loaded from a URL by using AFImageCache, without success... I'm not sure If i'm doing anything wrong and would love your opinions if you've ever used this library. I'm getting an image from a NSURLRequest, and then caching it as follows UIImage *img; //This image is a png icon returned from the server NSData *imgData = UIImagePNGRepresentation(img); // Always checking length to make sure its more than 0, and it is [[AFImageCache sharedImageCache] cacheImageData

iOS: Why my big files are not converted with NSData(contentsOfFile: options:)? Error Domain=NSCocaErrorDomain Code=256

假如想象 提交于 2019-12-06 16:08:06
I try to convert a video with NSData, it works well with little videos or 100mb, but my big files (4.44Gb) are not sent... var video_data: NSData? do { video_data = try NSData(contentsOfFile: (videoPath), options: NSData.ReadingOptions.alwaysMapped) } catch let error as NSError { video_data = nil return } How can I put big files in NSData? Error Domain=NSCocoaErrorDomain Code=256 "Impossible d’ouvrir le fichier « D9C7DABF-4BE3-4105-8D76-AA92B1D1502E_video.notsend »." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/EAE9B4C4-BE6B-490C-BEE7-381B2DF27CC9/Library/LEADS/D9C7DABF-4BE3