Search Results

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

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

  • Displaying issue in Webview

    - by milanjansari
    Hello, i did save png and pdf file in Sqlite successfully. but when i retrive png and pdf data from sqlite and trying to display in Webview its create a problem. for exp NSData *data = [[NSData alloc] initWithBytes:sqlite3_column_blob(selectstmt, 1) length:sqlite3_column_bytes(selectstmt, 3)]; [webview loadData:data MIMEType:@"image/png" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]]; but problem is there only see image tag not display image. any solution of below of the code. Thanks you

    Read the article

  • how to retrieve image from sqlite3?

    - by summer
    sorry guys..i know i had been asking alot of question..but ironically few has given me solution, and so now i really need a solution to the final part of my app?how to i retrieve image from sqlite to be display in the uiimageview?with conversion... NSData *imgData = [[NSData alloc] initWithBytes:sqlite3_column_blob(selectstmt, 3) length: sqlite3_column_bytes(selectstmt, 3)]; snap2playObj.snapImage = [UIImage imageWithData:imgData]; do i do it the normal way or do i need to convert it back to some string or something?kinda no clues..need some example or solution..and i wanna display it in my detailview

    Read the article

  • How to get ip address from NSNetService

    - by Vic
    When I get a NSNetService object, I try to do: NSNetService *ss=[netArray objectAtIndex:indexPath.row]; ss.delegate=self; [ss resolveWithTimeout:3.0]; Then on the delegate method: - (void)netServiceDidResolveAddress:(NSNetService *)sender { NSArray *address=sender.addresses; NSData *addressData=[NSData dataWithBytes:address length:sizeof(address)]; NSError *error; /* How? */ } Thanks.

    Read the article

  • Mac OS - Download an save an image file on HDD with Cocoa

    - by Julien
    I'm building a program, and I'm quite confident using Objective-C, but I don't know how to programmatically download a file from the web and copy it on the hard drive. I started with : NSString url = @"http://spiritofpolo.com/images/logo.png"; NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]]; But then I don't know what to do with the data... that sucks, no ;) Can somebody help?

    Read the article

  • what causes a bad token on iPhone- NSLog(@"token:%@",[devToken description]); crashes

    - by Grant M
    I am getting a bad token passed to me in - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken this code crashes on my iPhone but not my clients. - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken { NSLog(@"token:%@",[devToken description]); } I think something is wrong with my stored notifications settings on my iPhone but I can't find a way to delete them. deleting the app does not seem to do it.

    Read the article

  • Download an save an image file on HDD with Cocoa

    - by Julien
    I'm building a program, and I'm quite confident using Objective-C, but I don't know how to programmatically download a file from the web and copy it on the hard drive. I started with : NSString url = @"http://spiritofpolo.com/images/logo.png"; NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]]; But then I don't know what to do with the data... that sucks, no ;) Can somebody help?

    Read the article

  • Download HTML from website URL in objective C (iphone)

    - by Jonathan
    I'm trying to get the HTML data of a website so that I can parse it. I have parsing bit sorted out but using the following code doesn't seem to work: NSData *data = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString:@"http://thewebsite.net"]]; Is this the way I should be doing it or is there another way?

    Read the article

  • Play a wav file retrieved from a database on the iPhone?

    - by user312917
    I have alot of wav files stored in sqlite3, but when I retrieve one of them, I can't play it. The retrieve code is NSData *soundData = (NSDATA *)sqlite3_column_blob(statement, 0); mPlayer = [[AVAudioPlayer alloc] initWithData:soundData error:&error]; The data is stored as binary and it's there when I search for it using sqlite3.

    Read the article

  • Get nested data from local JSON file

    - by Lbase
    Now that I have the NSDictionary object JSONDictionary, how do I get the nested data inside of it? NSString *JSONFilePath = [[NSBundle mainBundle] pathForResource:@"sAPI" ofType:@"json"]; NSData *JSONData = [NSData dataWithContentsOfFile:JSONFilePath]; NSDictionary *JSONDictionary = [NSJSONSerialization JSONObjectWithData:JSONData options:kNilOptions error:nil]; NSLog(@"Dictionary: %@", JSONDictionary); sAPI.json snippet: { "ss": [{ "name": "bl", }, "ls": [{ "name": "ML", "abbreviation": "ml", "id": 10,

    Read the article

  • Application is crash..

    - by user338322
    Below is my crash Report. 0 0x326712f8 in prepareForMethodLookup () 1 0x3266cf5c in lookUpMethod () 2 0x32668f28 in objc_msgSend_uncached () 3 0x33f70996 in NSPopAutoreleasePool () 4 0x33f82a6c in -[NSAutoreleasePool drain] () 5 0x00003d3e in -[CameraViewcontroller save:] (self=0x811400, _cmd=0x319c00d4, number=0x11e210) at /Users/hardikrathore/Desktop/LiveVideoRecording/Classes/CameraViewcontroller.m:266 6 0x33f36f8a in __NSFireDelayedPerform () 7 0x32da44c2 in CFRunLoopRunSpecific () 8 0x32da3c1e in CFRunLoopRunInMode () 9 0x31bb9374 in GSEventRunModal () 10 0x30bf3c30 in -[UIApplication _run] () 11 0x30bf2230 in UIApplicationMain () 12 0x00002650 in main (argc=1, argv=0x2ffff474) at /Users/hardikrathore/Desktop/LiveVideoRecording/main.m:14 And this is the code. lines, where I am getting the error. -(void)save:(id)number { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; j =[number intValue]; while(screens[j] != NULL){ NSLog(@" image made : %d",j); UIImage * image = [UIImage imageWithCGImage:screens[j]]; image=[self imageByCropping:image toRect:CGRectMake(0, 0, 320, 240)]; NSData *imgdata = UIImageJPEGRepresentation(image,0.3); [image release]; CGImageRelease(screens[j]); screens[j] = NULL; UIImage * image1 = [UIImage imageWithCGImage:screens[j+1]]; image1=[self imageByCropping:image1 toRect:CGRectMake(0, 0, 320, 240)]; NSData *imgdata1 = UIImageJPEGRepresentation(image1,0.3); [image1 release]; CGImageRelease(screens[j+1]); screens[j+1] = NULL; NSString *urlString=@"http://www.test.itmate4.com/iPhoneToServerTwice.php"; // setting up the request object now NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSString *fileName=[VideoID stringByAppendingString:@"_"]; fileName=[fileName stringByAppendingString:[NSString stringWithFormat:@"%d",k]]; NSString *fileName2=[VideoID stringByAppendingString:@"_"]; fileName2=[fileName2 stringByAppendingString:[NSString stringWithFormat:@"%d",k+1]]; /* add some header info now we always need a boundary when we post a file also we need to set the content type You might want to generate a random boundary.. this is just the same as my output from wireshark on a valid html post */ NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"]; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; [request addValue:contentType forHTTPHeaderField: @"Content-Type"]; /* now lets create the body of the post */ //NSString *count=[NSString stringWithFormat:@"%d",front];; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; //[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; count=\"@\"";filename=\"%@.jpg\"\r\n",count,fileName] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@.jpg\"\r\n",fileName] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:imgdata]]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; //second boundary NSString *string1 = [[NSString alloc] initWithFormat:@"\r\n--%@\r\n",boundary]; NSString *string2 =[[NSString alloc] initWithFormat:@"Content-Disposition: form-data; name=\"userfile2\"; filename=\"%@.jpg\"\r\n",fileName2]; NSString *string3 =[[NSString alloc] initWithFormat:@"\r\n--%@--\r\n",boundary]; [body appendData:[string1 dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[string2 dataUsingEncoding:NSUTF8StringEncoding]]; //experiment //[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile2\"; filename=\"%@.jpg\"\r\n",fileName2] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:imgdata1]]; //[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[string3 dataUsingEncoding:NSUTF8StringEncoding]]; // setting the body of the post to the reqeust [request setHTTPBody:body]; // now lets make the connection to the web NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; if([returnString isEqualToString:@"SUCCESS"]) { NSLog(returnString); k=k+2; j=j+2; [self performSelectorInBackground:@selector(save:) withObject:(id)[NSNumber numberWithInt:j]]; } //k=k+2; [imgdata release]; [imgdata1 release]; [NSThread sleepForTimeInterval:.01]; } [pool drain]; <-------------Line 266 } As you can see in log report. I am getting the error, Line 266. Some autorelease problem Any help !!!? coz I am not getting why its happening.

    Read the article

  • iPhone: Crash in Custom Autorelease Pool

    - by user338322
    My app is crashing when I try to post images in an HTTP request. I am trying to upload images to a server. The crash appears related to my autorelease pool because the crash is trapped at the [pool release] message. Here is the crash report: #0 0x326712f8 in prepareForMethodLookup () #1 0x3266cf5c in lookUpMethod () #2 0x32668f28 in objc_msgSend_uncached () #3 0x33f70996 in NSPopAutoreleasePool () #4 0x33f82a6c in -[NSAutoreleasePool drain] () #5 0x00003d3e in -[CameraViewcontroller save:] (self=0x811400, _cmd=0x319c00d4, number=0x11e210) at /Users/hardikrathore/Desktop/LiveVideoRecording/Classes/CameraViewcontroller.m:266 #6 0x33f36f8a in __NSFireDelayedPerform () #7 0x32da44c2 in CFRunLoopRunSpecific () #8 0x32da3c1e in CFRunLoopRunInMode () #9 0x31bb9374 in GSEventRunModal () #10 0x30bf3c30 in -[UIApplication _run] () #11 0x30bf2230 in UIApplicationMain () #12 0x00002650 in main (argc=1, argv=0x2ffff474) at /Users/hardikrathore/Desktop/LiveVideoRecording/main.m:14 The crash report says that final line of the following code is the point of the crash. (Line No. 266) -(void)save:(id)number { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; j =[number intValue]; while(screens[j] != NULL){ NSLog(@" image made : %d",j); UIImage * image = [UIImage imageWithCGImage:screens[j]]; image=[self imageByCropping:image toRect:CGRectMake(0, 0, 320, 240)]; NSData *imgdata = UIImageJPEGRepresentation(image,0.3); [image release]; CGImageRelease(screens[j]); screens[j] = NULL; UIImage * image1 = [UIImage imageWithCGImage:screens[j+1]]; image1=[self imageByCropping:image1 toRect:CGRectMake(0, 0, 320, 240)]; NSData *imgdata1 = UIImageJPEGRepresentation(image1,0.3); [image1 release]; CGImageRelease(screens[j+1]); screens[j+1] = NULL; NSString *urlString=@"http://www.test.itmate4.com/iPhoneToServerTwice.php"; // setting up the request object now NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSString *fileName=[VideoID stringByAppendingString:@"_"]; fileName=[fileName stringByAppendingString:[NSString stringWithFormat:@"%d",k]]; NSString *fileName2=[VideoID stringByAppendingString:@"_"]; fileName2=[fileName2 stringByAppendingString:[NSString stringWithFormat:@"%d",k+1]]; /* add some header info now we always need a boundary when we post a file also we need to set the content type You might want to generate a random boundary.. this is just the same as my output from wireshark on a valid html post */ NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"]; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; [request addValue:contentType forHTTPHeaderField: @"Content-Type"]; /* now lets create the body of the post */ //NSString *count=[NSString stringWithFormat:@"%d",front];; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; //[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; count=\"@\"";filename=\"%@.jpg\"\r\n",count,fileName] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@.jpg\"\r\n",fileName] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:imgdata]]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; //second boundary NSString *string1 = [[NSString alloc] initWithFormat:@"\r\n--%@\r\n",boundary]; NSString *string2 =[[NSString alloc] initWithFormat:@"Content-Disposition: form-data; name=\"userfile2\"; filename=\"%@.jpg\"\r\n",fileName2]; NSString *string3 =[[NSString alloc] initWithFormat:@"\r\n--%@--\r\n",boundary]; [body appendData:[string1 dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[string2 dataUsingEncoding:NSUTF8StringEncoding]]; //experiment //[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile2\"; filename=\"%@.jpg\"\r\n",fileName2] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:imgdata1]]; //[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[string3 dataUsingEncoding:NSUTF8StringEncoding]]; // setting the body of the post to the reqeust [request setHTTPBody:body]; // now lets make the connection to the web NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; if([returnString isEqualToString:@"SUCCESS"]) { NSLog(returnString); k=k+2; j=j+2; [self performSelectorInBackground:@selector(save:) withObject:(id)[NSNumber numberWithInt:j]]; } [imgdata release]; [imgdata1 release]; [NSThread sleepForTimeInterval:.01]; } [pool drain]; //<-------------Line 266 } I don't understand what is causing the crash.

    Read the article

  • Parsing nested JSON objects with JSON Framework for Objective-C

    - by Sheehan Alam
    I have the following JSON object: { "response": { "status": 200 }, "messages": [ { "message": { "user": "value" "pass": "value", "url": "value" } ] } } I am using JSON-Framework (also tried JSON Touch) to parse through this and create a dictionary. I want to access the "message" block and pull out the "user", "pass" and "url" values. In Obj-C I have the following code: // Create new SBJSON parser object SBJSON *parser = [[SBJSON alloc] init]; // Prepare URL request to download statuses from Twitter NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]]; // Perform request and get JSON back as a NSData object NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; // Get JSON as a NSString from NSData response NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; //Print contents of json-string NSArray *statuses = [parser objectWithString:json_string error:nil]; NSLog(@"Array Contents: %@", [statuses valueForKey:@"messages"]); NSLog(@"Array Count: %d", [statuses count]); NSDictionary *results = [json_string JSONValue]; NSArray *tweets = [[results objectForKey:@"messages"] objectForKey:@"message"]; for (NSDictionary *tweet in tweets) { NSString *url = [tweet objectForKey:@"url"]; NSLog(@"url is: %@",url); } I can pull out "messages" and see all of the "message" blocks, but I am unable to parse deeper and pull out the "user", "pass", and "url".

    Read the article

  • Compress/Decompress NSString in objective-c (iphone) using GZIP or deflate

    - by Steven
    Hi, I have a web-service running on Windows Azure which returns JSON that I consume in my iPhone app. Unfortunately, Windows Azure doesn't seem to support the compression of dynamic responses yet (long story) so I decided to get around it by returning an uncompressed JSON package, which contains a compressed (using GZIP) string. e.g {"Error":null,"IsCompressed":true,"Success":true,"Value":"vWsAAB+LCAAAAAAAB..etc.."} ... where value is the compressed string of a complex object represented in JSON. This was really easy to implement on the server, but for the life of me I can't figure out how to decompress a gzipped NSString into an uncompressed NSString, all the examples I can find for zlib etc are dealing with files etc. Can anyone give me any clues on how to do this? (I'd also be happy for a solution that used deflate as I could change the server-side implementation to use deflate too). Thanks!! Steven Edit 1: Aaah, I see that ASIHTTPRequest is using the following function in it's source code: //uncompress gzipped data with zlib + (NSData *)uncompressZippedData:(NSData*)compressedData; ... and I'm aware that I can convert NSString to NSData, so I'll see if this leads me anywhere!

    Read the article

  • Using NSURLRequest to pass key-value pairs to PHP script with POST

    - by Ralf Mclaren
    Hi, I'm fairly new to objective-c, and am looking to pass a number of key-value pairs to a PHP script using POST. I'm using the following code but the data just doesn't seem to be getting posted through. I tried sending stuff through using NSData as well, but neither seem to be working. NSDictionary* data = [NSDictionary dictionaryWithObjectsAndKeys: @"bob", @"sender", @"aaron", @"rcpt", @"hi there", @"message", nil]; NSURL *url = [NSURL URLWithString:@"http://myserver.com/script.php"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:[NSData dataWithBytes:data length:[data count]]]; NSURLResponse *response; NSError *err; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err]; NSLog(@"responseData: %@", content); This is getting sent to this simple script to perform a db insert: <?php $sender = $_POST['sender']; $rcpt = $_POST['rcpt']; $message = $_POST['message']; //script variables include ("vars.php"); $con = mysql_connect($host, $user, $pass); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); mysql_query("INSERT INTO php_test (SENDER, RCPT, MESSAGE) VALUES ($sender, $rcpt, $message)"); echo "complete" ?> Any ideas?

    Read the article

  • iPhone POST to PHP failing

    - by Alexander
    I have this code here: NSString *post = [NSString stringWithFormat:@"deviceIdentifier=%@&deviceToken=%@",deviceIdentifier,deviceToken]; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:@"http://website.com/RegisterScript.php"]]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"MyApp-V1.0" forHTTPHeaderField:@"User-Agent"]; [request setHTTPBody:postData]; NSData *urlData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *response = [[NSString alloc] initWithData:urlData encoding:NSASCIIStringEncoding]; which should be sending data to my PHP server to register the device into our database, but for some of my users no POST data is being sent. I've been told that this line: NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO]; may be causing the problem. Any thoughts on why this script would sometimes not send the POST data? On the server I got the packet trace for a failed send and the Content-lenght came up as 0 so no data was sent at all. Thanks for any help

    Read the article

  • Can I load a UIImage from a URL?

    - by progrmr
    I have a URL for an image (got it from UIImagePickerController) but I no longer have the image in memory (the URL was saved from a previous run of the app). Can I reload the UIImage from the URL again? I see that UIImage has a imageWithContentsOfFile: but I have a URL. Can I use NSData's dataWithContentsOfURL: to read the URL? EDIT based on @Daniel's answer I tried the following code but it doesn't work... NSLog(@"%s %@", __PRETTY_FUNCTION__, photoURL); if (photoURL) { NSURL* aURL = [NSURL URLWithString:photoURL]; NSData* data = [[NSData alloc] initWithContentsOfURL:aURL]; self.photoImage = [UIImage imageWithData:data]; [data release]; } When I ran it the console shows: -[PhotoBox willMoveToWindow:] file://localhost/Users/gary/Library/Application%20Support/iPhone%20Simulator/3.2/Media/DCIM/100APPLE/IMG_0004.JPG *** -[NSURL length]: unrecognized selector sent to instance 0x536fbe0 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL length]: unrecognized selector sent to instance 0x536fbe0' Looking at the call stack, I'm calling URLWithString, which calls URLWithString:relativeToURL:, then initWithString:relativeToURL:, then _CFStringIsLegalURLString, then CFStringGetLength, then forwarding_prep_0, then forwarding, then -[NSObject doesNotRecognizeSelector]. Any ideas why my NSString (photoURL's address is 0x536fbe0) doesn't respond to length? Why does it say it doesn't respond to -[NSURL length]? Doesn't it know that param is an NSString, not a NSURL?

    Read the article

  • Reading Certificates on iOS Problem

    - by David Schiefer
    I am trying to read certificates from various URLs in iOS. My code however is not working well - the array that should return the information I need always returns null. What am I missing? - (void)findCertificate:(NSString *)url { NSInputStream*input = [[NSInputStream inputStreamWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://store.writeitstudios.com"]]] retain]; [input setDelegate:self]; [input scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [input open]; NSLog(@"Status: %i",[input streamStatus]); } - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode { NSLog(@"handle Event: %i",eventCode); if (eventCode == NSStreamStatusOpen) { NSArray *certificates = (NSArray*)CFReadStreamCopyProperty((CFReadStreamRef)aStream, kCFStreamPropertySSLPeerCertificates); NSLog(@"Certs: %@",CFReadStreamCopyProperty((CFReadStreamRef)aStream, kCFStreamPropertySSLPeerCertificates)); if ([certificates count] > 0) { SecCertificateRef certificate = (SecCertificateRef)[certificates objectAtIndex:0]; NSString *description = (NSString*)SecCertificateCopySubjectSummary(certificate); NSData *data = (NSData *)SecCertificateCopyData(certificate); NSLog(@"Description: %@",description); } } } And yes, I am aware that I am leaking memory. This is just a snippet.

    Read the article

  • Playing video and audio in iPhone not working...

    - by Scott
    So we have buttons linked up to display images/videos/audio on click depending on a check we do earlier. That part works fine. It knows which one to play, however, when we click the buttons for video and audio, nothing happens. The image one works fine. The video and audio are being taken for a URL online, they are not local, but everywhere said this was still possible. Here is a little snippet of the code where we play the two files: if ( [fName hasSuffix:@".png"]) { NSLog(@"PICTURE"); NSURL *url = [NSURL URLWithString: fName]; UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]]; self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; // self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"MainBG.jpg"]]; [self.view addSubview:[[UIImageView alloc] initWithImage:image]]; } if ( [fName hasSuffix:@".mp4"]) { NSLog(@"VIDEO"); //NSString *path = [[NSBundle mainBundle] pathForResource:fName ofType:@"mp4"]; //NSLog(path); NSURL *url = [NSURL fileURLWithPath:fName]; MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url]; [player play]; } if ( [fName hasSuffix:@".mp3"]) { NSLog(@"AUDIO"); NSURL *url = [NSURL fileURLWithPath:fName]; NSData *soundData = [NSData dataWithContentsOfURL:url]; AVAudioPlayer *avPlayer = [[AVAudioPlayer alloc] initWithData:soundData error: nil]; [avPlayer play]; } See anything wrong? By the way it compiles and runs, but nothing happens when we hit the button that executes that code.

    Read the article

  • Get Image from Byte Aarray.

    - by Arun Thakkar
    Hello Everyone!! Hope You all are fine and also in one of your best of moods!! Hope You all are Enjoying iPhone development. I herewith one issue that i am not able to solve, may be i don't know the depth concept of iPhone. So Its my humble requet to you to guide me or suggest or share your ideas. I do find an issue with getting an image from Bytes array. I am calling a webservice which returns an image in form of Bytes Array as response. I have Converted this bytes array in to form of NSData, Now i have NSData, But When i Try to get an image from this NSData, It shows nil. I Did lots of R&D and Find one suggestion to use base64 encoder, But unfortunately because of not proper guidance I was not able to Implement that. I was also suggested to use OPenSSL Library for base64 from url http://www.cocoadev.com/index.pl?BaseSixtyFour But again i was not able to include #include #include these two files. as in Newer Version of SDK 3.X family Apple has depreciated those (as i guess). So Now i need help from you guys. kindly help me if you have solution or if you know the steps to solve these. Looking Forwards. Regards, Arun Thakkar

    Read the article

  • Objective C code to handle large amount of data processing in iPhone

    - by user167662
    I had the following code that takes in 14 mb or more of image data encoded in base4 string and converts them to jpeg before writing to a file in iphone. It crashes my program giving the following error : Program received signal: “0”. warning: check_safe_call: could not restore current frame I tweak my program and it can process a few more images before the error appear again. My coding is as follows: // parameters is an array where the fourth element contains a list of images in base64 >encoded string NSMutableArray *imageStrList = (NSMutableArray*) [parameters objectAtIndex:5]; while (imageStrList.count != 0) { NSString *imgString = [imageStrList objectAtIndex:0]; // Create a file name using my own Utility class NSString *fileName = [Utility generateFileNName]; NSData *restoredImg = [NSData decodeWebSafeBase64ForString:imgString]; UIImage *img = [UIImage imageWithData: restoredImg]; NSData *imgJPEG = UIImageJPEGRepresentation(img, 0.4f); [imgJPEG writeToFile:fileName atomically:YES]; [imageStrList removeObjectAtIndex:0]; } I tried playing around with UIImageJPEGRepresentation and found out that the lower the value, the more image it can processed but this should not be the way. I am wondering if there is anyway to free up memory of the imageStrList immediately after processing each image so that it can be used by the next one in the line.

    Read the article

  • iphone file download not working

    - by Anonymous
    Hi, In my app I 'm first connecting to a web service, which in return sends a url for a file. I use the url to download the file and then display it on the new view. I get the correct URL but not able to download file from that location. I have another test app which will download file from the same location and it works like a charm. following is my code for webservice-file download. This is a snippet of the code where i 'm parsing the web service xml and then pass the result to NSData for file download. Any suggestions where am i going wrong -- I 'm referring to the following tutorials. Web Service PDF Viewer if ([elementName isEqualToString:@"PRHPdfResultsResult"]) { NSLog(soapResults); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Report downloaded from:" message:soapResults delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:soapResults]]; //Store the Data locally as PDF File NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]]; NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"myPDF.pdf"]; [pdfData writeToFile:filePath atomically:YES]; [alert show]; [alert release]; [soapResults setString:@""]; elementFound = FALSE; }

    Read the article

  • My app crash with MFMailComposeViewController and MFMessageComposeViewController when I re-launch it.

    - by Dolwen
    Hello all, I encounter a crash with MFMailComposeViewController, MFMessageComposeViewController and multitasking on IOS 4.2 (both simulator and IPHone 4). Code i use : Class emailClass = (NSClassFromString(@"MFMailComposeViewController")); if( emailClass != nil ) { MFMailComposeViewController * controller = [[emailClass alloc] init]; if([emailClass canSendMail]) { // delegate controller.mailComposeDelegate = self; // subject [controller setSubject:@"Hello All."]; // main message [controller setMessageBody:@"I love Stackoverflow.com !" isHTML:NO]; // adding image attachment // getting path for the image we have in the tutorial project NSString *path = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"]; // loading content of the image into NSData NSData *imageData = [NSData dataWithContentsOfFile:path]; // adding the attachment to he message [controller addAttachmentData:imageData mimeType:@"image/png" fileName:@"My Byook image"]; // setting different than the default transition for the modal view controller [controller setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; // show [[CGameStateManager getCurrentGameState] presentModalViewController:controller animated:YES]; } [controller release]; } To close MFMailComposeViewController i use : [[CGameStateManager getCurrentGameState] dismissModalViewControllerAnimated:NO]; Then the app crash on the "dismissModalViewControllerAnimated:" and we can read in the debugger with NSZombieEnabled : * -[UIImage isKindOfClass:]: message sent to deallocated instance 0xb0b9f80 Anyone have an answer to solve my problem ? :) Thx

    Read the article

  • Objective C: Function returning correct data for the first time of call and null for other times

    - by Kooshal Bhungy
    Hi all, Am a beginner in objective C, i am implementing a function that would query a web server and display the returning string in console. I am calling the function (getDatafromServer) repeatedly in a loop. The problem is that the first time am getting the value whereas the other times, it returns me a (null) in console... I've searched about memory management and check out on the forums but none have worked. Can you please guys tell me where am wrong in the codes below? Thanks in advance.... @implementation RequestThread +(void)startthread:(id)param{ while (true) { //NSLog(@"Test threads"); sleep(5); NSLog(@"%@",[self getDatafromServer]); } } +(NSString *) getDatafromServer{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *myRequestString = @"name=Hello%20&[email protected]"; NSData *myRequestData = [NSData dataWithBytes:[myRequestString UTF8String] length:[myRequestString length]]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"http://192.168.1.32/gs/includes/widget/getcalls.php?user=asdasd&passw=asdasdasd"]]; [request setHTTPMethod:@"POST"]; [request setHTTPBody: myRequestData]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *myString = [NSString stringWithUTF8String:[returnData bytes]]; [myRequestString release]; [request release]; [returnData release]; return myString; [pool release]; } @end

    Read the article

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