Search Results

Search found 477 results on 20 pages for 'nsdata'.

Page 5/20 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • MonoTouch Load image in background

    - by user1058951
    I am having a problem trying to load an image and display it using System.Threading.Task My Code is as follows Task DownloadTask { get; set; } public string Instrument { get; set; } public PriceChartViewController(string Instrument) { this.Instrument = Instrument; DownloadTask = Task.Factory.StartNew(() => { }); } private void LoadChart(ChartType chartType) { NSData data = new NSData(); DownloadTask = DownloadTask.ContinueWith(prevTask => { try { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; NSUrl nsUrl = new NSUrl(chartType.Uri(Instrument)); data = NSData.FromUrl(nsUrl); } finally { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; } }); DownloadTask = DownloadTask.ContinueWith(t => { UIImage image = new UIImage(data); chartImageView = new UIImageView(image); chartImageView.ContentScaleFactor = 2f; View.AddSubview(chartImageView); this.Title = chartType.Title; }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext()); } The second Continue with does not seem to be being called? Initially my code looked like the following without the background processing and it worked perfectly. private void oldLoadChart(ChartType chartType) { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; NSUrl nsUrl = new NSUrl(chartType.Uri(Instrument)); NSData data = NSData.FromUrl(nsUrl); UIImage image = new UIImage(data); chartImageView = new UIImageView(image); chartImageView.ContentScaleFactor = 2f; View.AddSubview(chartImageView); this.Title = chartType.Title; UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; } Does anyone know what I am doing wrong?

    Read the article

  • iPhone AES encryption issue

    - by Dilshan
    Hi, I use following code to encrypt using AES. - (NSData*)AES256EncryptWithKey:(NSString*)key theMsg:(NSData *)myMessage { // 'key' should be 32 bytes for AES256, will be null-padded otherwise char keyPtr[kCCKeySizeAES256 + 1]; // room for terminator (unused) bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding) // fetch key data [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding]; NSUInteger dataLength = [myMessage length]; //See the doc: For block ciphers, the output size will always be less than or //equal to the input size plus the size of one block. //That's why we need to add the size of one block here size_t bufferSize = dataLength + kCCBlockSizeAES128; void* buffer = malloc(bufferSize); size_t numBytesEncrypted = 0; CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, keyPtr, kCCKeySizeAES256, NULL /* initialization vector (optional) */, [myMessage bytes], dataLength, /* input */ buffer, bufferSize, /* output */ &numBytesEncrypted); if (cryptStatus == kCCSuccess) { //the returned NSData takes ownership of the buffer and will free it on deallocation return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted]; } free(buffer); //free the buffer; return nil; } However the following code chunk returns null if I tried to print the encryptmessage variable. Same thing applies to decryption as well. What am I doing wrong here? NSData *encrData = [self AES256EncryptWithKey:theKey theMsg:myMessage]; NSString *encryptmessage = [[NSString alloc] initWithData:encrData encoding:NSUTF8StringEncoding]; Thank you

    Read the article

  • Problem with XML parser

    - by zp26
    Hi, I have a problem with parsing XML. I have created a program which write a file xml in the project directory. The file XML are correct. (i checked). When i try to read this XML the program crash and return 1 status. I have controlled my 2 path and they are equals. Can you help me please? Thanks so much. #import "PositionIdentifierViewController.h" #import "WriterXML.h" @implementation PositionIdentifierViewController - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { NSString *stringa = [NSString stringWithFormat:@"%@",string]; textArea.text = [textArea.text stringByAppendingString:@"\n"]; textArea.text = [textArea.text stringByAppendingString:stringa]; } -(IBAction)startParsing { NSURL *xmlURL = [NSURL fileURLWithPath:path]; NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL]; [parser setDelegate:self]; BOOL success = [parser parse]; if(success == YES){ // } [parser release]; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; NSArray *tempPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [tempPaths objectAtIndex:0]; path = [documentsDirectoryPath stringByAppendingPathComponent:@"filePosizioni.xml"]; WriterXML *newWriter; newWriter = [[WriterXML alloc]init]; [newWriter saveXML:(NSString*)@"ciao":(float)10:(float)40:(float)70]; [newWriter saveXML:(NSString*)@"pippo":(float)20:(float)50:(float)80]; [newWriter saveXML:(NSString*)@"pluto":(float)30:(float)60:(float)90]; NSLog(path); } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end #import "WriterXML.h" @implementation WriterXML -(void)saveXML:(NSString*)name:(float)x:(float)y:(float)z{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectoryPath stringByAppendingPathComponent:@"filePosizioni.xml"]; NSFileHandle *myHandle; NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *titoloXML = [NSString stringWithFormat:@"<?xml version=1.0 encoding=UTF-8 ?>"]; NSString *inizioTag = [NSString stringWithFormat:@"\n\n\n<position>"]; NSString *tagName = [NSString stringWithFormat:@"\n <name>%@</name>", name]; NSString *tagX = [NSString stringWithFormat:@"\n <x>%f</x>", x]; NSString *tagY = [NSString stringWithFormat:@"\n <y>%f</y>", y]; NSString *tagZ = [NSString stringWithFormat:@"\n <z>%f</z>", z]; NSString *fineTag= [NSString stringWithFormat:@"\n</position>"]; NSData* dataTitoloXML = [titoloXML dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataInizioTag = [inizioTag dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataName = [tagName dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataX = [tagX dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataY = [tagY dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataZ = [tagZ dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataFineTag = [fineTag dataUsingEncoding: NSASCIIStringEncoding]; if(![fileManager fileExistsAtPath:filePath]) [fileManager createFileAtPath:filePath contents:dataTitoloXML attributes:nil]; myHandle = [NSFileHandle fileHandleForUpdatingAtPath:filePath]; [myHandle seekToEndOfFile]; [myHandle writeData:dataInizioTag]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataName]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataX]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataY]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataZ]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataFineTag]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; NSLog(@"zp26 %@",filePath); } @end

    Read the article

  • Help needed with AES between Java and Objective-C (iPhone)....

    - by Simon Lee
    I am encrypting a string in objective-c and also encrypting the same string in Java using AES and am seeing some strange issues. The first part of the result matches up to a certain point but then it is different, hence when i go to decode the result from Java onto the iPhone it cant decrypt it. I am using a source string of "Now then and what is this nonsense all about. Do you know?" Using a key of "1234567890123456" The objective-c code to encrypt is the following: NOTE: it is a NSData category so assume that the method is called on an NSData object so 'self' contains the byte data to encrypt. - (NSData *)AESEncryptWithKey:(NSString *)key { char keyPtr[kCCKeySizeAES128+1]; // room for terminator (unused) bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding) // fetch key data [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding]; NSUInteger dataLength = [self length]; //See the doc: For block ciphers, the output size will always be less than or //equal to the input size plus the size of one block. //That's why we need to add the size of one block here size_t bufferSize = dataLength + kCCBlockSizeAES128; void *buffer = malloc(bufferSize); size_t numBytesEncrypted = 0; CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, keyPtr, kCCKeySizeAES128, NULL /* initialization vector (optional) */, [self bytes], dataLength, /* input */ buffer, bufferSize, /* output */ &numBytesEncrypted); if (cryptStatus == kCCSuccess) { //the returned NSData takes ownership of the buffer and will free it on deallocation return [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted]; } free(buffer); //free the buffer; return nil; } And the java encryption code is... public byte[] encryptData(byte[] data, String key) { byte[] encrypted = null; Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); byte[] keyBytes = key.getBytes(); SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES"); try { Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding", "BC"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); encrypted = new byte[cipher.getOutputSize(data.length)]; int ctLength = cipher.update(data, 0, data.length, encrypted, 0); ctLength += cipher.doFinal(encrypted, ctLength); } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage()); } finally { return encrypted; } } The hex output of the objective-c code is - 7a68ea36 8288c73d f7c45d8d 22432577 9693920a 4fae38b2 2e4bdcef 9aeb8afe 69394f3e 1eb62fa7 74da2b5c 8d7b3c89 a295d306 f1f90349 6899ac34 63a6efa0 and the java output is - 7a68ea36 8288c73d f7c45d8d 22432577 e66b32f9 772b6679 d7c0cb69 037b8740 883f8211 748229f4 723984beb 50b5aea1 f17594c9 fad2d05e e0926805 572156d As you can see everything is fine up to - 7a68ea36 8288c73d f7c45d8d 22432577 I am guessing I have some of the settings different but can't work out what, I tried changing between ECB and CBC on the java side and it had no effect. Can anyone help!? please....

    Read the article

  • iPhone: CATiledLayer/UIScrollView wont scroll after zooming and only zooms to anchor point

    - by Brodie4598
    Here is the problem... I am using CA Tiled Layer to display a large jpg. The view loads okay, and when I go to scroll around, it works fine. However, as soon as I zoom in or out once, it scrolls to the top left (to the anchor point) and will not scroll at all. The zooming works fine, but I just cannot scroll. Here is my code: #import <QuartzCore/QuartzCore.h> #import "PracticeViewController.h" @implementation practiceViewController //@synthesize image; - (void)viewDidLoad { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect pageRect = CGRectMake(0, 0, image.size.width, image.size.height); CATiledLayer *tiledLayer = [CATiledLayer layer]; tiledLayer.anchorPoint = CGPointMake(0.0f, 1.0f); tiledLayer.delegate = self; tiledLayer.tileSize = CGSizeMake(1000, 1000); tiledLayer.levelsOfDetail = 6; tiledLayer.levelsOfDetailBias = 0; tiledLayer.bounds = pageRect; tiledLayer.transform = CATransform3DMakeScale(1.0f, -1.0f, 0.3f); myContentView = [[UIView alloc] initWithFrame:self.view.bounds]; [myContentView.layer addSublayer:tiledLayer]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; scrollView.delegate = self; scrollView.contentSize = pageRect.size; scrollView.minimumZoomScale = .2; scrollView.maximumZoomScale = 1; [scrollView addSubview:myContentView]; [self.view addSubview:scrollView]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return myContentView; } - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect imageRect = CGRectMake (0.0, 0.0, image.size.width, image.size.height); CGContextDrawImage (ctx, imageRect, [image CGImage]); } @end

    Read the article

  • Problem in encoding and decoding the string in Iphone sdk

    - by monish
    HI Guys, Here I am having a problem In encoding/decoding the strings. Actually I had a string which I am encoding it using the base64.which was working fine. And now I need to decode the string that was encoded before and want to print it. I code I written as: I imported the base64.h and base64.m files into my application which contains the methods as: + (NSData *) dataWithBase64EncodedString:(NSString *) string; - (id) initWithBase64EncodedString:(NSString *) string; - (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength; And the code in my view controller where I encode the String is: - (id)init { if (self = [super init]) { // Custom initialization userName = @"Sekhar"; password = @"Bethalam"; } return self; } -(void)reloadView { NSString *authStr = [NSString stringWithFormat:@"%@:%@",userName,password]; NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding]; NSString *authValue = [NSString stringWithFormat:@"%@", [authData base64EncodingWithLineLength:30]]; NSLog(authValue); //const char *str = authValue; //NSString *decStr = [StringEncryption DecryptString:authValue]; //NSLog(decStr); //NSData *decodeData = [NSData decode:authValue]; //NSString *decStr = [NSString stringWithFormat:@"%@",decodeData]; //NSStr //NSLog(decStr); } -(void)viewWillAppear:(BOOL)animated { [self reloadView]; } and now I want to decode the String that I encoded. But I dont know How to do that.can anyone suggest me with code how to get it. Anyone's help will be much appreciated. Thank you, Monish.

    Read the article

  • Why won't my CATiledLayer scroll in a UIScrollView after zooming?

    - by Brodie4598
    I'm currently having the following problem with CATiledLayer: when the view first loads, the scrolling works perfectly, but then when you zoom once, the view snaps to the anchor point (top left corner) and it can no longer scroll at all. The zooming works in that it will zoom in and out, but it will only zoom to the top left corner. My code is as follows: #import <QuartzCore/QuartzCore.h> #import "PracticeViewController.h" @implementation practiceViewController //@synthesize image; - (void)viewDidLoad { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect pageRect = CGRectMake(0, 0, image.size.width, image.size.height); CATiledLayer *tiledLayer = [CATiledLayer layer]; tiledLayer.anchorPoint = CGPointMake(0.0f, 1.0f); tiledLayer.delegate = self; tiledLayer.tileSize = CGSizeMake(1000, 1000); tiledLayer.levelsOfDetail = 6; tiledLayer.levelsOfDetailBias = 0; tiledLayer.bounds = pageRect; tiledLayer.transform = CATransform3DMakeScale(1.0f, -1.0f, 0.3f); myContentView = [[UIView alloc] initWithFrame:self.view.bounds]; [myContentView.layer addSublayer:tiledLayer]; UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; scrollView.delegate = self; scrollView.contentSize = pageRect.size; scrollView.minimumZoomScale = .2; scrollView.maximumZoomScale = 1; [scrollView addSubview:myContentView]; [self.view addSubview:scrollView]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return myContentView; } - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; NSData *data = [NSData dataWithContentsOfFile:path]; image = [UIImage imageWithData:data]; CGRect imageRect = CGRectMake (0.0, 0.0, image.size.width, image.size.height); CGContextDrawImage (ctx, imageRect, [image CGImage]); } @end

    Read the article

  • Core Data, Bindings, value transformers : crash when saving

    - by Gael
    Hi, I am trying to store a PNG image in a core data store backed by an sqlite database. Since I intend to use this database on an iPhone I can't store NSImage objects directly. I wanted to use bindings and an NSValueTransformer subclass to handle the transcoding from the NSImage (obtained by an Image well on my GUI) to an NSData containing the PNG binary representation of the image. I wrote the following code for the ValueTransformer : + (Class)transformedValueClass { return [NSImage class]; } + (BOOL)allowsReverseTransformation { return YES; } - (id)transformedValue:(id)value { if (value == nil) return nil; return [[[NSImage alloc] initWithData:value] autorelease]; } - (id)reverseTransformedValue:(id)value { if (value == nil) return nil; if(![value isKindOfClass:[NSImage class]]) { NSLog(@"Type mismatch. Expecting NSImage"); } NSBitmapImageRep *bits = [[value representations] objectAtIndex: 0]; NSData *data = [bits representationUsingType:NSPNGFileType properties:nil]; return data; } The model has a transformable property configured with this NSValueTransformer. In Interface Builder a table column and an image well are both bound to this property and both have the proper value transformer name (an image dropped in the image well shows up in the table column). The transformer is registered and called every time an image is added or a row is reloaded (checked with NSLog() calls). The problem arises when I am trying to save the managed objects. The console output shows the error message : [NSImage length]: unrecognized selector sent to instance 0x1004933a0 It seems like core data is using the value transformer to obtain the NSImage back from the NSData and then tries to save the NSImage instead of the NSData. There are probably workarounds such as the one presented in this post but I would really like to understand why my approach is flawn. Thanks in advance for your ideas and explanations.

    Read the article

  • a + sing in email address

    - by d.andreykiv
    Hi. I need to submit an email address with a "+" sign and validate in on server. But server receives email like "[email protected]" as "aaa [email protected]". I send all data as POST request with following code NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", url, @"/signUp"]]; NSString *post = [NSString stringWithFormat:@"&email=%@&userName=%@&password=%@", user.email, user.userName, user.password]; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO]; NSData* data = [self sendRequest:url postData:postData]; post variable before encoding has value &[email protected]&userName=Asdfasdfadsfadsf&password=sdfasdf after encoding it is same &[email protected]&userName=Asdfasdfadsfadsf&password=sdfasdf Method I use to send request looks like following code: -(id) sendRequest:(NSURL*) url postData:(NSData*)postData { // Create request NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]]; [request setURL:url]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody:postData]; NSURLResponse *urlResponse; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:nil]; [request release]; return data; }

    Read the article

  • XCode iPhone Programming: Loading a jpg into a UIImageView from URL

    - by Antonio Murgia
    My app has to load an image from a http server and displaying it into an UIImageView How can i do that?? I tried this: NSString *temp = [NSString alloc]; [temp stringwithString:@"http://192.168.1.2x0/pic/LC.jpg"] temp=[(NSString *)CFURLCreateStringByAddingPercentEscapes( nil, (CFStringRef)temp, NULL, NULL, kCFStringEncodingUTF8) autorelease]; NSData *dato = [NSData alloc]; dato=[NSData dataWithContentsOfURL:[NSURL URLWithString:temp]]; pic = [pic initWithImage:[UIImage imageWithData:dato]]; This code is in viewdidload of the view but nothing is displayed! The server is working because i can load xml files from it. but i can't display that image! I need to load the image programmatically because it has to change depending on the parameter passed! Thank you in advance. Antonio

    Read the article

  • JSON + 3des encrypt dosen't work

    - by oscurodrago
    i'm trying to pass some JSON data encrypted to my app but seem when i decrypt it my script add some 00 to hexe code making it impossible to be serialized i've tried to pass data uncrypted and crypted and the only difference i found is 00 at the end that is how i read JSON if isn't Encrypted NSLog(@"A) %@", response ); NSMutableArray *json = [NSJSONSerialization JSONObjectWithData:response options:kNilOptions error:&error]; NSLog(@"B) %@", error); that is NSLog Output 2012-03-28 00:43:58.399 VGCollect[5583:f803] A) <5b7b2274 69746c65 223a2252 696c6173 63696174 61206c61 20707269 6d612045 7370616e 73696f6e 65206469 20526167 6e61726f 6b204f64 79737365 79222c22 63617465 676f7279 223a225b 20505356 69746120 5d222c22 696d6755 726c223a 22494d41 4745535c 2f323031 325c2f30 335c2f30 30303038 3536345f 31353078 38302e6a 7067227d 2c7b2274 69746c65 223a2250 68616e74 61737920 53746172 204f6e6c 696e6520 3220616e 63686520 73752069 4f532065 20416e64 726f6964 20222c22 63617465 676f7279 223a225b 20495048 4f4e452c 2050432c 20505356 69746120 5d222c22 696d6755 726c223a 22494d41 4745535c 2f323031 325c2f30 335c2f30 30303038 3437355f 31353078 38302e6a 7067227d 2c7b2274 69746c65 223a2250 72696d69 20536372 65656e73 686f7420 696e2061 6c747261 20726973 6f6c757a 696f6e65 20706572 202e6861 636b5c2f 5c2f7665 72737573 222c2263 61746567 6f727922 3a225b20 50533320 5d222c22 696d6755 726c223a 22494d41 4745535c 2f323031 325c2f30 335c2f30 30303038 3437325f 31353078 38302e6a 7067227d 2c7b2274 69746c65 223a2269 6c206e75 6f766f20 444c4320 64692046 696e616c 2046616e 74617379 20584949 492d3220 636f6e66 65726d61 746f2061 6e636865 20696e20 416d6572 69636122 2c226361 7465676f 7279223a 225b2050 53332c20 58333630 205d222c 22696d67 55726c22 3a22494d 41474553 5c2f3230 31325c2f 30335c2f 30303030 38343439 5f313530 7838302e 6a706722 7d2c7b22 7469746c 65223a22 52656769 73747261 746f2069 6c206d61 72636869 6f205461 6c657320 6f662058 696c6c69 6120696e 20457572 6f706122 2c226361 7465676f 7279223a 225b2050 5333205d 222c2269 6d675572 6c223a22 494d4147 45535c2f 32303132 5c2f3033 5c2f3030 30303834 34385f31 35307838 302e6a70 67227d2c 7b227469 746c6522 3a225376 656c6174 69202e68 61636b5c 2f5c2f56 65727375 732e2065 202e6861 636b5c2f 5c2f5365 6b616920 6e6f204d 756b6f75 206e6922 2c226361 7465676f 7279223a 225b2050 5333205d 222c2269 6d675572 6c223a22 494d4147 45535c2f 32303132 5c2f3033 5c2f3030 30303834 33345f31 35307838 302e6a70 67227d2c 7b227469 746c6522 3a22476f 6e205061 6b752050 616b7520 50616b75 2050616b 75204164 76656e74 75726520 756e206e 756f766f 2067696f 636f2064 69204e61 6d636f20 42616e64 6169222c 22636174 65676f72 79223a22 5b203344 53205d22 2c22696d 6755726c 223a2249 4d414745 535c2f32 3031325c 2f30335c 2f303030 30383432 385f3135 30783830 2e6a7067 227d2c7b 22746974 6c65223a 224e756f 76652069 6d6d6167 696e6920 6520696e 666f2064 69204669 72652045 6d626c65 6d204177 616b656e 696e6722 2c226361 7465676f 7279223a 225b2033 4453205d 222c2269 6d675572 6c223a22 494d4147 45535c2f 32303132 5c2f3033 5c2f3030 30303834 31365f31 35307838 302e6a70 67227d2c 7b227469 746c6522 3a225072 696d6520 696d6d61 67696e69 20646569 206e756f 76692044 4c432064 69204669 6e616c20 46616e74 61737920 58494949 2d32222c 22636174 65676f72 79223a22 5b205053 332c2058 33363020 5d222c22 696d6755 726c223a 22494d41 4745535c 2f323031 325c2f30 335c2f30 30303038 3431325f 31353078 38302e6a 7067227d 2c7b2274 69746c65 223a2249 6e206172 7269766f 20717565 73746f20 41757475 6e6e6f20 45706963 204d6963 6b657920 323a2054 68652050 6f776572 206f6620 54776f22 2c226361 7465676f 7279223a 225b2050 53332c20 5769692c 20583336 30205d22 2c22696d 6755726c 223a2249 4d414745 535c2f32 3031325c 2f30335c 2f303030 30383430 385f3135 30783830 2e6a7067 227d5d> 2012-03-28 00:43:58.410 VGCollect[5583:f803] B) (null) instead that is how i serialize my crypted JSON NSData *decryptBase64 = [GTMBase64 decodeData:response]; NSData *decrypt3DES = [Crypt TripleDES:decryptBase64 encryptOrDecrypt:kCCDecrypt key:@"2b9534b45611cbb2436e625d"]; NSLog(@"A) %@", decrypt3DES ); NSMutableArray *json = [NSJSONSerialization JSONObjectWithData:decrypt3DES options:kNilOptions error:&error]; NSLog(@"B) %@", error); and that is the NSLog output 2012-03-28 00:41:51.525 VGCollect[5529:f803] A) <5b7b2274 69746c65 223a2252 696c6173 63696174 61206c61 20707269 6d612045 7370616e 73696f6e 65206469 20526167 6e61726f 6b204f64 79737365 79222c22 63617465 676f7279 223a225b 20505356 69746120 5d222c22 696d6755 726c223a 22494d41 4745535c 2f323031 325c2f30 335c2f30 30303038 3536345f 31353078 38302e6a 7067227d 2c7b2274 69746c65 223a2250 68616e74 61737920 53746172 204f6e6c 696e6520 3220616e 63686520 73752069 4f532065 20416e64 726f6964 20222c22 63617465 676f7279 223a225b 20495048 4f4e452c 2050432c 20505356 69746120 5d222c22 696d6755 726c223a 22494d41 4745535c 2f323031 325c2f30 335c2f30 30303038 3437355f 31353078 38302e6a 7067227d 2c7b2274 69746c65 223a2250 72696d69 20536372 65656e73 686f7420 696e2061 6c747261 20726973 6f6c757a 696f6e65 20706572 202e6861 636b5c2f 5c2f7665 72737573 222c2263 61746567 6f727922 3a225b20 50533320 5d222c22 696d6755 726c223a 22494d41 4745535c 2f323031 325c2f30 335c2f30 30303038 3437325f 31353078 38302e6a 7067227d 2c7b2274 69746c65 223a2269 6c206e75 6f766f20 444c4320 64692046 696e616c 2046616e 74617379 20584949 492d3220 636f6e66 65726d61 746f2061 6e636865 20696e20 416d6572 69636122 2c226361 7465676f 7279223a 225b2050 53332c20 58333630 205d222c 22696d67 55726c22 3a22494d 41474553 5c2f3230 31325c2f 30335c2f 30303030 38343439 5f313530 7838302e 6a706722 7d2c7b22 7469746c 65223a22 52656769 73747261 746f2069 6c206d61 72636869 6f205461 6c657320 6f662058 696c6c69 6120696e 20457572 6f706122 2c226361 7465676f 7279223a 225b2050 5333205d 222c2269 6d675572 6c223a22 494d4147 45535c2f 32303132 5c2f3033 5c2f3030 30303834 34385f31 35307838 302e6a70 67227d2c 7b227469 746c6522 3a225376 656c6174 69202e68 61636b5c 2f5c2f56 65727375 732e2065 202e6861 636b5c2f 5c2f5365 6b616920 6e6f204d 756b6f75 206e6922 2c226361 7465676f 7279223a 225b2050 5333205d 222c2269 6d675572 6c223a22 494d4147 45535c2f 32303132 5c2f3033 5c2f3030 30303834 33345f31 35307838 302e6a70 67227d2c 7b227469 746c6522 3a22476f 6e205061 6b752050 616b7520 50616b75 2050616b 75204164 76656e74 75726520 756e206e 756f766f 2067696f 636f2064 69204e61 6d636f20 42616e64 6169222c 22636174 65676f72 79223a22 5b203344 53205d22 2c22696d 6755726c 223a2249 4d414745 535c2f32 3031325c 2f30335c 2f303030 30383432 385f3135 30783830 2e6a7067 227d2c7b 22746974 6c65223a 224e756f 76652069 6d6d6167 696e6920 6520696e 666f2064 69204669 72652045 6d626c65 6d204177 616b656e 696e6722 2c226361 7465676f 7279223a 225b2033 4453205d 222c2269 6d675572 6c223a22 494d4147 45535c2f 32303132 5c2f3033 5c2f3030 30303834 31365f31 35307838 302e6a70 67227d2c 7b227469 746c6522 3a225072 696d6520 696d6d61 67696e69 20646569 206e756f 76692044 4c432064 69204669 6e616c20 46616e74 61737920 58494949 2d32222c 22636174 65676f72 79223a22 5b205053 332c2058 33363020 5d222c22 696d6755 726c223a 22494d41 4745535c 2f323031 325c2f30 335c2f30 30303038 3431325f 31353078 38302e6a 7067227d 2c7b2274 69746c65 223a2249 6e206172 7269766f 20717565 73746f20 41757475 6e6e6f20 45706963 204d6963 6b657920 323a2054 68652050 6f776572 206f6620 54776f22 2c226361 7465676f 7279223a 225b2050 53332c20 5769692c 20583336 30205d22 2c22696d 6755726c 223a2249 4d414745 535c2f32 3031325c 2f30335c 2f303030 30383430 385f3135 30783830 2e6a7067 227d5d00> 2012-03-28 00:41:51.530 VGCollect[5529:f803] B) Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Garbage at end.) UserInfo=0x6ccdd40 {NSDebugDescription=Garbage at end.} as u can see the only difference between 2 NSlogs is 00 at the end of second hexcode and the error on serialization of it do u know how fix that ? idk if is needed, that is my script for encrypt data +(NSData*)TripleDES:(NSData*)plainData encryptOrDecrypt:(CCOperation)encryptOrDecrypt key:(NSString*)key { const void *vplainText; size_t plainTextBufferSize; plainTextBufferSize = [plainData length]; vplainText = (const void *)[plainData bytes]; CCCryptorStatus ccStatus; uint8_t *bufferPtr = NULL; size_t bufferPtrSize = 0; size_t movedBytes = 0; // uint8_t ivkCCBlockSize3DES; bufferPtrSize = (plainTextBufferSize + kCCBlockSize3DES) & ~(kCCBlockSize3DES - 1); bufferPtr = malloc( bufferPtrSize * sizeof(uint8_t)); memset((void *)bufferPtr, 0x0, bufferPtrSize); // memset((void *) iv, 0x0, (size_t) sizeof(iv)); // NSString *key = @"123456789012345678901234"; NSString *initVec = @"init Vec"; const void *vkey = (const void *) [key UTF8String]; const void *vinitVec = (const void *) [initVec UTF8String]; ccStatus = CCCrypt(encryptOrDecrypt, kCCAlgorithm3DES, (kCCOptionPKCS7Padding | kCCOptionECBMode) , vkey, //"123456789012345678901234", //key kCCKeySize3DES, vinitVec, //"init Vec", //iv, vplainText, //"Your Name", //plainText, plainTextBufferSize, (void *)bufferPtr, bufferPtrSize, &movedBytes); NSData *result = [NSData dataWithBytes:(const void *)bufferPtr length:(NSUInteger)movedBytes]; return result; }

    Read the article

  • UIImagePickerController Causes my app to crash!

    - by Flafla2
    In my app, a user can select an image, change the picture of a UIImageView to the new imge, and save the image to NSUserDefaults using NSKeyedArchiver. When the user selects the image the app immediately crashes! Here is my code - - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; if ([[NSUserDefaults standardUserDefaults] integerForKey:@"PictureKey"] == 1) { UIImage *previmage = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; [prevbutton setImage:previmage]; NSData *previmagedata = [NSKeyedArchiver archivedDataWithRootObject:previmage]; [[NSUserDefaults standardUserDefaults] setObject:previmagedata forKey:@"PrevImage"]; } else if ([[NSUserDefaults standardUserDefaults] integerForKey:@"PictureKey"] == 2) { UIImage *nextimage = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; [nextbutton setImage:nextimage]; NSData *nextimagedata = [NSKeyedArchiver archivedDataWithRootObject:nextimage]; [[NSUserDefaults standardUserDefaults] setObject:nextimagedata forKey:@"NextImage"]; }else { UIImage *optionsimage = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; [moreoptionsbutton setImage:optionsimage]; NSData *optimagedata = [NSKeyedArchiver archivedDataWithRootObject:optionsimage]; [[NSUserDefaults standardUserDefaults] setObject:optimagedata forKey:@"OptionsImage"]; } } Thanks in advance!

    Read the article

  • NSURLConnection performance

    - by oksk
    Hi all, I'm using NSURLConnection for downloading some images in my app currently. Before implementing via this, I implemented it by NSData(dataWithContentOfURL) in NSThread. But I wanted to cancel during downloading images, So I changed it to NSURLConnection. But It happens other problem. Performance was very low after changing. For example, There is at least 5seconds for downloading images at NSThread(NSData async) But, There is more than 2 or 3 times than it at NSURLConnection(async) !! Can I enhance performance ?? How?? (* sorry about my question with NSData(dataWithContentOfFile). correct question is dataWithContentOfURL)

    Read the article

  • If url exists Objective-c

    - by HiGuy Smith
    Hey, I have a program that needs to tell if an online image exists, but the only way that I've gotten this to work is by loading the image in a NSData pointer and checking if the pointer exists. - (BOOL)exists { NSString *filePath = @"http://couleeapps.hostei.com/BottomBox.png"; NSURL *url = [NSURL URLWithString:filePath]; NSData *imageData = [NSData dataWithContentsOfURL:url]; if (imageData) { return YES; } return NO; } This has worked for me, but my problem is that I have a very slow connection, and it takes forever to download the image. So my question is: is there a way to check if a image (say "http://couleeapps.hostei.com/BottomBox.png") is available without having to download it? Help is much appreciated HiGuy

    Read the article

  • POST and multiple submit buttons on form (iphone)

    - by Jonathan
    NSString *reqURL = [NSString stringWithFormat:@"%@/login",SERVER_URL]; NSMutableURLRequest *req = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:reqURL]]; [req setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; NSData *myRequestData = [NSData dataWithBytes:[@"username=whatever&password=whatever" UTF8String] length: [@"username=whatever&password=whatever" length]]; [req setHTTPMethod: @"POST"]; [req setHTTPBody: myRequestData]; NSData *returnData = [NSURLConnection sendSynchronousRequest:req returningResponse: nil error: nil]; NSString *html = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; I got this code from another question I asked. But what happens if there is more than one submit button. I really have no idea how to ask this question. An example of such situation is on the logout page for this site. There are no fields to enter data into, but there are 2 submit buttons. How can I "simulate clicking" on one of those buttons using code like the above (so not using a UIWebView)

    Read the article

  • Sending a message from Objective-C and getting the return value?

    - by Nick Brooks
    I have this code NSString *tr = [self sendUrl:@"http://google.com/"]; But for some reason 'tr' will remain nil after it is executed. What am I doing wrong? sendUrl : - (NSString *)sendUrl:(NSString *) uri { NSLog(@"Requesting URI 1 ..."); // Prepare URL request to download statuses from Twitter NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:uri]]; NSLog(@"Requesting URI 2 ..."); // Perform request and get JSON back as a NSData object NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSLog(@"Requesting URI 3 ..."); // Get JSON as a NSString from NSData response NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; NSLog(@"Requesting URI 4 ..."); return json_string; }

    Read the article

  • how to delete a image from iphone application

    - by pankaj
    I am working an iphone app where i am giving the option of downloading an image to user's iphone. Following is my code for downloading of image. UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlAddress]]]; NSString *pngFilePath = [[[NSString stringWithFormat:@"%@/",docDir] stringByAppendingString:[NSString stringWithFormat:@"%@",couponID]] stringByAppendingString:@".png"]; NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)]; [data1 writeToFile:pngFilePath atomically:YES]; My above code works fine but now i want to give option of deleting the image downloaded from above code. Can some one please advice me how can i delete a image file from iphone.

    Read the article

  • How can I get the JSON array data from nsstring or byte in xcode 4.2?

    - by user1471568
    I'm trying to get values from nsdata class and doesn't work. here is my JSON data. { "count": 3, "item": [{ "id": "1", "latitude": "37.556811", "longitude": "126.922015", "imgUrl": "http://175.211.62.15/sample_res/1.jpg", "found": false }, { "id": "3", "latitude": "37.556203", "longitude": "126.922629", "imgUrl": "http://175.211.62.15/sample_res/3.jpg", "found": false }, { "id": "2", "latitude": "37.556985", "longitude": "126.92286", "imgUrl": "http://175.211.62.15/sample_res/2.jpg", "found": false }] } and here is my code -(NSDictionary *)getDataFromItemList { NSData *dataBody = [[NSData alloc] initWithBytes:buffer length:sizeof(buffer)]; NSDictionary *iTem = [[NSDictionary alloc]init]; iTem = [NSJSONSerialization JSONObjectWithData:dataBody options:NSJSONReadingMutableContainers error:nil]; NSLog(@"id = %@",[iTem objectForKey:@"id"]); //for Test output = [[NSString alloc] initWithBytes:buffer length:rangeHeader.length encoding:NSUTF8StringEncoding]; NSLog(@"%@",output); return iTem; } how can I access every value in the JSON? Please help me.

    Read the article

  • Resolving html entities with NSXMLParse on iPhone

    - by Roberto
    Hi all, i think i read every single web page relating to this problem but i still cannot find a solution to it, so here i am. I have an HTML web page wich is not under my control and i need to parse it from my iPhone application. Here it is a sample of the web page i'm talking about: <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> </HEAD> <BODY> <LI class="bye bye" rel="hello 1"> <H5 class="onlytext"> <A name="morning_part">morning</A> </H5> <DIV class="mydiv"> <SPAN class="myclass">something about you</SPAN> <SPAN class="anotherclass"> <A href="http://www.google.it">Bye Bye &egrave; un saluto</A> </SPAN> </DIV> </LI> </BODY> </HTML> I'm using NSXMLParser and it is going well till it find the è html entity. It calls foundCharacters: for "Bye Bye" and then it calls resolveExternalEntityName:systemID:: with an entityName of "egrave". In this method i'm just returning the character "è" trasformed in an NSData, the foundCharacters is called again adding the string "è" to the previous one "Bye Bye " and then the parser raise the NSXMLParserUndeclaredEntityError error. I have no DTD and i cannot change the html file i'm parsing. Do you have any ideas on this problem? Thanks in advance to all of you, Rob. Update (12/03/2010). After the suggestion of Griffo i ended up with something like this: data = [self replaceHtmlEntities:data]; NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; [parser setDelegate:self]; [parser parse]; where replaceHtmlEntities:(NSData *) is something like this: - (NSData *)replaceHtmlEntities:(NSData *)data { NSString *htmlCode = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding]; NSMutableString *temp = [NSMutableString stringWithString:htmlCode]; [temp replaceOccurrencesOfString:@"&amp;" withString:@"&" options:NSLiteralSearch range:NSMakeRange(0, [temp length])]; [temp replaceOccurrencesOfString:@"&nbsp;" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [temp length])]; ... [temp replaceOccurrencesOfString:@"&Agrave;" withString:@"À" options:NSLiteralSearch range:NSMakeRange(0, [temp length])]; NSData *finalData = [temp dataUsingEncoding:NSISOLatin1StringEncoding]; return finalData; } But i am still looking the best way to solve this problem. I will try TouchXml in the next days but i still think that there should be a way to do this using NSXMLParser API, so if you know how, feel free to write it here :)

    Read the article

  • Why does Keychain Services return the wrong keychain content?

    - by Graham Lee
    I've been trying to use persistent keychain references in an iPhone application. I found that if I created two different keychain items, I would get a different persistent reference each time (they look like 'genp.......1', 'genp.......2', …). However, attempts to look up the items by persistent reference always returned the content of the first item. Why should this be? I confirmed that my keychain-saving code was definitely creating new items in each case (rather than updating existing items), and was not getting any errors. And as I say, Keychain Services is giving a different persistent reference for each item. I've managed to solve my immediate problem by searching for keychain items by attribute rather than persistent references, but it would be easier to use persistent references so I'd appreciate solving this problem. Here's my code: - (NSString *)keychainItemWithName: (NSString *)name { NSString *path = [GLApplicationSupportFolder() stringByAppendingPathComponent: name]; NSData *persistentRef = [NSData dataWithContentsOfFile: path]; if (!persistentRef) { NSLog(@"no persistent reference for name: %@", name); return nil; } NSArray *refs = [NSArray arrayWithObject: persistentRef]; //get the data CFMutableDictionaryRef params = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFDictionaryAddValue(params, kSecMatchItemList, refs); CFDictionaryAddValue(params, kSecClass, kSecClassGenericPassword); CFDictionaryAddValue(params, kSecReturnData, kCFBooleanTrue); CFDataRef item = NULL; OSStatus result = SecItemCopyMatching(params, (CFTypeRef *)&item); CFRelease(params); if (result != errSecSuccess) { NSLog(@"error %d retrieving keychain reference for name: %@", result, name); return nil; } NSString *token = [[NSString alloc] initWithData: (NSData *)item encoding: NSUTF8StringEncoding]; CFRelease(item); return [token autorelease]; } - (void)setKeychainItem: (NSString *)newToken forName: (NSString *)name { NSData *tokenData = [newToken dataUsingEncoding: NSUTF8StringEncoding]; //firstly, find out whether the item already exists NSDictionary *searchAttributes = [NSDictionary dictionaryWithObjectsAndKeys: name, kSecAttrAccount, kCFBooleanTrue, kSecReturnAttributes, nil]; NSDictionary *foundAttrs = nil; OSStatus searchResult = SecItemCopyMatching((CFDictionaryRef)searchAttributes, (CFTypeRef *)&foundAttrs); if (noErr == searchResult) { NSMutableDictionary *toStore = [foundAttrs mutableCopy]; [toStore setObject: tokenData forKey: (id)kSecValueData]; OSStatus result = SecItemUpdate((CFDictionaryRef)foundAttrs, (CFDictionaryRef)toStore); if (result != errSecSuccess) { NSLog(@"error %d updating keychain", result); } [toStore release]; return; } //need to create the item. CFMutableDictionaryRef params = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFDictionaryAddValue(params, kSecClass, kSecClassGenericPassword); CFDictionaryAddValue(params, kSecAttrAccount, name); CFDictionaryAddValue(params, kSecReturnPersistentRef, kCFBooleanTrue); CFDictionaryAddValue(params, kSecValueData, tokenData); NSData *persistentRef = nil; OSStatus result = SecItemAdd(params, (CFTypeRef *)&persistentRef); CFRelease(params); if (result != errSecSuccess) { NSLog(@"error %d from keychain services", result); return; } NSString *path = [GLApplicationSupportFolder() stringByAppendingPathComponent: name]; [persistentRef writeToFile: path atomically: NO]; [persistentRef release]; }

    Read the article

  • UIWebView get HTML Source

    - by Alexandre Cassagne
    Hi I am trying to get the HTML source of a UIWebView without re-downloading it again (a.k.a. do another download, such as [NSData dataWithContentsOfURL:(NSURL*)URL] or launching an NSURLRequest. Browsing the UIWebView header and documentation, there seems to be no way of accessing the current loaded NSData of the source. Am I missing something ?

    Read the article

  • iPhone 3DES encryption key length issue

    - by Russell Hill
    Hi, I have been banging my head on a wall with this one. I need to code my iPhone application to encrypt a 4 digit "pin" using 3DES in ECB mode for transmission to a webservice which I believe is written in .NET. + (NSData *)TripleDESEncryptWithKey:(NSString *)key dataToEncrypt:(NSData*)encryptData { NSLog(@"kCCKeySize3DES=%d", kCCKeySize3DES); char keyBuffer[kCCKeySize3DES+1]; // room for terminator (unused) bzero( keyBuffer, sizeof(keyBuffer) ); // fill with zeroes (for padding) [key getCString: keyBuffer maxLength: sizeof(keyBuffer) encoding: NSUTF8StringEncoding]; // encrypts in-place, since this is a mutable data object size_t numBytesEncrypted = 0; size_t returnLength = ([encryptData length] + kCCBlockSize3DES) & ~(kCCBlockSize3DES - 1); // NSMutableData* returnBuffer = [NSMutableData dataWithLength:returnLength]; char* returnBuffer = malloc(returnLength * sizeof(uint8_t) ); CCCryptorStatus ccStatus = CCCrypt(kCCEncrypt, kCCAlgorithm3DES , kCCOptionECBMode, keyBuffer, kCCKeySize3DES, nil, [encryptData bytes], [encryptData length], returnBuffer, returnLength, &numBytesEncrypted); if (ccStatus == kCCParamError) NSLog(@"PARAM ERROR"); else if (ccStatus == kCCBufferTooSmall) NSLog(@"BUFFER TOO SMALL"); else if (ccStatus == kCCMemoryFailure) NSLog(@"MEMORY FAILURE"); else if (ccStatus == kCCAlignmentError) NSLog(@"ALIGNMENT"); else if (ccStatus == kCCDecodeError) NSLog(@"DECODE ERROR"); else if (ccStatus == kCCUnimplemented) NSLog(@"UNIMPLEMENTED"); if(ccStatus == kCCSuccess) { NSLog(@"TripleDESEncryptWithKey encrypted: %@", [NSData dataWithBytes:returnBuffer length:numBytesEncrypted]); return [NSData dataWithBytes:returnBuffer length:numBytesEncrypted]; } else return nil; } } I do get a value encrypted using the above code, however it does not match the value from the .NET web service. I believe the issue is that the encryption key I have been supplied by the web service developers is 48 characters long. I see that the iPhone SDK constant "kCCKeySize3DES" is 24. So I SUSPECT, but don't know, that the commoncrypto API call is only using the first 24 characters of the supplied key. Is this correct? Is there ANY way I can get this to generate the correct encrypted pin? I have output the data bytes from the encryption PRIOR to base64 encoding it and have attempted to match this against those generated from the .NET code (with the help of a .NET developer who sent the byte array output to me). Neither the non-base64 encoded byte array nor the final base64 encoded strings match.

    Read the article

  • Reading .ppt (MS PowerPoint) file in Cocoa Touch

    - by Biranchi
    Hi All, Any idea how to read a .ppt file in Cocoa Touch ? I tried to load the contents of the file in UIWebView but it didn't work. Here is the code : [aWebView loadData:[NSData dataWithContentsOfFile:filePath] MIMEType:@"application/vnd.ms-powerpoint" textEncodingName:@"utf-8" baseURL:[NSURL fileURLWithPath:filePath]]; [powerWeb loadData:[NSData dataWithContentsOfFile:filePath] MIMEType:@"application/vnd.ms-powerpoint" textEncodingName:@"utf-8" baseURL:[NSURL fileURLWithPath:filePath]]; All suggestions are highly appreciated. Thanks

    Read the article

  • Objective-C memory leak in loading remote content

    - by Ican Zilb
    I try to load a plist file from my server. I can think of 2 ways to do that, but for both Instruments says there's huge memory leak : NSData* plistData = [NSData dataWithContentsOfURL:url]; and NSDictionary* updateDigest = [NSDictionary dictionaryWithContentsOfURL: [NSURL URLWithString:updateURL] ]; The backtrace of the memory leak leads to __CFURLCache in CFNetwork and I am wondering if something can be done to fix the leak? Any other way to load a remote plist xml, without the memory leakage ? Thanks

    Read the article

  • Problem with writeData

    - by zp26
    Hi, I have a problem with my code. I want to create a XML file like this: <name>myName<name> <x>myX<x> <y>myY<y> <z>myZ<z> but my file is: <name>myName<name><x>myX<x><y>myY<y><z>myZ<z> Can i have this text formatting? This is my code: -(void)salvataggioInXML:(NSString*)name:(float)x:(float)y:(float)z{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectoryPath stringByAppendingPathComponent:@"filePosizioni.xml"]; NSFileHandle *myHandle = [NSFileHandle fileHandleForUpdatingAtPath:filePath]; [myHandle seekToEndOfFile]; NSString *tagName = [NSString stringWithFormat:@"<name>%@<name>", name]; NSString *tagX = [NSString stringWithFormat:@"<x>%f<x>", name]; NSString *tagY = [NSString stringWithFormat:@"<y>%f<y>", name]; NSString *tagZ = [NSString stringWithFormat:@"<z>%f<z>", name]; NSData* dataName = [tagName dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataX = [tagX dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataY = [tagY dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataZ = [tagZ dataUsingEncoding: NSASCIIStringEncoding]; [myHandle writeData:dataName]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataX]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataY]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataZ]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; NSLog(@"zp26 %@",filePath); }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >