nsdata

Trying to resize an NSImage which turns into NSData

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 TIFFRepresentat...

AES encrypted value, the conversion happens NSString value to NSData?

cipher.h cipher.m are developing a module has. NSData value of the encrypted value problem as follows. : <0b21kck 0v35919 sk2910> As the purpose of encryption is to be sent to NSURLConnection String value. NSString value to NSData encrypted so I think it must be converted to What can you do? ...

NSData to NSString by changing the value null is returned. I need you help

*cipher.h, cipher.m all code : http://watchitlater.com/blog/2010/02/java-and-iphone-aes-interoperability Cipher.m -(NSData *)encrypt:(NSData *)plainText{ return [self transform:KCCEncrypt data:plainText; } step1. Cipher *cipher = [[Cipher alloc]initWithKey:@"1234567890"]; NSData *input = [@"kevin" dataUsingEncoding:NSUTF8StringEnc...

Text encoding problem between NSImage, NSData, and NSXMLDocument

I'm attempting to take an NSImage and convert it to a string which I can write in an XML document. My current attempt looks something like this: [xmlDocument setCharacterEncoding: @"US-ASCII"]; NSData* data = [image TIFFRepresentation]; NSString* string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; //Put stri...

Storing CLLocationCoordinates2D in NSMutableArray

After some searching, I got the following solution : ref: http://stackoverflow.com/questions/1392909/nsmutablearray-addobject-with-mallocd-struct CLLocationCoordinate2D* new_coordinate = malloc(sizeof(CLLocationCoordinate2D)); new_coordinate->latitude = latitude; new_coordinate->longitude = longitude; [points addObject:[NSData dataWithB...

NSData-AES Class Encryption/Decryption in Cocoa

hi, I am attempting to encrypt/decrypt a plain text file in my text editor. encrypting seems to work fine, but the decrypting does not work, the text comes up encrypted. I am certain i've decrypted the text using the word i encrypted it with - could someone look through the snippet below and help me out? Thanks :) Encrypting: NSAlert...

NSData's writeToFile method failing with server address

Hi. I am trying to write an NSData object to a directory like so; [myData writeToFile:[NSString stringWithFormat:@"%@/%@.txt", path, filename] atomically:YES]; I receive no errors or warnings but I am assuming the write fails because the path variable has the format of afp://10.0.0.20/username/Desktop. I am connected to the networked...

New NSData with range of old NSData maintaining bytes.

I have a fairly large NSData (or NSMutableData if necessary) object which I want to take a small chunk out of and leave the rest. Since I'm working with large amounts of NSData bytes, I don't want to make a big copy, but instead just truncate the existing bytes. Basically: NSData *source: < a few bytes I want to discard > + < big chunk...

How to serialize object containing NSData?

I'm trying to serialize an object containing a number of data fields...where one of the fields is of datatype NSData which won't serialize. I've followed instructions at http://www.isolated.se but my code (see below) results in the error "[NSConcreteData data]: unrecognized selector sent to instance...". How do I serialize my object? He...

obj-c problem setting array with componentsSeperatedByString

I have a data source with about 2000 lines that look like the following: 6712,Anaktuvuk Pass Airport,Anaktuvuk Pass,United States,AKP,PAKP,68.1336,-151.743,2103,-9,A What I am interested in is the 6th section of this string so I want to turn it into an array, then i want to check the 6th section [5] for an occurrance of that string "PA...

How create UIImage from bytes ?

Hello, all! I need in UIImage created from my colors (for example, i need in image 1x1 pixel with black color). I've got array: unsigned char *color[] = {0, 0, 0, 1}; How can i create UIImage from this array ? I've try unsigned char *bytes[4] = {0,0,0,1}; NSData *data = [NSData dataWithBytes:bytes length:4]; UIImage *img = [UII...

Email from an app, but not use a a pop up controller, just text inside a text box.

Hey is there any way to send whats in a text view (im trying to make a suggestion box) to my email address? example user types in the box " I think you should add twitter support" then that is sent in the background to my email address [email protected] then a message is popped up on the screen saying "suggestion sent" just an exampl...

NSData to display as a string

Hello all, this is my first post. I am building an iPhone app and stuck with the following: unsigned char hashedChars[32]; CC_SHA256([inputString UTF8String], [inputString lengthOfBytesUsingEncoding:NSASCIIStringEncoding], hashedChars); NSData *hashedData = [NSData dataWithBytes:hashedChars length:32]; NSLog(@"hashedData = %@", hashedDa...

game state singleton cocos2d, initWithEncoder always returns null

Hi, I'm trying to write a basic test "game state" singleton in cocos2d, but for some reason upon loading the app, initWithCoder is never called. Any help would be much appreciated, thanks. Here's my singleton GameState.h: #import "cocos2d.h" @interface GameState : NSObject <NSCoding> { NSInteger level, score; Boolean seenInstruct...

Saving data - does work on Simulator, not on Device

I use NSData to persist an image in my application. I save the image like so (in my App Delegate): - (void)applicationWillTerminate:(UIApplication *)application { NSLog(@"Saving data"); NSData *data = UIImagePNGRepresentation([[viewController.myViewController myImage]image]); //Write the file out! NSArray *paths = NSSe...

Memory leak with NSData

I'm having a leak with this code without being able to find where it's coming from. This function get called within an autorelease pool. I release the IplImage* image argument. When I run the ObjAlloc tool, it tells me that "NSData* data" is leaking. If I try to manually release the UIImage returned by this function, I get an EXC_BAD_AC...

Getting HTML source(NSData) from website that needs logging in (iphone)

NSData *data = [[NSData alloc] initWithContentsOfURL:url]; Url is an NSURL and it works fine. However I'd like to get the HTML (data) after I've logged in. So the website has a standard way of logging in with 2 textboxes and a submit action on the form. So how can I log in then get the HTMl source so I can parse it. Do i have to use ...

How to pull UIImages from NSData from a socket.

Hey all! I'm using ASyncSocket to move some UIImages from one device over to another. Essentially, on one device I have: NSMutableData *data = UIImageJPEGRepresentation(image, 0.1); if(isRunning){ [sock writeData:data withTimeout:-1 tag:0]; } So a new image will be added to the socket every so often (like a webcam). Then, on ...

iphone - data signing using NSData of the private key

Hi I am working on a e-banking iphone application. I am using WSS with XML-Signature to sign the requests to the customer's SOAP server. Since the iPhone device can not be trusted (due to jail-breaking), the customer requirement is to manually encrypt the RSA key pair (using AES128) before storing the keys into keychain. From what I ...

Correct way to load image into UIWebView from NSData object

I have downloaded a gif image into an NSData object (I've checked the contents of the NSData object and it's definitely populated). Now I want to load that image into my UIWebView. I've tried the following: [webView loadData:imageData MIMEType:@"image/gif" textEncodingName:nil baseURL:nil]; but I get a blank UIWebView. Loading the ima...