Search Results

Search found 2356 results on 95 pages for 'nsstring'.

Page 13/95 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • How do I split an NSString by each character in the string?

    - by Robert Höglund
    I have the following code, which works as I expect. What I would like to know if there is an accepted Cocoa way of splitting a string into an array with each character of the string as an object in an array? - (NSString *)doStuffWithString:(NSString *)string { NSMutableArray *stringBuffer = [NSMutableArray arrayWithCapacity:[string length]]; for (int i = 0; i < [string length]; i++) { [stringBuffer addObject:[NSString stringWithFormat:@"%C", [string characterAtIndex:i]]]; } // doing stuff with the array return [stringBuffer componentsJoinedByString:@""]; }

    Read the article

  • changing output in objective-c app

    - by Zack
    // // RC4.m // Play5 // // Created by svp on 24.05.10. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "RC4.h" @implementation RC4 @synthesize txtLyrics; @synthesize sbox; @synthesize mykey; - (IBAction) clicked: (id) sender { NSData *asciidata1 = [@"4875" dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *asciistr1 = [[NSString alloc] initWithData:asciidata1 encoding:NSASCIIStringEncoding]; //[txtLyrics setText:@"go"]; NSData *asciidata = [@"sdf883jsdf22" dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *asciistr = [[NSString alloc] initWithData:asciidata encoding:NSASCIIStringEncoding]; //RC4 * x = [RC4 alloc]; [txtLyrics setText:[self decrypt:asciistr1 andKey:asciistr]]; } - (NSMutableArray*) hexToChars: (NSString*) hex { NSMutableArray * arr = [[NSMutableArray alloc] init]; NSRange range; range.length = 2; for (int i = 0; i < [hex length]; i = i + 2) { range.location = 0; NSString * str = [[hex substringWithRange:range] uppercaseString]; unsigned int value; [[NSScanner scannerWithString:str] scanHexInt:&value]; [arr addObject:[[NSNumber alloc] initWithInt:(int)value]]; } return arr; } - (NSString*) charsToStr: (NSMutableArray*) chars { NSString * str = @""; for (int i = 0; i < [chars count]; i++) { str = [NSString stringWithFormat:@"%@%@",[NSString stringWithFormat:@"%c", [chars objectAtIndex:i]],str]; } return str; } //perfect except memory leaks - (NSMutableArray*) strToChars: (NSString*) str { NSData *asciidata = [str dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *asciistr = [[NSString alloc] initWithData:asciidata encoding:NSASCIIStringEncoding]; NSMutableArray * arr = [[NSMutableArray alloc] init]; for (int i = 0; i < [str length]; i++) { [arr addObject:[[NSNumber alloc] initWithInt:(int)[asciistr characterAtIndex:i]]]; } return arr; } - (void) initialize: (NSMutableArray*) pwd { sbox = [[NSMutableArray alloc] init]; mykey = [[NSMutableArray alloc] init]; int a = 0; int b; int c = [pwd count]; int d = 0; while (d < 256) { [mykey addObject:[pwd objectAtIndex:(d % c)]]; [sbox addObject:[[NSNumber alloc] initWithInt:d]]; d++; } d = 0; while (d < 256) { a = (a + [[sbox objectAtIndex:d] intValue] + [[mykey objectAtIndex:d] intValue]) % 256; b = [[sbox objectAtIndex:d] intValue]; [sbox replaceObjectAtIndex:d withObject:[sbox objectAtIndex:a]]; [sbox replaceObjectAtIndex:a withObject:[[NSNumber alloc] initWithInt:b]]; d++; } } - (NSMutableArray*) calculate: (NSMutableArray*) plaintxt andPsw: (NSMutableArray*) psw { [self initialize:psw]; int a = 0; int b = 0; NSMutableArray * c = [[NSMutableArray alloc] init]; int d; int e; int f; int g = 0; while (g < [plaintxt count]) { a = (a + 1) % 256; b = (b + [[sbox objectAtIndex:a] intValue]) % 256; e = [[sbox objectAtIndex:a] intValue]; [sbox replaceObjectAtIndex:a withObject:[sbox objectAtIndex:b]]; [sbox replaceObjectAtIndex:b withObject:[[NSNumber alloc] initWithInt:e]]; int h = ([[sbox objectAtIndex:a]intValue] + [[sbox objectAtIndex:b]intValue]) % 256; d = [[sbox objectAtIndex:h] intValue]; f = [[plaintxt objectAtIndex:g] intValue] ^ d; [c addObject:[[NSNumber alloc] initWithInt:f]]; g++; } return c; } - (NSString*) decrypt: (NSString*) src andKey: (NSString*) key { NSMutableArray * plaintxt = [self hexToChars:src]; NSMutableArray * psw = [self strToChars:key]; NSMutableArray * chars = [self calculate:plaintxt andPsw:psw]; NSData *asciidata = [[self charsToStr:chars] dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *asciistr = [[NSString alloc] initWithData:asciidata encoding:NSUTF8StringEncoding]; return asciistr; } @end This is supposed to decrypt a hex string with an ascii string, using rc4 decryption. I'm converting my java application to objective-c. The output keeps changing, every time i run it.

    Read the article

  • How does Mach-O loader recognize a bunch of NSString objects?

    - by overboming
    I have known that If you define a bunch of @"" NSString objects in the source code in Mac OS. These NSStrings will be stored in a segment in the Mach-O library. Section sectname __ustring segname __TEXT addr 0x000b3b54 size 0x000001b7 offset 731988 align 2^1 (2) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 If I hex dump the binary, they are aligned closely one by one with a 0x0000as separator. What I want to know is how does the loader in Mac OS X load these NSStrings when the program runs? Are they loaded simpily by recognize the 0x0000 separator or these is a string offset table elsewhere in the binary pointing to separate NSString objects? Thanks. (What I really want to do is the increase the length of one of the NSString, so I have to know how the loader recognize these separate objects)

    Read the article

  • How does Mach-O loader loads different NSString objects?

    - by overboming
    I have known that If you define a bunch of @"" NSString objects in the source code in Mac OS. These NSStrings will be stored in a segment in the Mach-O library. Section sectname __ustring segname __TEXT addr 0x000b3b54 size 0x000001b7 offset 731988 align 2^1 (2) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 If I hex dump the binary, they are aligned closely one by one with a 0x0000as separator. What I want to know is how does the loader in Mac OS X load these NSStrings when the program runs? Are they loaded simpily by recognize the 0x0000 separator or these is a string offset table elsewhere in the binary pointing to separate NSString objects? Thanks. (What I really want to do is the increase the length of one of the NSString, so I have to know how the loader recognize these separate objects)

    Read the article

  • Iphone SQLite Databse with german umlauts results in NULL value

    - by Daniel
    Hi guys, I'm quite new to the Iphone development and after search for an answer for 3 hours now, I hope that you guys can give me a hand. My problem is that I have a SQLite Database with german umlauts. Looking at it with a SQLite browser tool shows me that the data is stored with german umlauts, correctly. But selecting fields with german umlauts in it results in a NULL value. I'm already using "stringWithUTF8String", so I don't get the point where the problem is placed. Here is my code: -(void) readSearchFromDatabase { searchFlag = YES; // Setup the database object sqlite3 *database; // Init the SCode Array searchSCodes = [[NSMutableArray alloc] init]; // Open the database from the users filessytem if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { NSString *wildcard =@"%"; // Setup the SQL Statement and compile it NSString *sql = [NSString stringWithFormat:@"SELECT * FROM scode WHERE ta LIKE '%@%@%@' OR descriptionde LIKE '%@%@%@' OR descriptionen LIKE '%@%@%@'", wildcard, searchBar.text, wildcard, wildcard, searchBar.text, wildcard, wildcard, searchBar.text, wildcard, wildcard, searchBar.text, wildcard]; //Creating a const char SQL Statement especially for SQLite const char *sqlStatement = [sql UTF8String]; sqlite3_stmt *compiledStatement; if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { // Loop through the results and add them to the feeds array while(sqlite3_step(compiledStatement) == SQLITE_ROW) { // Read the data from the result row NSString *aTa = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)]; NSString *aReport = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)]; NSString *aDescriptionDE = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]; NSString *aDescriptionEN = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)]; //Results a NULL value NSLog(@"Output: %@", aDescriptionDE); // Create a new SCode object with the data from the database SCode *searchSCode = [[SCode alloc] initWithTa:aTa report:aReport descriptionDE:aDescriptionDE descriptionEN:aDescriptionEN]; // Add the SCode object to the SCodes Array [searchSCodes addObject:searchSCode]; [searchSCode release]; } } // Release the compiled statement from memory sqlite3_finalize(compiledStatement); } sqlite3_close(database); }

    Read the article

  • Creating an MJPEG Viewer Iphone

    - by Tony
    Hey all, Im trying to make a MJPEG viewer in Objective C but I'm having a bunch of issues with it. First off, Im using AsyncSocket(http://code.google.com/p/cocoaasyncsocket/) which lets me connect to the host. Here's what I got so far NSLog(@"Ready"); asyncSocket = [[AsyncSocket alloc] initWithDelegate:self]; //http://kamera5.vfp.slu.se/axis-cgi/mjpg/video.cgi NSError *err = nil; if(![asyncSocket connectToHost:@"kamera5.vfp.slu.se" onPort:80 error:&err]) { NSLog(@"Error: %@", err); } then in the didConnectToHost method: - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port{ NSLog(@"Accepted client %@:%hu", host, port); NSString *urlString = [NSString stringWithFormat:@"http://kamera5.vfp.slu.se/axis-cgi/mjpg/video.cgi"]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"GET"]; //set headers NSString *_host = [NSString stringWithFormat:host]; [request addValue:_host forHTTPHeaderField: @"Host"]; NSString *KeepAlive = [NSString stringWithFormat:@"300"]; [request addValue:KeepAlive forHTTPHeaderField: @"Keep-Alive"]; NSString *connection = [NSString stringWithFormat:@"keep-alive"]; [request addValue:connection forHTTPHeaderField: @"Connection"]; //get response NSHTTPURLResponse* urlResponse = nil; NSError *error = [[NSError alloc] init]; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error]; NSString *result = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"Response Code: %d", [urlResponse statusCode]); if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 300) { NSLog(@"Response: %@", result); //here you get the response } } This calls the MJPEG stream, but it doesn't call it to get more data. What I think its doing is just loading the first chunk of data, then disconnecting. Am I doing this totally wrong or is there light at the end of this tunnel? Thanks!

    Read the article

  • upload photo at facebook via iphone

    - by yunas
    hello i am trying to upload my image from myapplication but not able to do so.... i have tried ASIFormDataRequest *theRequest = [ASIFormDataRequest requestWithURL:url]; NSString *nowTimestamp = [NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970]]; [theRequest setPostValue:kApiKey forKey:@"api_key"]; [theRequest setPostValue:(float)[[NSDate date] timeIntervalSince1970] forKey:@"call_id"]; [theRequest setPostValue:@"1.0" forKey:@"v"]; [theRequest setData:[NSString stringWithString:@"abc"] forKey:@"status"]; [theRequest setPostValue:[NSString stringWithFormat:@"%lld",session1.uid] forKey:@"uid"]; NSLog(@"%lld",session1.uid); NSString *strSig = [[NSString alloc] init]; strSig = [strSig stringByAppendingString:[NSString stringWithFormat:@"@=%@",@"api_key",kApiKey]]; StrSig = [strSig stringByAppendingString:[NSString stringWithFormat:@"@=%@",@"call_id",nowTimestamp]]; strSig = [strSig stringByAppendingString:[NSString stringWithFormat:@"%@=%@",@"v",@"1.0"]]; strSig = [strSig stringByAppendingString:[NSString stringWithFormat:@"%@=%@",@"uid",[NSString stringWithFormat:@"%lld",session1.uid]]]; strSig = [strSig stringByAppendingString:kApiSecret]; [theRequest setPostValue:[self md5:strSig] forKey:@"sig"]; [theRequest setURL:url]; [theRequest setRequestMethod:@"POST"]; [theRequest setPostFormat:ASIMultipartFormDataPostFormat]; [theRequest startSynchronous]; but it says that signature is incorrect .... where i am wrong please help me.....

    Read the article

  • Append data to file in iPhone app

    - by zp26
    I have a problem. I want to create a file like XML. I have create a code for this but the file not append the information but rewrite and save only the last NSData. Can you help me/ 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]; if ([dataName writeToFile:filePath atomically:YES]) NSLog(@"writeok"); [myHandle seekToEndOfFile]; if ([dataX writeToFile:filePath atomically:YES]) NSLog(@"writeok"); [myHandle seekToEndOfFile]; if ([dataY writeToFile:filePath atomically:YES]) NSLog(@"writeok"); [myHandle seekToEndOfFile]; if ([dataZ writeToFile:filePath atomically:YES]) NSLog(@"writeok"); [myHandle seekToEndOfFile]; NSLog(@"zp26 %@",filePath); }

    Read the article

  • The rightCalloutAccessory button is not shown

    - by Luca
    I try to manage annotations, and to display an info button on the right of the view when a PIN get selected, my relevant code is this: - (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"greenPin"]; if ([annotation isKindOfClass:[ManageAnnotations class]]) { static NSString* identifier = @"ManageAnnotations"; MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; if (newAnnotation==nil) { newAnnotation=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; }else { newAnnotation.annotation=annotation; } newAnnotation.pinColor = MKPinAnnotationColorGreen; newAnnotation.animatesDrop = YES; newAnnotation.canShowCallout = YES; newAnnotation.rightCalloutAccessoryView=[UIButton buttonWithType:UIButtonTypeInfoLight]; return newAnnotation; }else { newAnnotation.pinColor = MKPinAnnotationColorGreen; newAnnotation.animatesDrop = YES; newAnnotation.canShowCallout = YES; return newAnnotation; } ManageAnnotations.m : @implementation ManageAnnotations @synthesize pinColor; @synthesize storeName=_storeName; @synthesize storeAdress=_storeAdress; @synthesize coordinate=_coordinate; -(id)initWithTitle:(NSString*)storeName adress:(NSString*)storeAdress coordinate:(CLLocationCoordinate2D)coordinate{ if((self=[super init])){ _storeName=[storeName copy]; _storeAdress=[storeAdress copy]; _coordinate=coordinate; } return self; } -(NSString*)title{ return _storeName; } -(NSString*)subtitle{ return _storeAdress; } ManageAnnotations.h @interface ManageAnnotations : NSObject<MKAnnotation>{ NSString *_storeName; NSString *_storeAdress; CLLocationCoordinate2D _coordinate; } // @property(nonatomic,assign)MKPinAnnotationColor pinColor; @property(nonatomic, readonly, copy)NSString *storeName; @property(nonatomic, readonly, copy)NSString *storeAdress; @property(nonatomic,readonly)CLLocationCoordinate2D coordinate; // -(id)initWithTitle:(NSString*)storeName adress:(NSString*)storeAdress coordinate:(CLLocationCoordinate2D)coordinate; // The PINS are shown correctly on the Map, but without the info button on the right of the view. Am i missing something?

    Read the article

  • Creating an mailto: URL with a URL in the body iPhone SDK

    - by Sjakelien
    UPDATE: I just found a similar post here: http://stackoverflow.com/questions/730101/how-do-i-encode-in-a-url-in-an-html-attribute-value Please consider the code below: I try to send an email message from within my iPhone app. The problem I encounter is that I want to put a URL in the body of the email. This URL contains two ampersands. I am encoding all the strings using "stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding", but the URL ends up in my new mail messagd truncated after the first ampersand. IE: "http://www.mydomain.nl/?cm=79&ctime=1246572000&cid=4772" becomes "http://www.mydomain.nl/?cm=79". Any suggestion what I could do to escape? NSString *eMailSubject = @"My Subject"; NSString *encodedSubject = [[NSString alloc] initWithString:[eMailSubject stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSString *eMailBody = @"http://www.mydomain.nl?cm=79&ctime=1246572000&cid=4772"; NSString *encodedBody = [[NSString alloc] initWithString:[eMailBody stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSString *urlString = [[NSString alloc] initWithString:[NSString stringWithFormat:@"mailto:?subject=%@&body=%@", encodedSubject, encodedBody]]; NSString *encodedURL = [[NSString alloc] initWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSURL *url = [[NSURL alloc] initWithString:encodedURL]; [[UIApplication sharedApplication] openURL:url];

    Read the article

  • How do I upload an NSImage(NSData)to Twitpic with OAMutableURLRequest?

    - by timothy5216
    I'm using OAConsumer in my xAuth twitterEngine and i'm adding Twitpic OAuth Echo to it. But it won't POST the NSData. here is some of my code: //other file NSArray *reps = [[imageToUpload image] representations]; NSData *imageData = [NSBitmapImageRep representationOfImageRepsInArray:reps usingType:NSJPEGFileType properties:nil]; [twitter testUploadImageData:imageData withMessage:@"Hello WORLD!!" toURL:[NSURL URLWithString:uploadURL.stringValue]]; // - (void)testUploadImageData:(NSData *)data withMessage:(NSString *)message toURL:(NSURL *)url; { //url = @"http://api.twitpic.com/2/upload.xml" //message = @"Hello WORLD!!" NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *String = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; NSLog(@"dataString: %@",String); OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url consumer:self.consumer token:_accessToken realm:nil signatureProvider:nil]; // Setup POST body [request setHTTPMethod:@"POST"]; //NSString *stringBoundary = [NSString stringWithString:@"0xKhTmLbOuNdArY"]; //NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", stringBoundary]; // NSString *stringBoundarySeparator = [NSString stringWithFormat:@"\r\n--%@\r\n", stringBoundary]; /* NSMutableString *postString = [NSMutableString string]; [postString appendString:@"\r\n"]; [postString appendString:stringBoundarySeparator]; [postString appendString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"message\"\r\n\r\n%@", message]]; [postString appendString:stringBoundarySeparator]; [postString appendString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"media\"; filename=\"%@\"\r\n", @"file.jpg"]]; [postString appendString:@"Content-Type: image/jpg\r\n"]; [postString appendString:@"Content-Transfer-Encoding: binary\r\n\r\n"]; // Setting up the POST request's multipart/form-data body NSMutableData *postBody = [NSMutableData data]; [postBody appendData:[postString dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:data]; [request setHTTPBody:postBody]; */ [request setHTTPMethod:@"POST"]; NSString *thing = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; NSLog(@"%@",thing); [request setParameters:[NSArray arrayWithObjects: [OARequestParameter requestParameterWithName:@"oauth_token" value:_accessToken.key], [OARequestParameter requestParameterWithName:@"X-Auth-Service-Provider" value:@"https://api.twitter.com/1/account/verify_credentials.json"], [OARequestParameter requestParameterWithName:@"key" value:@"my-key-here :P"], [OARequestParameter requestParameterWithName:@"message" value:message], //iv'e changed this many times. I was just trying this to see if it works [OARequestParameter requestParameterWithName:@"media" value:thing], nil]]; OAAsynchronousDataFetcher *dataFetcher = [[OAAsynchronousDataFetcher alloc] init]; [dataFetcher initWithRequest:request delegate:self didFinishSelector:@selector(uploadDidUpload:withData:) didFailSelector:@selector(uploadDidFail:withData:)]; [dataFetcher start]; [dataFetcher release]; [request release]; [pool drain]; } I'm authenticated but it still won't POST the data :(

    Read the article

  • -[NSConcreteMutableData release]: message sent to deallocated instance

    - by kamibutt
    Dear members, I am facing a problem of -[NSConcreteMutableData release]: message sent to deallocated instance, i have attached my sample code as well. - (IBAction)uploadImage { NSString *urlString = @"http://192.168.1.108/iphoneimages/uploadfile.php?userid=1&charid=23&msgid=3"; //if(FALSE) for (int i=0; i<[imgArray count]; i++) { // setting up the request object now NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; /* 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 */ NSMutableData *body = [[NSMutableData data] autorelease]; NSString *str = [NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"ipodfile%d.jpg\"\r\n",i]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:str] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; NSData *imageData = UIImageJPEGRepresentation([imgArray objectAtIndex:i], 90); [body appendData:[NSData dataWithData:imageData]]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; // setting the body of the post to the reqeust [request setHTTPBody:body]; // now lets make the connection to the web [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; //NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; //NSLog(@"%@",returnString); [imageData release]; [request release]; //[body release]; } } It successfully upload the images to the folder and there is no any error in the execution but when it complete it process and try to go back it give error -[NSConcreteMutableData release]: message sent to deallocated instance Please help me out. Thanks

    Read the article

  • I'm trying to pass a string from my first ViewController to my second ViewController but it returns NULL

    - by Dashony
    In my first view controller I have 3 input fields each of them take the user input into and saves it into a string such as: address, username and password as NSUserDefaults. This part works fine. In my second view controller I'm trying to take the 3 strings from first controller (address, username and password) create a html link based on the 3 strings. I've tried many ways to access the 3 strings with no luck, the result I get is NULL. Here is my code: //.h file - first view controller with the 3 input fields CamSetup.h #import <UIKit/UIKit.h> @interface CamSetup : UIViewController <UITextFieldDelegate> { NSString * address; NSString * username; NSString * password; IBOutlet UITextField * addressField; IBOutlet UITextField * usernameField; IBOutlet UITextField * passwordField; } -(IBAction) saveAddress: (id) sender; -(IBAction) saveUsername: (id) sender; -(IBAction) savePassword: (id) sender; @property(nonatomic, retain) UITextField *addressField; @property(nonatomic, retain) UITextField *usernameField; @property(nonatomic, retain) UITextField *passwordField; @property(nonatomic, retain) NSString *address; @property(nonatomic, retain) NSString *username; @property(nonatomic, retain) NSString *password; @end //.m file - first view controller CamSetup.m #import "CamSetup.h" @interface CamSetup () @end @implementation CamSetup @synthesize addressField, usernameField, passwordField, address, username, password; -(IBAction) saveAddress: (id) sender { address = [[NSString alloc] initWithFormat:addressField.text]; [addressField setText:address]; NSUserDefaults *stringDefaultAddress = [NSUserDefaults standardUserDefaults]; [stringDefaultAddress setObject:address forKey:@"stringKey1"]; NSLog(@"String [%@]", address); } -(IBAction) saveUsername: (id) sender { username = [[NSString alloc] initWithFormat:usernameField.text]; [usernameField setText:username]; NSUserDefaults *stringDefaultUsername = [NSUserDefaults standardUserDefaults]; [stringDefaultUsername setObject:username forKey:@"stringKey2"]; NSLog(@"String [%@]", username); } -(IBAction) savePassword: (id) sender { password = [[NSString alloc] initWithFormat:passwordField.text]; [passwordField setText:password]; NSUserDefaults *stringDefaultPassword = [NSUserDefaults standardUserDefaults]; [stringDefaultPassword setObject:password forKey:@"stringKey3"]; NSLog(@"String [%@]", password); } - (void)viewDidLoad { [addressField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey1"]]; [usernameField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey2"]]; [passwordField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey3"]]; [super viewDidLoad]; } @end //.h second view controller LiveView.h #import <UIKit/UIKit.h> #import "CamSetup.h" @interface LiveView : UIViewController { NSString *theAddress; NSString *theUsername; NSString *thePassword; CamSetup *camsetup; //here is an instance of the first class } @property (nonatomic, retain) NSString *theAddress; @property (nonatomic, retain) NSString *theUsername; @property (nonatomic, retain) NSString *thePassword; @end //.m second view LiveView.m file #import "LiveView.h" @interface LiveView () @end @implementation LiveView @synthesize theAddress, theUsername, thePassword; - (void)viewDidLoad { [super viewDidLoad]; theUsername = camsetup.username; //this is probably not right? NSLog(@"String [%@]", theUsername); //resut here is NULL NSLog(@"String [%@]", camsetup.username); //and here NULL as well } @end

    Read the article

  • How can I change 'self.view' within a button method created outside of 'loadView'

    - by Scott
    Hey guys. So I am creating buttons dynamically within loadView. Each of these buttons is given an action using the @Selector method, such as : [button addTarget:self action:@selector(showCCView) forControlEvents:UIControlEventTouchUpInside]; Now that showCCView method is defined outside of loadView, where this above statement is located. The point of the method is to change the view currently on the screen (so set self.view = ccView). It gives me an error every time I try and access self.view outside of loadView, and even sometimes when I try and access it at random places within loadView, it just has been acting really weird. I tried to change it around so I wouldn't have to deal with this either. I had made a function + (void) showView: (UIView*) oldView: (UIView*) newView; but this didn't work out either because the @Selector was being real prissy about using it with a function that needed two parameters. Any help please? Here is my code: // // SiteOneController.m // InstantNavigator // // Created by dni on 2/22/10. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "SiteOneController.h" @implementation SiteOneController + (UIView*) ccContent { UIView *ccContent = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; ccContent.backgroundColor = [UIColor whiteColor]; [ccContent addSubview:[SiteOneController myNavBar1:@"Constitution Center Content"]]; return ccContent; } // Button Dimensions int a = 62; int b = 80; int c = 200; int d = 30; // NPSIN Green Color + (UIColor*)myColor1 { return [UIColor colorWithRed:0.0f/255.0f green:76.0f/255.0f blue:29.0f/255.0f alpha:1.0f]; } // Creates Nav Bar with default Green at top of screen with given String as title + (UINavigationBar*)myNavBar1: (NSString*)input { UIView *test = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, test.bounds.size.width, 45)]; navBar.tintColor = [SiteOneController myColor1]; UINavigationItem *navItem; navItem = [UINavigationItem alloc]; navItem.title = input; [navBar pushNavigationItem:navItem animated:false]; return navBar; } //-------------------------------------------------------------------------------------------// //-------------------------------------------------------------------------------------------// //-------------------------------------------------------------------------------------------// // Implement loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { //hard coded array of content for each site // CC NSMutableArray *allccContent = [[NSMutableArray alloc] init]; NSString *cc1 = @"House Model"; NSString *cc2 = @"James Dexter History"; [allccContent addObject: cc1]; [cc1 release]; [allccContent addObject: cc2]; [cc2 release]; // FC NSMutableArray *allfcContent = [[NSMutableArray alloc] init]; NSString *fc1 = @"Ghost House"; NSString *fc2 = @"Franklins Letters"; NSString *fc3 = @"Franklins Business"; [allfcContent addObject: fc1]; [fc1 release]; [allfcContent addObject: fc2]; [fc2 release]; [allfcContent addObject: fc3]; [fc3 release]; // PC NSMutableArray *allphContent = [[NSMutableArray alloc] init]; NSString *ph1 = @"Changing Occupancy"; NSString *ph2 = @"Sketches"; NSString *ph3 = @"Servant House"; NSString *ph4 = @"Monument"; NSString *ph5 = @"Virtual Model"; [allphContent addObject: ph1]; [ph1 release]; [allphContent addObject: ph2]; [ph2 release]; [allphContent addObject: ph3]; [ph3 release]; [allphContent addObject: ph4]; [ph4 release]; [allphContent addObject: ph5]; [ph5 release]; // Each content page's view //UIView *ccContent = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; UIView *fcContent = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; UIView *phContent = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; //ccContent.backgroundColor = [UIColor whiteColor]; fcContent.backgroundColor = [UIColor whiteColor]; phContent.backgroundColor = [UIColor whiteColor]; //[ccContent addSubview:[SiteOneController myNavBar1:@"Constitution Center Content"]]; [fcContent addSubview:[SiteOneController myNavBar1:@"Franklin Court Content"]]; [phContent addSubview:[SiteOneController myNavBar1:@"Presidents House Content"]]; //allocate the view self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; //set the view's background color self.view.backgroundColor = [UIColor whiteColor]; [self.view addSubview:[SiteOneController myNavBar1:@"Sites"]]; NSMutableArray *sites = [[NSMutableArray alloc] init]; NSString *one = @"Constution Center"; NSString *two = @"Franklin Court"; NSString *three = @"Presidents House"; [sites addObject: one]; [one release]; [sites addObject: two]; [two release]; [sites addObject: three]; [three release]; NSString *ccName = @"Constitution Center"; NSString *fcName = @"Franklin Court"; NSString *element; int j = 0; for (element in sites) { UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; //setframe (where on screen) //separation is 15px past the width (45-30) button.frame = CGRectMake(a, b + (j*45), c, d); [button setTitle:element forState:UIControlStateNormal]; button.backgroundColor = [SiteOneController myColor1]; /*- (void) fooFirstInput:(NSString*) first secondInput:(NSString*) second { NSLog(@"Logs %@ then %@", first, second); } - (void) performMethodsViaSelectors { [self performSelector:@selector(fooNoInputs)]; [self performSelector:@selector(fooOneInput:) withObject:@"first"]; [self performSelector;@selector(fooFirstInput:secondInput:) withObject:@"first" withObject:@"second"];*/ //UIView *old = self.view; if (element == ccName) { [button addTarget:self action:@selector(showCCView) forControlEvents:UIControlEventTouchUpInside]; } else if (element == fcName) { } else { } [self.view addSubview: button]; j++; } } // This method show the content views for each of the sites. /*+ (void) showCCView { self.view = [SiteOneController ccContent]; }*/

    Read the article

  • Xcode is not calling asp.net webservice

    - by vaibhav
    I have oracle database and using webservice i want to insert some records in to it So i created webservice in asp.net as follows public bool PickPill(string Me_id, string Mem_device_id, string Test_datetime, string Creation_id, string PillBayNo) { string Hed_seq_id = Hed_seq_Id(); bool ResultHED = InsHealthEData(Hed_seq_id, Mem_device_id, Me_id, Test_datetime, Creation_id); bool ResultHET = InsHealthETest(Hed_seq_id, PillBayNo, Test_datetime, Creation_id); if (ResultHED == ResultHET == true) return true; else return false; } this function did all data insertion trick for me i tested this service on the local mechine with ip address http:72.44.151.178/PickPillService.asmx then, I see an example on how to attach asp.net web service to iphone apps http://www.devx.com/wireless/Article/43209/0/page/4 then i created simillar code in xcode which has 2 files ConsumePillServiceViewController.m ConsumePillServiceViewController.h file Now, Using Designer of xcode i created 5 textboxes(Me_id,Mem_device_id,Test_datetime,Creation_id,PillBayNo) with all parameters hardcode as our service demands then modify my ConsumePillServiceViewController.h file as follows @interface ConsumePillServiceViewController : UIViewController { //---outlets--- IBOutlet UITextField *Me_id; IBOutlet UITextField *Mem_device_id; IBOutlet UITextField *Test_datetime; IBOutlet UITextField *Creation_id; IBOutlet UITextField *PillBayNo; //---web service access--- NSMutableData *webData; NSMutableString *soapResults; NSURLConnection *conn; } @property (nonatomic, retain) UITextField *Me_id; @property (nonatomic, retain) UITextField *Mem_device_id; @property (nonatomic, retain) UITextField *Test_datetime; @property (nonatomic, retain) UITextField *Creation_id; @property (nonatomic, retain) UITextField *PillBayNo; - (IBAction)buttonClicked:(id)sender; @end and ConsumePillServiceViewController.m as follows import "ConsumePillServiceViewController.h" @implementation ConsumePillServiceViewController @synthesize Me_id; @synthesize Mem_device_id; @synthesize Test_datetime; @synthesize Creation_id; @synthesize PillBayNo; (IBAction)buttonClicked:(id)sender { NSString *soapMsg = @"" "" "" ""; NSString *smMe_id= [soapMsg stringByAppendingString: [NSString stringWithFormat: @"%@",Me_id.text]]; NSString *smMem_device_id= [smMe_id stringByAppendingString: [NSString stringWithFormat: @"%@",Mem_device_id.text]]; NSString *smTest_datetime= [smMem_device_id stringByAppendingString: [NSString stringWithFormat: @"%@",Test_datetime.text]]; NSString *smCreation_id= [smTest_datetime stringByAppendingString: [NSString stringWithFormat: @"%@",Creation_id.text]]; NSString *smPillBayNo= [smCreation_id stringByAppendingString: [NSString stringWithFormat: @"%@",PillBayNo.text]]; NSString *smRestMsg= [smPillBayNo stringByAppendingString: @"" "" ""]; soapMsg=smRestMsg; //---print it to the Debugger Console for verification--- NSLog(soapMsg); NSURL *url = [NSURL URLWithString: //create a URL load request object using instances : @"http://72.44.151.178/PickPillService.asmx"];//of the NSMutableURLRequest and NSURL objects NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; //opulate the request object with the various headers, such as Content-Type, SOAPAction, and Content-Length. //You also set the HTTP method and HTTP body NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]]; [req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [req addValue:@"http://tempuri.org/PickPill" forHTTPHeaderField:@"SOAPAction"]; [req addValue:msgLength forHTTPHeaderField:@"Content-Length"]; //---set the HTTP method and body--- [req setHTTPMethod:@"POST"]; [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]]; conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; //establish the connection with the web service, if (conn) { //you use the NSURLConnection class together with the request object just created webData = [[NSMutableData data] retain];//webData object use to receive incoming data from the web service } }//End of button clicked event -(void) connection:(NSURLConnection *) connection //Recive response didReceiveResponse:(NSURLResponse *) response { [webData setLength: 0]; } -(void) connection:(NSURLConnection *) connection //Repeative call method and append data to webData didReceiveData:(NSData *) data { [webData appendData:data]; } -(void) connection:(NSURLConnection *) connection//If error occure error should be displayed didFailWithError:(NSError *) error { [webData release]; [connection release]; } -(void) connectionDidFinishLoading:(NSURLConnection *) connection { NSLog(@"DONE. Received Bytes: %d", [webData length]); NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding]; //---shows the XML--- NSLog(theXML); [connection release]; [webData release]; } (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 { [Me_id release]; [Creation_id release]; [Mem_device_id release]; [Test_datetime release]; [PillBayNo release]; [soapResults release]; [super dealloc]; } @end I did all things as shown in the website and when i built application it successfully built but in the debuggin window i see (gdb) continue 2010-03-17 09:09:54.595 ConsumePillService[6546:20b] A00000004303101103/13/2010 07:34:38Hboxdata2 (gdb) continue (gdb) continue (gdb) continue 2010-03-17 09:10:05.411 ConsumePillService[6546:20b] DONE. Received Bytes: 476 2010-03-17 09:10:05.412 ConsumePillService[6546:20b] soap:ServerServer was unable to process request. ---> One or more errors occurred during processing of command. ORA-00936: missing expression It should return me true if all things are ok What is this ORA-00936 error all about as it is not releted with webservice Please help me solving this problem Thanks in advance, Vaibhav Deshpande

    Read the article

  • UITableView crashes when trying to scroll

    - by Ondrej
    Hi, I have a problem with data in UITableView. I have UIViewController, that contains UITableView outlet and few more things I am using and ... It works :) ... it works lovely, but ... I've created an RSS reader class that is using delegates to deploy the data to the table ... and once again, If I'll just create dummy data in the main controller everything works! problem is with this line: rss.delegate = self; Preview looks a little bit broken than here are those RSS reader files on Google code: (Link to the header file on GoogleCode) (Link to the implementation file on Google code) viewDidLoad function of my controller: IGDataRss20 *rss = [[[IGDataRss20 alloc] init] autorelease]; rss.delegate = self; [rss initWithContentsOfUrl:@"http://rss.cnn.com/rss/cnn_topstories.rss"]; and my delegate methods: - (void)parsingEnded:(NSArray *)result { super.data = [[NSMutableArray alloc] initWithArray:result]; NSLog(@"My Items: %d", [super.data count]); [super.table reloadData]; NSLog(@"Parsing ended"); } (void)parsingError:(NSString *)message { NSLog(@"MyMessage: %@", message); } (void)parsingStarted:(NSXMLParser *)parser { NSLog(@"Parsing started"); } Just to clarify, NSLog(@"Parsing ended"); is being executed and I have 10 items in the array. Ok, here's my RSS reader header file: @class IGDataRss20; @protocol IGDataRss20Delegate @optional (void)parsingStarted:(NSXMLParser *)parser; (void)parsingError:(NSString *)message; (void)parsingEnded:(NSArray *)result; @end @interface IGDataRss20 : NSObject { NSXMLParser *rssParser; NSMutableArray *data; NSMutableDictionary *currentItem; NSString *currentElement; id <IGDataRss20Delegate> delegate; } @property (nonatomic, retain) NSMutableArray *data; @property (nonatomic, assign) id delegate; (void)initWithContentsOfUrl:(NSString *)rssUrl; (void)initWithContentsOfData:(NSData *)inputData; @end And this RSS reader implementation file: #import "IGDataRss20.h" @implementation IGDataRss20 @synthesize data, delegate; (void)initWithContentsOfUrl:(NSString *)rssUrl { self.data = [[NSMutableArray alloc] init]; NSURL *xmlURL = [NSURL URLWithString:rssUrl]; rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL]; [rssParser setDelegate:self]; [rssParser setShouldProcessNamespaces:NO]; [rssParser setShouldReportNamespacePrefixes:NO]; [rssParser setShouldResolveExternalEntities:NO]; [rssParser parse]; } (void)initWithContentsOfData:(NSData *)inputData { self.data = [[NSMutableArray alloc] init]; rssParser = [[NSXMLParser alloc] initWithData:inputData]; [rssParser setDelegate:self]; [rssParser setShouldProcessNamespaces:NO]; [rssParser setShouldReportNamespacePrefixes:NO]; [rssParser setShouldResolveExternalEntities:NO]; [rssParser parse]; } (void)parserDidStartDocument:(NSXMLParser *)parser { [[self delegate] parsingStarted:parser]; } (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError { NSString * errorString = [NSString stringWithFormat:@"Unable to parse RSS feed (Error code %i )", [parseError code]]; NSLog(@"Error parsing XML: %@", errorString); if ([parseError code] == 31) NSLog(@"Error code 31 is usually caused by encoding problem."); [[self delegate] parsingError:errorString]; } (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { currentElement = [elementName copy]; if ([elementName isEqualToString:@"item"]) currentItem = [[NSMutableDictionary alloc] init]; } (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ([elementName isEqualToString:@"item"]) { [data addObject:(NSDictionary *)[currentItem copy]]; } } (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if (![currentItem objectForKey:currentElement]) [currentItem setObject:[[[NSMutableString alloc] init] autorelease] forKey:currentElement]; [[currentItem objectForKey:currentElement] appendString:string]; } (void)parserDidEndDocument:(NSXMLParser *)parser { //NSLog(@"RSS array has %d items: %@", [data count], data); [[self delegate] parsingEnded:(NSArray *)self.data]; } (void)dealloc { [data, delegate release]; [super dealloc]; } @end Hope someone will be able to help me as I am becoming to be quite desperate, and I thought I am not already such a greenhorn :) Thanks, Ondrej

    Read the article

  • NSMutableArray of Objects

    - by Terry Owen
    First off I am very new to Objective C and iPhone programming. Now that that is out of the way. I have read through most of the Apple documentation on this and some third party manuals. I guess I just want to know if I'm going about this the correct way ... - (NSMutableArray *)makeModel { NSString *api = @"http://www.mycoolnewssite.com/api/v1"; NSArray *namesArray = [NSArray arrayWithObjects:@"News", @"Sports", @"Entertainment", @"Business", @"Features", nil]; NSArray *urlsArray = [NSArray arrayWithObjects: [NSString stringWithFormat:@"%@/news/news/25/stories.json", api], [NSString stringWithFormat:@"%@/news/sports/25/stories.json", api], [NSString stringWithFormat:@"%@/news/entertainment/25/stories.json", api], [NSString stringWithFormat:@"%@/news/business/25/stories.json", api], [NSString stringWithFormat:@"%@/news/features/25/stories.json", api], nil]; NSMutableArray *result = [NSMutableArray array]; for (int i = 0; i < [namesArray count]; i++) { NSMutableDictionary *objectDict = [NSMutableDictionary dictionary]; NSString *name = (NSString *)[namesArray objectAtIndex:i]; NSString *url = (NSString *)[urlsArray objectAtIndex:i]; [objectDict setObject:name forKey:@"NAME"]; [objectDict setObject:url forKey:@"URL"]; [objectDict setObject:@"NO" forKey:@"HASSTORIES"]; [result addObject:objectDict]; } return result; } Any insight would be appreciated ;-)

    Read the article

  • want to fetch the friends list of facebook thorough fbconnect in iphone using objective-c ?

    - by uttam
    how to fetch the friends list of facebook in iphone through fbconnect in objective-c? I am using this code (void)getUserName { NSString *fql = [NSString localizedStringWithFormat: @"SELECT uid FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = %lld)",[FBSession session].uid]; NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"]; [[FBRequest requestWithDelegate:self] call:@"facebook.friends.get" params:params]; } - (void)request:(FBRequest*)request didLoad:(id)result { if ([request.method isEqualToString:@"facebook.fql.query"]) { NSArray* users = result; NSDictionary* user = [users objectAtIndex:0]; NSString* name = [user objectForKey:@"name"]; _label.text = [NSString stringWithFormat:@"Logged in as %@", name]; } else if ([request.method isEqualToString:@"facebook.users.setStatus"]) { NSString* success = result; if ([success isEqualToString:@"1"]) { _label.text = [NSString stringWithFormat:@"Status successfully set"]; } else { _label.text = [NSString stringWithFormat:@"Problem setting status"]; } } else if ([request.method isEqualToString:@"facebook.freinds.get"]) { if(myList==nil) { NSArray* users = result; myList =[[NSArray alloc] initWithArray: users]; for(NSInteger i=0;i<[users count];i++) { NSDictionary* user = [users objectAtIndex:i]; NSString* uid = [user objectForKey:@"uid"]; NSString* fql = [NSString stringWithFormat: @"select name from user where uid == %@", uid]; NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"]; [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params]; } } else { NSArray* users = result; NSDictionary* user = [users objectAtIndex:0]; NSString* name = [user objectForKey:@"name"]; //txtView.text=[NSString localizedStringWithFormat:@"%@%@,\n",txtView.text,name]; NSLog(name); }} I want to get the friends list from facebook and then search/modify then add it to my addressbook. I know this code is doing this but I don't know how to use it or where do I use it.. If you could please post something or just elaborate on how do I use your code thru fbconnect framework. I have implemented upto get permissions and publish feeds one's wall. But please can you post here about the layout details of the results, like what do Ineed to use on the layout point of view.

    Read the article

  • iPhone: Repeating Rows in Each Section of Grouped UITableview

    - by Rank Beginner
    I'm trying to learn how to use the UITableView in conjunction with a SQLite back end. My issue is that I've gotten the table to populate with the records from the database, however I'm having a problem with the section titles. I am not able to figure out the proper set up for this, and I'm repeating all tasks under each section. The table looks like this. The groups field is where I'm trying to pull the section title from. TaskID groups TaskName sched lastCompleted nextCompleted success 1 Household laundry 3 03/19/2010 03/22/2010 y 1 Automotive Change oil 3 03/20/2010 03/23/2010 y In my viewDidLoad Method, I create an array from each column in the table like below. //Create and initialize arrays from table columns //______________________________________________________________________________________ ids =[[NSMutableArray alloc] init]; tasks =[[NSMutableArray alloc] init]; sched =[[NSMutableArray alloc] init]; lastComplete =[[NSMutableArray alloc] init]; nextComplete =[[NSMutableArray alloc] init]; weight =[[NSMutableArray alloc] init]; success =[[NSMutableArray alloc] init]; group =[[NSMutableArray alloc] init]; // Bind them to the data //______________________________________________________________________________________ NSString *query = [NSString stringWithFormat:@"SELECT * FROM Tasks ORDER BY nextComplete "]; sqlite3_stmt *statement; if (sqlite3_prepare_v2( database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { [ids addObject:[NSString stringWithFormat:@"%i",(int*) sqlite3_column_int(statement, 0)]]; [group addObject:[NSString stringWithFormat:@"%s",(char*) sqlite3_column_text(statement, 1)]]; [tasks addObject:[NSString stringWithFormat:@"%s",(char*) sqlite3_column_text(statement, 2)]]; [sched addObject:[NSString stringWithFormat:@"%i",(int*) sqlite3_column_int(statement, 3)]]; [lastComplete addObject:[NSString stringWithFormat:@"%s",(char*) sqlite3_column_text(statement, 4)]]; [nextComplete addObject:[NSString stringWithFormat:@"%s",(char*) sqlite3_column_text(statement, 5)]]; [success addObject:[NSString stringWithFormat:@"%s",(char*) sqlite3_column_text(statement, 6)]]; [weight addObject:[NSString stringWithFormat:@"%i",(int*) sqlite3_column_int(statement, 7)]]; } sqlite3_finalize(statement); } In the table method:cellForRowAtIndexPath, I create controls on the fly and set their text properties to objects in the array. Below is a sample, I can provide more but am already working on a book here... :) /create the task label NSString *tmpMessage; tmpMessage = [NSString stringWithFormat:@"%@ every %@ days, for %@ points",[tasks objectAtIndex:indexPath.row],[sched objectAtIndex:indexPath.row],[weight objectAtIndex:indexPath.row]]; CGRect schedLabelRect = CGRectMake(0, 0, 250, 15); UILabel *lblSched = [[UILabel alloc] initWithFrame:schedLabelRect]; lblSched.textAlignment = UITextAlignmentLeft; lblSched.text = tmpMessage; lblSched.font = [UIFont boldSystemFontOfSize:10]; [cell.contentView addSubview: lblSched]; [lblSched release]; My numberOfSectionsInTableView method looks like this // Figure out how many sections there are by a distinct count of the groups field // The groups are entered by user when creating tasks //______________________________________________________________________________________ NSString *groupquery = [NSString stringWithFormat:@"SELECT COUNT(DISTINCT groups) as Sum FROM Tasks"]; int sum; sqlite3_stmt *statement; if (sqlite3_prepare_v2( database, [groupquery UTF8String], -1, &statement, nil) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { sum = sqlite3_column_int(statement, 0); } sqlite3_finalize(statement); } if (sum=0) { return 1; } return 2; } I know I'm going wrong here but this is all that's in my numberOfRowsInSection method return [ids count];

    Read the article

  • problem with pathForResource

    - by mr.octobor
    HI all I have problem with NSString *filePaht = [[NSBundle mainBundle] pathForResource:(NSString *)name ofType:(NSString *)ext]; if I used NSString *filePaht = [[NSBundle mainBundle] pathForResource:@"soundName" ofType:@"aiff"]; it's OK but when I used NSString *fileName = [[file.list objectAtIndex:index] objectForKey:@"soundName"]; NSString *filePaht = [[NSBundle mainBundle] pathForResource:fileName ofType:@"aiff"]; It's not work have any idea !? Thanks

    Read the article

  • XML parsing to plist iPhone SDK

    - by victor
    Hi, guys. Could you, please, help me with parsing of this XML code: <?xml version="1.0" encoding="utf-8"?> <stuff> <parts> <part id='327'> <name>Logitech MX500</name> <serial>618163558491989</serial> <account>ASDALSKD</account> <number>987 789 456</number> <alarm>alarm1</alarm> </part> <part id='846'> <name>Logitech MX510</name> <serial>871351434945431</serial> <account>KJSDAKLJFA</account> <number>454 564 131</number> <alarm>alarm2</alarm> </part> </parts> <info>Information</info> </stuff> And save data to plist file stuff.plist in this format: 327 NSArray Name NSString Logitech MX500 Serial NSString 618163558491989 Account NSString ASDALSKD Number NSString 987 789 456 Alarm NSString alarm1 846 NSArray Name NSString Logitech MX510 Serial NSString 871351434945431 Account NSString KJSDAKLJFA Number NSString 454 564 131 Alarm NSString alarm2

    Read the article

  • How to save data from multiple views of an iPhone app?

    - by DownUnder
    Hi Everyone. I'm making an app where I need to save the text in multiple views in the app when the app quits. I also need to be able to remove all of the data from just one of those views and when the app quits, it's possible not all of those views will have been created yet. After reading this post I thought perhaps it would be good to use a singleton that manages my app data which loads in the data when it is first requested and saved it when the app quits. Then in each view where I need to save data I can just set it on the singleton. I gave it a go but have run into some issues. At first I didn't synthesize the properties (as in the post I was using as a guide) but the compiler told me I needed to make getters and setters, so I did. Now when my applicationWIllTerminate: gets call the app crashes and the console says "Program received signal: “EXC_BAD_ACCESS”. kill quit". Is anyone able to tell me what I'm doing wrong, or suggest a better approach to saving the data? //SavedData.h #import <Foundation/Foundation.h> #define kFileName @"appData.plist" @interface SavedData : NSObject { NSString *information; NSString *name; NSString *email; NSString *phone; NSString *mobile; } @property(assign) NSString *information; @property(assign) NSString *name; @property(assign) NSString *email; @property(assign) NSString *phone; @property(assign) NSString *mobile; + (SavedData *)singleton; + (NSString *)dataFilePath; + (void)applicationWillTerminate:(NSNotification *)notification; @end //SavedData.m #import "SavedData.h" @implementation SavedData @synthesize information; @synthesize name; @synthesize email; @synthesize phone; @synthesize mobile; static SavedData * SavedData_Singleton = nil; + (SavedData *)singleton{ if (nil == SavedData_Singleton){ SavedData_Singleton = [[SavedData_Singleton alloc] init]; NSString *filePath = [self dataFilePath]; if([[NSFileManager defaultManager] fileExistsAtPath:filePath]){ NSMutableArray * array = [[NSMutableArray alloc] initWithContentsOfFile:filePath]; information = [array objectAtIndex:0]; name = [array objectAtIndex:1]; email = [array objectAtIndex:2]; phone = [array objectAtIndex:3]; mobile = [array objectAtIndex:4]; [array release]; } UIApplication *app = [UIApplication sharedApplication]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:app]; } return SavedData_Singleton; } + (NSString *)dataFilePath{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *DocumentsDirectory = [paths objectAtIndex:0]; return [DocumentsDirectory stringByAppendingPathComponent:kFileName]; } + (void)applicationWillTerminate:(NSNotification *)notification{ NSLog(@"Application will terminate received"); NSMutableArray *array = [[NSMutableArray alloc] init]; [array addObject:information]; [array addObject:name]; [array addObject:email]; [array addObject:phone]; [array addObject:mobile]; [array writeToFile:[self dataFilePath] atomically:YES]; [array release]; } @end Then when I want to use it I do myLabel.text = [SavedData singleton].information; And when I change the field [SavedData singleton].information = @"my string"; Any help will be very much appreciated!

    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

  • NSMutableArray Problem - iPhone

    - by David Schiefer
    Hi, I'm trying to get a UITableView to read it's data from a file. I've attempted it like this: NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullFileName = [NSString stringWithFormat:@"%@/entries.plist", documentsDirectory]; self.dataForTable = [[NSMutableArray alloc] initWithContentsOfFile:fullFileName]; This compiles fine, but when saving something to the file in the following snippet, the file is not saved nor anything is written to the array: NSMutableDictionary*userDictionary; userDictionary = [[NSMutableDictionary alloc] init]; [userDictionary setObject:name.text forKey:@"name"]; [userDictionary setObject:email.text forKey:@"email"]; [userDictionary setObject:serial.text forKey:@"serial"]; [userDictionary setObject:notes.text forKey:@"notes"]; [userDictionary setObject:[NSNumber numberWithInt:[licenseType selectedRowInComponent:0]] forKey:@"license_type"]; [userDictionary setObject:[date date] forKey:@"date"]; [userDictionary setObject:[NSNumber numberWithBool:[paymentSwitch isOn]] forKey:@"payment"]; NSString*dirToSaveTo = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString*fileName = [NSString stringWithFormat:@"%@.plist",name.text]; NSString*saveName = [dirToSaveTo stringByAppendingPathComponent:fileName]; [userDictionary writeToFile:saveName atomically:NO]; NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullFileName = [NSString stringWithFormat:@"%@/entries.plist", documentsDirectory]; [self.dataForTable addObject:name.text]; NSLog(@"%@",self.dataForTable); [self.dataForTable writeToFile:fullFileName atomically:YES]; The NSLog just returns (null). The *plist file is never written. What am I doing wrong?

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >