Search Results

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

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

  • Reverse geocode coordinates to street address and setting as subtitle in annotation?

    - by Krismutt
    Hey everybody! Basically I wanna reverse geocode my coordinates for my annotation and show the address as the subtitle for the annotation. I just cant figure out how to do it... savePosition.h #import <Foundation/Foundation.h> #import <MapKit/MapKit.h> #import <MapKit/MKReverseGeocoder.h> #import <AddressBook/AddressBook.h> @interface savePosition : NSObject <MKAnnotation, MKReverseGeocoderDelegate> { CLLocationCoordinate2D coordinate; } @property (nonatomic, readonly) CLLocationCoordinate2D coordinate; -(id)initWithCoordinate:(CLLocationCoordinate2D) coordinate; - (NSString *)subtitle; - (NSString *)title; @end savePosition.m @synthesize coordinate; -(NSString *)subtitle{ return [NSString stringWithFormat:@"%f", streetAddress]; } -(NSString *)title{ return @"Saved position"; } -(id)initWithCoordinate:(CLLocationCoordinate2D) coor{ coordinate=coor; NSLog(@"%f,%f",coor.latitude,coor.longitude); return self; MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate]; geocoder.delegate = self; [geocoder start]; } - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error { } - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{ NSString *streetAddress = [NSString stringWithFormat:@"%@", [placemark.addressDictionary objectForKey:kABPersonAddressStreetKey]]; } @end any ideas?? Thanks in advance!

    Read the article

  • Problem in data binding in NSString?

    - by Rajendra Bhole
    Hi, I selecting the row of the table. The text of the row i stored in the application delegate object as a NSString. That NSString i want to retrieving or binding in SELECT statement of SQLite query, For that i written code in the TableView Class (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { selectedText = [appDelegate.categoryArray objectAtIndex:indexPath.row]; appDelegate.selectedTextOfRow = selectedText; ListOfPrayersViewController *listVC = [[ListOfPrayersViewController alloc] init]; [self.navigationController pushViewController:listVC animated:YES]; [listVC release]; } and database class class code is. + (void) getDuas:(NSString *)dbPath{ if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK){ SalahAppDelegate *appDelegate = (SalahAppDelegate *)[[UIApplication sharedApplication] delegate]; NSString *categoryTextForQuery =[NSString stringWithFormat:@"SELECT Category FROM Prayer WHERE Category ='%s'", appDelegate.selectedTextOfRow ]; NSLog(@"The Text %@", categoryTextForQuery); //const char *sqlQuery1 = (char *)categoryTextForQuery; //const char *sqlQuery = "SELECT Category FROM Prayer WHERE Category = 'Invocations for the beginning of the prayer'"; sqlite3_stmt *selectstmt; if(sqlite3_prepare_v2(database, [categoryTextForQuery UTF8String], -1, &selectstmt, NULL) == SQLITE_OK){ appDelegate.duasArray =[[NSMutableArray alloc] init]; while(sqlite3_step(selectstmt) == SQLITE_ROW){ NSString *dua = [[NSString alloc] initWithCString:(char *)sqlite3_column_text(selectstmt,0) encoding:NSASCIIStringEncoding]; Prayer *prayerObj = [[Prayer alloc] initwithDuas:dua]; prayerObj.DuaName = dua; [appDelegate.duasArray addObject:prayerObj]; } } } } The code is comes out of loop on the statement or starting the loop of the while(sqlite3_step(selectstmt) == SQLITE_ROW) Why? How i bind the table selected text in SELECT statement of sqlite?

    Read the article

  • Convert wchar_t* to NSString

    - by Sharath
    Trying to convert const wchar_t * to NSString. The following code only produces the first character. I've tried the different CFAllocator options as well but with no success. Can anyone help me or point to how I can convert wchar_t * to NSString const wchar_t *data = L"Hello World"; int l = wcslen(data); CFStringRef c = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, (const UniChar *) data,l); NSString *nStr = (NSString *)c; //This always gives me 'H'

    Read the article

  • How to check if variable is a CFString?

    - by Sheehan Alam
    I am trying to set some text on a label descriptionLabel.text = [NSString stringWithFormat:mySTUser.bio]; The bio property of mySTUser is an NSString. Sometimes it is not an NSString when I set it. How can I check if mySTUser.bio is an NSString so I can prevent it from being assigned to my label text?

    Read the article

  • Converting NSDecimalNumber to NSString

    - by 4thSpace
    I'm retrieving a key from an object that looks like this: po obj { TypeID = 3; TypeName = Asset; } The key value is being retrieved like this: NSString *typeId = (NSString*)[obj objectForKey:@"TypeID"]; Rather than typeId being an NSString, it is an NSDecimalNumber. Why is that? How do I convert it to an NSString?

    Read the article

  • SQLite MYSQL character encoding

    - by Lee Armstrong
    I have a strange situation where the following code works however XCode warns it is deprecated... NSString *col1 = [NSString stringWithCString:(char *)sqlite3_column_text(compiledStatement, 0)]; However as that is the deprecated method if I set an encoding the string comes out wrong! I have tried all the encodings but none work! NSString *col1 = [NSString stringWithCString:(char *)sqlite3_column_text(compiledStatement, 0) encoding:NSASCIIStringEncoding];

    Read the article

  • strchr in objective C?

    - by Brian Postow
    I'm trying to write the equivalent of strchr, but with NSStrings... I've currently got this: Boolean nsstrchr(NSString* s, char c) { NSString *tmps = [NSString stringWithFormat: @"%c", c]; NSCharacterSet *cSet = [NSCharacterSet characterSetWithCharactersInString: tmps]; NSRange rg = [s rangeOfCharacterFromSet: cSet]; return rg.location != NSNotFound; } This seems needlessly complex... Is there a way to do this (preferably, one that doesn't involve turning the NSString into a cstring which doubles the run time, or writing it myself using characterAtIndex:... Am I missing some obvious method in the NSString description?

    Read the article

  • ios - how do I concatinate strings to create a url?

    - by GeekedOut
    I am trying to make a url by first collecting the parameters, and then in one statement creating the actual url. Here is what I am trying to do: NSString *urlString = @"http://www.some_login_url.com?email=%@&password=%@"; NSString *email = self.email.text; NSString *password = self.password.text; NSString *url_to_send = [NSString stringWithFormat:@"%@%@", urlString , email , password]; So what I wanted to do was replace the @ symbols with the values in the variables, but instead the second variable just got appended to the end of the string. How would I change the last line so I could put the right parameters in their correct spots? Thanks!!

    Read the article

  • NSCFString leak inVolving NSString

    - by Srilakshmi Manthena
    Hi, I am getting leak at NSString *firstNameStr = [NSString stringWithFormat:@"%s",firstNameString]; CODE: +(NSString *)getValueForProperty:(ABPropertyID)propertyId forContact:(NSString *)contactId { if (addressBook == nil) { addressBook = ABAddressBookCreate(); } ABRecordID contactIntId = [contactId intValue]; ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, contactIntId); CFStringRef firstName; char *firstNameString; firstName = ABRecordCopyValue(person, propertyId); // Paso a char* los datos para que se puedan escribir static char* fallback = ""; int fbLength = strlen(fallback); int firstNameLength = fbLength; bool firstNameFallback = true; if (firstName != NULL) { firstNameLength = (int) CFStringGetLength(firstName); firstNameFallback = false; } if (firstNameLength == 0) { firstNameLength = fbLength; firstNameFallback = true; } firstNameString = malloc(sizeof(char)*(firstNameLength+1)); if (firstNameFallback == true) { strcpy(firstNameString, fallback); } else { CFStringGetCString(firstName, firstNameString, 10*CFStringGetLength(firstName), kCFStringEncodingASCII); } if (firstName != NULL) { CFRelease(firstName); } NSString *firstNameStr = [NSString stringWithFormat:@"%s",firstNameString]; free(firstNameString); return firstNameStr; }

    Read the article

  • Saving NSString to file

    - by Michael Amici
    I am having trouble saving simple website data to file. I believe the sintax is correct, could someone help me? When I run it, it shows that it gets the data, but when i quit and open up the file that it is supposed to save to, nothing is in it. - (BOOL)textFieldShouldReturn:(UITextField *)nextField { [timer invalidate]; startButton.hidden = NO; startButton.enabled = YES; stopButton.enabled = NO; stopButton.hidden = YES; stopLabel.hidden = YES; label.hidden = NO; label.text = @"Press to Activate"; [nextField resignFirstResponder]; NSString *urlString = textField.text; NSData *dataNew = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]]; NSUInteger len = [dataNew length]; NSString *stringCompare = [NSString stringWithFormat:@"%i", len]; NSLog(@"%@", stringCompare); NSString *filePath = [[NSBundle mainBundle] pathForResource:@"websiteone" ofType:@"txt"]; if (filePath) { [stringCompare writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:NULL]; NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL]; NSLog(@"Saving... %@", myText); } else { NSLog(@"cant find the file"); } return YES; }

    Read the article

  • Converting long value to unichar* in objective-c

    - by conmulligan
    I'm storing large unicode characters (0x10000+) as long types which eventually need to be converted to NSStrings. Smaller unicode characters can be created as a unichar, and an NSString can be created using [NSString stringWithCharacters:(const unichar *)characters length:(NSUInteger)length] So, I imagine the best way to get an NSString from the unicode long value would be to first get a unichar* from the long value. Any idea on how I might go about doing this?

    Read the article

  • App crashes often in a for-loop

    - by Flocked
    Hello, my app crashes often in this for-loop: for (int a = 0; a <= 20; a++) { int b = arc4random() % [newsStories count]; NSString * foo = [[NSString alloc]initWithString:[[newsStories objectAtIndex: arc4random() % b]objectForKey:@"title"]]; foo = [foo stringByReplacingOccurrencesOfString:@"’" withString:@""]; foo = [[foo componentsSeparatedByCharactersInSet:[[NSCharacterSet letterCharacterSet] invertedSet]] componentsJoinedByString:@" "]; foo = [foo stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; textView.text = [textView.text stringByAppendingString:[NSString stringWithFormat:@"%@ ", foo]]; } The code changes a NSString from a NSDictionary and adds it into a textView. Sometimes it first crashes in the second time using the for-loop. What did I wrong?

    Read the article

  • How to declare NSString constants for passing to NSNotificationCenter

    - by synic
    I've got the following in my .h file: #ifndef _BALANCE_NOTIFICATION #define _BALANCE NOTIFICATION const NSString *BalanceUpdateNotification #endif and the following in my .m file: const NSString *BalanceUpdateNotification = @"BalanceUpdateNotification"; I'm using this with the following codes: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBalance:) name:BalanceUpdateNotification object:nil]; and [[NSNotificatoinCenter defaultCenter] postNotificationName:BalanceUpdateNotificatoin object:self userInfo:nil]; Which works, but it gives me a warning: Passing argument 1 of 'postNotificationName:object:userInfo' discards qualifiers from pointer target type So, I can cast it to (NSString *), but I'm wondering what the proper way to do this is.

    Read the article

  • What is NSString in struct?

    - by 4thSpace
    I've defined a struct and want to assign one of its values to a NSMutableDictionary. When I try, I get a EXC_BAD_ACCESS. Here is the code: //in .h file typedef struct { NSString *valueOne; NSString *valueTwo; } myStruct; myStruct aStruct; //in .m file - (void)viewDidLoad { [super viewDidLoad]; aStruct.valueOne = @"firstValue"; } //at some later time [myDictionary setValue:aStruct.valueOne forKey:@"key1"]; //dies here with EXC_BAD_ACCESS This is the output in debugger console: (gdb) p aStruct.valueOne $1 = (NSString *) 0xf41850 Is there a way to tell what the value of aStruct.valueOne is? Since it is an NSString, why does the dictionary have such a problem with it? ------------- EDIT ------------- This edit is based on some comments below. The problem appears to be in the struct memory allocation. I have no issues assigning the struct value to the dictionary in viewDidLoad, as mentioned in one of the comments. The problem is that later on, I run into an issue with the struct. Just before the error, I do: po aStruct.oneValue Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000000 0x9895cedb in objc_msgSend () The program being debugged was signaled while in a function called from GDB. GDB has restored the context to what it was before the call. To change this behavior use "set unwindonsignal off" Evaluation of the expression containing the function (_NSPrintForDebugger) will be abandoned. This occurs just before the EXC_BAD_ACCESS: NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"MM-dd-yy_HH-mm-ss-A"]; NSString *date = [formatter stringFromDate:[NSDate date]]; [formatter release]; aStruct.valueOne = date; So the memory issue is most likely in my releasing of formatter. The date var has no retain. Should I instead be doing NSString *date = [[formatter stringFromDate:[NSDate date]] retain]; Which does work but then I'm left with a memory leak.

    Read the article

  • Passing a string representing my format specifier into stringWithFormat and seeing issues

    - by Jeff
    If I call "[NSString stringWithFormat:@"Testing \n %@",variableString]"; I get what I would expect, which is Testing, followed by a new line, then the contents of variableString. However, if i try NSString *testString = @"Testing \n %@"; //forgive shorthand here [NSString stringWithFormat,testString,variableString] the output actually literally writes \n to the screen instead of a newline. any workaround to this? seems odd to me

    Read the article

  • iphone read txt file from UIWebView

    - by Ni
    I can read the data in file.txt file located in local disk. NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"txt"]; NSString* Data = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error ]; now, I upload the file.txt file into a website. how can i read the data from the txt file now from UIWebView? Please help!!

    Read the article

  • Strange behaviour of NSString in NSView

    - by Mee
    Trying to create a Skat-Game, I encountered the following problem: isBidding is a Boolean value indicationg, the program is in a certain state, [desk selected] is a method calling returning the current selected player, chatStrings consists of dictionaries, saving strings with the player, who typed, and what he typed - (void)drawRect:(NSRect)rect { NSMutableDictionary * attributes = [NSMutableDictionary dictionary]; [attributes setObject:[NSFont fontWithName:playerFont size:playerFontSize] forKey:NSFontAttributeName]; [attributes setObject:playerFontColor forKey:NSForegroundColorAttributeName]; [[NSString stringWithFormat:@"Player %i",[desk selected] + 1]drawInRect:playerStringRect withAttributes:attributes]; if (isBidding) { [attributes setObject:[NSFont fontWithName:chatFont size:chatFontSize] forKey:NSFontAttributeName]; [attributes setObject:chatFontColor forKey:NSForegroundColorAttributeName]; int i; for (i = 0; i < [chatStrings count]; i++, yProgress -= 20) { if (isBidding) [[NSString stringWithFormat:@"Player %i bids: %@",[[[chatStrings objectAtIndex:i]valueForKey:@"Player"]intValue], [[chatStrings objectAtIndex:i]valueForKey:@"String"]] drawAtPoint:NSMakePoint([self bounds].origin.x, yProgress) withAttributes:attributes]; else [[NSString stringWithFormat:@"Player %i: %@",[[[chatStrings objectAtIndex:i]valueForKey:@"Player"]intValue], [[chatStrings objectAtIndex:i]valueForKey:@"String"]] drawAtPoint:NSMakePoint([self bounds].origin.x, yProgress) withAttributes:attributes]; } if (isBidding) [[NSString stringWithFormat:@"Player %i bids: %@",[desk selected] + 1, displayString] drawAtPoint:NSMakePoint([self bounds].origin.x, yProgress) withAttributes:attributes]; else [[NSString stringWithFormat:@"Player %i: %@",[desk selected] + 1, displayString] drawAtPoint:NSMakePoint([self bounds].origin.x, yProgress) withAttributes:attributes]; yProgress = chatFontBegin; } } This is the part determining the string's content, the string is contributed by an [event characters] method. -(void)displayChatString:(NSString *)string { displayString = [displayString stringByAppendingString:string]; [self setNeedsDisplay:YES]; } The problem if have is this: when typing in more than two letters the view displays NSRectSet{{{471, 574},{500, 192}}} and returns no more discription when I try to print it. then I get an EXC_BAD_ACCESS message, though I have not released it (as far as I can see) I also created the string with alloc and init, so I cannot be in the autorelease pool. I also tried to watch the process when it changes with the debugger, but I couldn't find any responsible code. As you can see I am still a beginner in Cocoa (and programming in general), so I would be really happy if somebody would help me with this.

    Read the article

  • Problem in type casting in NSDate to NSString?

    - by Prash.......
    Hi, I developing an application, in which i found a ridiculous problem in type casting, I am not able to type cast NSDate to NSString. NSDate *selected =[datePicker date]; NSString *stringTypeCast = [[NSString alloc] initWithData:selected encoding:NSUTF8StringEncoding]; From ,above snippet datePicker is an object of UIDatePickerController.

    Read the article

  • Problem with NSString

    - by Kassar
    I have a problem with NSString in dynamic binding ... I manipulate with Facebook library, when i'll share my story i should make an instance of FBStreamDialog and charge its attributes with values of the story then show it, like this: FBStreamDialog* dialog = [[[FBStreamDialog alloc] init]autorelease]; dialog.delegate = self; dialog.userMessagePrompt = @"prompt"; NSString* sss=@"{ \"name\":\"%@\", \"href\":\"%@\", \"caption\":\"%@\", \"description\":\"%@\" , \"media\":[{ \"type\":\"image\", \"src\":\"%@\", \"href\":\"%@\" }] }"; dialog.attachment = [NSString stringWithFormat:sss,@"title",@"http://www.docs.com/hi.html",@"caption",@"summary",@"http://www.images.com/206.jpg",@"http://www.images.com/206.jpg"]; NSLog(@"ATTACHMENT: %@",dialog.attachment); The code above is running well. But my problem is when i want to charge these attributes dynamically like this: BStreamDialog* dialog = [[[FBStreamDialog alloc] init]autorelease]; dialog.delegate = self; dialog.userMessagePrompt = @"prompt"; NSString* sss=@"{ \"name\":\"%@\", \"href\":\"%@\", \"caption\":\"%@\", \"description\":\"%@\" , \"media\":[{ \"type\":\"image\", \"src\":\"%@\", \"href\":\"%@\" }] }"; dialog.attachment = [NSString stringWithFormat:sss,story.title,story.link,story.caption,story.summary,story.imagelink,story.imagelink]; NSLog(@"ATTACHMENT: %@",dialog.attachment); It's running without crash but it doesn't share the story it share a blank one !!! Although, it shows in the console (output of NSLog) the value of attachment is true !!! Could you plz help me. Sorry for my english.

    Read the article

  • NSString stringWithFormat question

    - by John Smith
    I am trying to build a small table using NSString. I cannot seem to format the strings properly. Here is what I have [NSString stringWithFormat:@"%8@: %.6f",e,v] where e is an NSString from somewhere else, and v is a float. What I want is output something like this: Grapes: 20.3 Pomegranates: 2.5 Oranges: 15.1 What I get is Grapes:20.3 Pomegranates:2.5 Oranges:15.1 How can I fix my format to do something like this?

    Read the article

  • NSMutableArray memory leak when reloading objects

    - by Davin
    I am using Three20/TTThumbsviewcontroller to load photos. I am struggling since quite a some time now to fix memory leak in setting photosource. I am beginner in Object C & iOS memory management. Please have a look at following code and suggest any obvious mistakes or any errors in declaring and releasing variables. -- PhotoViewController.h @interface PhotoViewController : TTThumbsViewController <UIPopoverControllerDelegate,CategoryPickerDelegate,FilterPickerDelegate,UISearchBarDelegate>{ ...... NSMutableArray *_photoList; ...... @property(nonatomic,retain) NSMutableArray *photoList; -- PhotoViewController.m @implementation PhotoViewController .... @synthesize photoList; ..... - (void)LoadPhotoSource:(NSString *)query:(NSString *)title:(NSString* )stoneName{ NSLog(@"log- in loadPhotosource method"); if (photoList == nil) photoList = [[NSMutableArray alloc] init ]; [photoList removeAllObjects]; @try { sqlite3 *db; NSFileManager *fileMgr = [NSFileManager defaultManager]; NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *dbPath = [documentsPath stringByAppendingPathComponent: @"DB.s3db"]; BOOL success = [fileMgr fileExistsAtPath:dbPath]; if(!success) { NSLog(@"Cannot locate database file '%@'.", dbPath); } if(!(sqlite3_open([dbPath UTF8String], &db) == SQLITE_OK)) { NSLog(@"An error has occured."); } NSString *_sql = query;//[NSString stringWithFormat:@"SELECT * FROM Products where CategoryId = %i",[categoryId integerValue]]; const char *sql = [_sql UTF8String]; sqlite3_stmt *sqlStatement; if(sqlite3_prepare(db, sql, -1, &sqlStatement, NULL) != SQLITE_OK) { NSLog(@"Problem with prepare statement"); } if ([stoneName length] != 0) { NSString *wildcardSearch = [NSString stringWithFormat:@"%@%%",[stoneName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; sqlite3_bind_text(sqlStatement, 1, [wildcardSearch UTF8String], -1, SQLITE_STATIC); } while (sqlite3_step(sqlStatement)==SQLITE_ROW) { NSString* urlSmallImage = @"Mahallati_NoImage.png"; NSString* urlThumbImage = @"Mahallati_NoImage.png"; NSString *designNo = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,2)]; designNo = [designNo stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *desc = [NSString stringWithUTF8String:(char *) sqlite3_column_text(sqlStatement,7)]; desc = [desc stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *caption = designNo;//[designNo stringByAppendingString:desc]; caption = [caption stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *smallFilePath = [documentsPath stringByAppendingPathComponent: [NSString stringWithFormat:@"Small%@.JPG",designNo] ]; smallFilePath = [smallFilePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ([fileMgr fileExistsAtPath:smallFilePath]){ urlSmallImage = [NSString stringWithFormat:@"Small%@.JPG",designNo]; } NSString *thumbFilePath = [documentsPath stringByAppendingPathComponent: [NSString stringWithFormat:@"Thumb%@.JPG",designNo] ]; thumbFilePath = [thumbFilePath stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ([fileMgr fileExistsAtPath:thumbFilePath]){ urlThumbImage = [NSString stringWithFormat:@"Thumb%@.JPG",designNo]; } NSNumber *photoProductId = [NSNumber numberWithInt:(int)sqlite3_column_int(sqlStatement, 0)]; NSNumber *photoPrice = [NSNumber numberWithInt:(int)sqlite3_column_int(sqlStatement, 6)]; char *productNo1 = sqlite3_column_text(sqlStatement, 3); NSString* productNo; if (productNo1 == NULL) productNo = nil; else productNo = [NSString stringWithUTF8String:productNo1]; Photo *jphoto = [[[Photo alloc] initWithCaption:caption urlLarge:[NSString stringWithFormat:@"documents://%@",urlSmallImage] urlSmall:[NSString stringWithFormat:@"documents://%@",urlSmallImage] urlThumb:[NSString stringWithFormat:@"documents://%@",urlThumbImage] size:CGSizeMake(123, 123) productId:photoProductId price:photoPrice description:desc designNo:designNo productNo:productNo ] autorelease]; [photoList addObject:jphoto]; [jphoto release]; } } @catch (NSException *exception) { NSLog(@"An exception occured: %@", [exception reason]); } self.photoSource = [[[MockPhotoSource alloc] initWithType:MockPhotoSourceNormal title:[NSString stringWithFormat: @"%@",title] photos: photoList photos2:nil] autorelease]; } Memory leaks happen when calling above LoadPhotosource method again with different query... I feel its something wrong in declaring NSMutableArray (photoList), but can't figure out how to fix memory leak. Any suggestion is really appreciated.

    Read the article

  • I want to use contents of String or Array in an IF ELSE statement for iphone

    - by Michael Robinson
    I want to check to see if an array is empty to activate a shipping method. Here is the code for returning the array. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullFileName = [NSString stringWithFormat:@"%@/arraySaveFile", documentsDirectory]; NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:fullFileName]; I want to write something like: if NSString *fullFileName ="" ; [nnNEP EnableShipping]; else [nnNEP DisableShipping]; OR if array contents ="" ; [nnNEP EnableShipping]; else [nnNEP DisableShipping]; I just can't find the right or description on how to do this properly. Thanks,

    Read the article

  • Objective-C NSString Assignment Problem

    - by golfromeo
    In my Cocoa application, in the header file, I declare a NSString ivar: NSString *gSdkPath; Then, in awakeFromNib, I assign it to a value: gSdkPath = @"hello"; Later, it's value is changed in the code: gSdkPath = [NSString stringWithString:[folderNames objectAtIndex:0]]; (the object returned from objectAtIndex is an NSString) However, after this point, in another method when I try to NSLog() (or do anything with) the gSdkPath variable, the app crashes. I'm sure this has something to do with memory management, but I'm beginning with Cocoa and not sure exactly how this all works. Thanks for any help in advance.

    Read the article

  • How to bind the arguments in NSString in iphone?

    - by Prash.......
    Hi, i developing an application in which i want to bind my own parameter with an URL for http post request. But i findout the serious problem during the string binding, The code snippet as follows: NSString *mainURL1 = @"http://xxx.xxx.xx.xx/webservice/Service.asmx?op=UserDetailsNew?"; NSString *mainURL2 = [mainURL1 stringByAppendingString:@"MobileNo=%@",txtMobile.text]; NSString *mainURL3 = [mainURL2 stringByAppendingString:@"&Country=%@",txtCountry.text]; NSString *mainURL4 = [mainURL3 stringByAppendingString:@"&UserName=%@",txtName.text]; NSString *mainURL5 = [mainURL4 stringByAppendingString:@"&ScreenName=%@",txtScreenname.text]; NSString *mainURL6 = [mainURL5 stringByAppendingString:@"&EmailId=%@",txtemailid.text]; NSString *mainURL7 = [mainURL6 stringByAppendingString:@"&Password=%@",txtpassword.text]; NSString *mainURL8 = [mainURL7 stringByAppendingString:@"&RetypePassword=%@",txtretypepassword.text]; NSString *mainURL9 = [mainURL8 stringByAppendingString:@"%20HTTP/1.1"]; on binding the runtime arguments it ginev me too many parameter appending in NSString function. how i solve above problem?

    Read the article

  • How to search for a string including spaces in Objective C?

    - by AlexCu
    I have a real basic command-line program, in Objective-C, that searches for user inputed information. Unfourtunately, the code will only read the first word in series of words that the user enters. For example, if the user enters in "Apples are great", only "Apples" is kept (and hence searched later on), excluding the "are great" part of the sentence. Here's what I have so far: char enteredQuery [128]; // array 'name' to hold the scanf string NSString *searchQuery; // ending NSString to hold and compare the user inputed data NSLog(@"Enter search query:"); scanf("%s", enteredQuery); //will read the next line searchQuery = [NSString stringWithCString: enteredQuery encoding: NSASCIIStringEncoding]; //converts scanf data into a NSString type I know it's got to do with me using scanf or the character-encoder conversion, but I can't seem to figure it out. Any help in solving the problem is very appreciated! Thanks.

    Read the article

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