nsdata

Merging NSData video files into one video file

大城市里の小女人 提交于 2019-12-03 17:32:49
I have a bunch of video files that I want to merge into one video file, I am using NSMutableData to achieve the task NSMutableData *concatenatedData = [[NSMutableData alloc] init]; for (int i=0; i <[videoArray count]; i ++) { [concatenatedData appendData: [videoArray objectAtIndex:i]]; } [concatenatedData writeToFile:[[NSString alloc] initWithFormat:@"%@%@", NSTemporaryDirectory(), @"outputConct.mov"] atomically:YES]; UISaveVideoAtPathToSavedPhotosAlbum([[NSString alloc] initWithFormat:@"%@%@", NSTemporaryDirectory(),@"outputConct.mov"], nil, nil, nil); after the video is saved in my camera

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

回眸只為那壹抹淺笑 提交于 2019-12-03 16:17:07
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")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $

Trying to resize an NSImage which turns into NSData

北城余情 提交于 2019-12-03 16:16:51
I have an NSImage which I am trying to resize like so; NSImage *capturePreviewFill = [[NSImage alloc] initWithData:previewData]; NSSize newSize; newSize.height = 160; newSize.width = 120; [capturePreviewFill setScalesWhenResized:YES]; [capturePreviewFill setSize:newSize]; NSData *resizedPreviewData = [capturePreviewFill TIFFRepresentation]; resizedCaptureImageBitmapRep = [[NSBitmapImageRep alloc] initWithData:resizedPreviewData]; saveData = [resizedCaptureImageBitmapRep representationUsingType:NSJPEGFileType properties:nil]; [saveData writeToFile:@"/Users/ricky/Desktop/Photo.jpg" atomically

Getting data from the nstask - communicating with command line - objective c

有些话、适合烂在心里 提交于 2019-12-03 16:10:42
问题 I know how to send data to the task: NSData *charlieSendData = [[charlieImputText stringValue] dataUsingEncoding:NSUTF8StringEncoding]; [[[task standardInput] fileHandleForWriting] writeData:charlieSendData]; But how do I get what the task responds with?? Elijah 回答1: Give an NSPipe or an NSFileHandle as the task's standardOutput , and read from that. NSTask * list = [[NSTask alloc] init]; [list setLaunchPath:@"/bin/ls"]; [list setCurrentDirectoryPath:@"/"]; NSPipe * out = [NSPipe pipe]; [list

Decode MP3 File from NSData

爷,独闯天下 提交于 2019-12-03 14:45:53
For my application, I need to decode an MP3 file which is stored in an NSData object. For security reasons, it is undesirable to write the NSData object to disk and re-open it using a System URL reference, even if its only locally stored for a few moments. I would like to take advantage Extended Audio File Services (or Audio File Services) to do this, but I'm having trouble getting a representation of the NSData, which exists only in memory, that can be read by these Audio File Services. Edit: I want to decode the MP3 data so I can get access to linear, PCM audio samples for manipulation.

Using Structs (Bytes) with SWIFT - Struct to NSData and NSData to Struct

风格不统一 提交于 2019-12-03 14:41:45
I'm trying to understand how structs work within SWIFT. I'm familiar with how .NET handles them and how it packs bytes into a structure, etc. I'm finding some weirdness with the following code: struct exampleStruct { var ModelNumber: Byte! var MajorVersion: Byte! var MinorVersion: Byte! var Revision: Byte! } var myStruct = exampleStruct ( ModelNumber: 1, MajorVersion: 2, MinorVersion: 3, Revision: 4 ) myStruct.MinorVersion // << Returns 3 // Struct to NSData. var data = NSData( bytes: &myStruct, length: sizeof(exampleStruct) ) println("data: \(data)") The println returns: "data: <01000200

NSData from NSKeyedArchiver to NSString

人走茶凉 提交于 2019-12-03 13:50:28
I'm trying to convert NSData generated from NSKeyedArchiver to an NSString so that I can pass it around and eventually convert it back to NSData. I have to pass this as a string (I'm using three20 URL passing). I've gone through various encodings, UTF8, ASCII, etc. and can't get anything to work. NSKeyedArchiver says that the NSData is formated as a property list: NSPropertyListBinaryFormat_v1_0. Does anyone have any idea how I can convert this NSData to a String and back again? Size of the string isn't an issue. Thanks What you want is: id<nscoding> obj; NSData * data = [NSKeyedArchiver

Cannot track down [NSData getBytes:length:] crash

坚强是说给别人听的谎言 提交于 2019-12-03 13:30:18
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 what is it about. Can someone help? Stacktrace from Crashlytics: Thread : Crashed: com.apple.CFNetwork

Convert nsdictionary to nsdata

若如初见. 提交于 2019-12-03 12:03:50
问题 have an app that can take a picture and then upload to a server. encoding it to base 64 and pass it thru a XMLRPC to my php server. i want to take the NSDictionary info that is returned from UIImagePickerController delegate -(void) imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info and convert it to NSData so i can encode it. so, how can i convert NSDictionary to an NSData? 回答1: You can use an NSKeyedArchiver to serialize your

How do I extract the width and height of a PNG from looking at the header in objective c?

倾然丶 夕夏残阳落幕 提交于 2019-12-03 11:59:50
I have a need to find the dimensions of images online without downloading them. To accomplish this I do this: + (CGSize) getImageDimensions:(NSString *)url { // Send a synchronous request NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString: url]]; NSString *rangeString = [url hasSuffix: @"png"] ? @"bytes=0-100" : @"bytes=0-1300"; [urlRequest setValue:rangeString forHTTPHeaderField:@"Range"]; NSURLResponse * response = nil; NSError * error = nil; NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];