nsdata

Check type of class an NSData store?

五迷三道 提交于 2019-12-20 07:44:24
问题 I have a library that process a string and converts it to an unknown format and insert it into a NSData. In a part of the code that library check if the NSData is empty, if not it sends to the server: if (!dataToSend) { return; } I thought the stored value would be a string or base64, for that tested the following codes: NSLog(@"To string -> %@",[NSString stringWithUTF8String:[dataToSend bytes]]); NSString *decodedString = [[NSString alloc] initWithData:dataToSend encoding

Objective-C: Getting PNG Thumbnail from Movie with NSData

二次信任 提交于 2019-12-20 07:21:09
问题 I have the following code to attempt to get a screenshot of a video file from NSData. I can confirm the NSData is valid and not nil, however both dataString and movieURL are returning nil. - (UIImage *)imageFromMovie:(NSData *)movieData { // set up the movie player NSString *dataString = [[NSString alloc] initWithData:movieData encoding:NSUTF8StringEncoding]; NSURL *movieURL = [NSURL URLWithString:dataString]; // get the thumbnail AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:movieURL

How can I convert my Zip-file to NSData to email my Zip file as an attachment

 ̄綄美尐妖づ 提交于 2019-12-20 05:35:31
问题 I', m using the Objective Zip library to compress several images i took. I came to the point (I guess) where I' zipping an image. Now I'd like to send this zipped File with the mailcomposer. However I need to declare a "NSData object" within my mail function. [picker addAttachmentData:"NSData object" mimeType:@"application/zip" fileName:@"test.zip"]; Here's a snippit of my code -(IBAction)sendMail{ NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,

saving images in string format (to use in xml)..not working

前提是你 提交于 2019-12-20 05:18:14
问题 i am converting image from picker into nsdata(jpeg representation) and then converting it into nsstring using the following code NSData *data=UIImageJPEGRepresentation(image,1.0); NSString *imageString=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]; [[NSUserDefaults standardUserDefaults] setObject:imageString forKey:@"image_name"]; and at the other end where i need to display the image the uiimage is formed as follows. NSString *imageString=[[NSString alloc] init];

Is there any difference between dataWithContentsOfURL (threaded) and dataTaskWithURL?

試著忘記壹切 提交于 2019-12-20 04:11:18
问题 We're using dataWithContentsOfURL because it is, uh, simple... NSData *datRaw = [NSData dataWithContentsOfURL:ur]; Now, of course, that will hang the main UI thread. So we put it on another thread. We do that exactly thus, -(void)performSearch:(NSString *)stuff then:(void(^)(void))after { dispatch_queue_t otherThread =dispatch_queue_create(nil,0); dispatch_queue_t mainThread =dispatch_get_main_queue(); dispatch_async(otherThread, ^{ self.resultsRA = [self ... calls dataWithContentsOfURL ...];

UIImagePNGRepresentation slow or am I doing something wrong?

孤街浪徒 提交于 2019-12-18 19:28:12
问题 I'm working on an iPhone App that uses the camera to take pictures, then I'm saving them to the Applications Documents directory. I'm using the following code to convert the UIImage to NSData, NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)]; Then I write the NSData using [imageData writeToFile:path atomically:NO] It all works. The problem is that UIImagePNGRepresentation() is really slow. It takes 8-9 secs on my 3G to convert the image to NSData. This seems wrong to

Creating a large Dummy File

放肆的年华 提交于 2019-12-18 18:24:07
问题 I'm new to this community and also new to iOS development, and I hope that someone can help me with a little problem... Currently I'm writing a little app for myself, that should create a very large dummy file, with dummy data or words or whatever it makes it big. The reason is, I would like to click a button and the app should generate a 4 gb file and save it to disk, that no other app could use it, because it isnt free... If I need the 4 gb of free space, I just have to open my little app,

Audio recorded using Audio Queue Services to data

狂风中的少年 提交于 2019-12-18 17:05:09
问题 I want to transmit voice from one iPhone to another. I have established connection between two iPhones using TCP and I have managed to record voice on the iPhone and play it using Audio Queue Services. I have also managed to send data between the two iPhones. I do this by sending NSData packages. My next step is to send the audio data to the other iPhone as it is being recorded. I believe I should do this in the AudioInputCallback . My AudioQueueBufferRef is called inBuffer and it seems that

Get the data from NSURLSession DownloadTaskWithRequest from completion handler

旧时模样 提交于 2019-12-18 15:48:25
问题 So I'm having hard time understanding something. This are the things I understand about NSURSession : Generally , I have 2 options for (as far as I know) DataTask(e.x dataTaskWithRequest) And DownloadTask(e.x DownloadTaskWithRequest ) - Using their delegate method , or use the completion handler , Can't do both. I have managed to receive DATA using dataTaskWithRequest like this : let request = NSMutableURLRequest(URL: dataSourceURL!) request.HTTPMethod = "POST" let postString = "lastid=\(id)"

How can a moderately sized memory allocation fail in a 64 bit process on Mac OS X?

纵饮孤独 提交于 2019-12-18 14:54:14
问题 I'm building a photo book layout application. The application frequently decompresses JPEG images into in-memory bitmap buffers. The size of the images is constrained to 100 megapixels (while they usually do not exceed 15 megapixels). Sometimes memory allocations for these buffers fail: [[NSMutableData alloc] initWithLength:] returns nil . This seems to happen in situations where the systems's free physical memory approaches zero. My understanding of the virtual memory system in Mac OS X was