Search Results

Search found 605 results on 25 pages for 'stringwithformat'.

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

  • iPhone: NSTimer Countdown (Display Minutes:Seconds)

    - by user298261
    Hello! I have my timer code set up, and it's all kosher, but I want my label to display "Minutes : seconds" instead of just seconds. -(void)countDown{ time -= 1; theTimer.text = [NSString stringWithFormat:@"%i", time]; if(time == 0) { [countDownTimer invalidate]; } } I've already set "time" to 600, or 10 minutes. However, I want the display to show 10:59, 10:58, etc. until it reaches zero. How do I do this? Thanks!

    Read the article

  • release does not free up memory in low-memory condidtion

    - by user322945
    I am trying to follow the Apple's recommendation to handle low-memory warnings (found in Session 416 of WWDC 2009 videos) by freeing up resources used by freeing up my dataController object (referenced in my app delegate) that contains a large number of strings for read from a plist: - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { [_dataController release]; _dataController = nil; NSLog([NSString stringWithFormat:@"applicationDidReceiveMemoryWarning bottom... retain count:%i", [_dataController retainCount]]); } But when I run ObjectAlloc within Instruments and simulate a Low-Memory Condition, I don't see a decrease in the memory used by my app even though I see the NSLog statements written out and the retain count is zero for the object. I do pass references to the app delegate around to some of the view controllers. But the code above releases the reference to the _dataController object (containing the plist data) so I would expect the memory to be freed. Any help would be appreciated.

    Read the article

  • UITableViewCell imageView.contentMode doesn't work in 3.0

    - by JustinXXVII
    In UITableViewCellStyleDefault, setting the contentMode on the imageView has no result. If I change my build SDK to version 3.1, everything again works. I don't get any warnings or errors when compiling on 3.0 but this code: cell.imageView.contentMode = UIViewContentModeScaleAspectFit; cell.imageView.image = [UIImage imageNamed:[[NSString stringWithFormat:@"%@head.jpg",[gametype objectAtIndex:indexPath.row]]lowercaseString]]; seems to default to the UIViewContentModeCenter, so all of my pictures exceed the cell boundaries and encroach on neighboring cells. Let me reiterate that if I change my target to 3.1 everything works correctly and all pictures are scaled accordingly to fit in the default imageView Is this a known bug?

    Read the article

  • How to use LIKE query in sqlite & iPhone

    - by 4thSpace
    I'm using the following for a LIKE query. Is this technique for LIKE correct? selectstmtSearch = nil; if(selectstmtSearch == nil){ const char *sql = "SELECT col1, col2 FROM table1 t1 JOIN table2 t2 ON t1.cityid = t2.cityid where t1.cityname like ?001 order by t1.cityname"; if(sqlite3_prepare_v2(databaseSearch, sql, -1, &selectstmtSearch, NULL) == SQLITE_OK) { sqlite3_bind_text(selectstmtSearch, 1, [[NSString stringWithFormat:@"%%%@%%", searchText] UTF8String], -1, SQLITE_TRANSIENT); } } The problem I'm having is after a few uses of this, I get an error 14 on sqlite3_open(), which is unable to open database. If I replace the LIKE with something such as: SELECT col1, col2 FROM table1 t1 JOIN table2 t2 ON t1.cityid = t2.cityid where t1.cityname = ? order by t1.cityname It works fine. I do open/close the DB before after the above code. Is there a way to troubleshoot exactly why the database can't be opened and what its relationship to my LIKE syntax is?

    Read the article

  • New line and returns ignored in setMessageBody

    - by Magic Bullet Dave
    Am I doing something dumb? I can pre-fill and email ok but the "\r\n" is ignored in the emailBody: - (void) sendEventInEmail { MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; NSString *emailSubject = [eventDictionary objectForKey:EVENT_NAME_KEY]; [picker setSubject:emailSubject]; // Fill out the email body text NSString *iTunesLink = @"http://itunes.apple.com/gb/app/whats-on-reading/id347859140?mt=8"; // Link to iTune App link NSString *content = [eventDictionary objectForKey:@"Description"]; NSString *emailBody = [NSString stringWithFormat:@"%@\r\nSent using <a href = '%@'>What's On Reading</a> for the iPhone.", content, iTunesLink]; [picker setMessageBody:emailBody isHTML:YES]; picker.navigationBar.barStyle = UIBarStyleBlack; [self presentModalViewController:picker animated:YES]; [picker release]; } Regards Dave

    Read the article

  • Objective-c string appending causes exception

    - by Dave C
    Hello Everyone, The following code is causing me some problems. The third line causes a program crash... it doesn't happen the first time I step through but somehow later on in the program. If I comment out that third line, the program runs smoothly. NSString *myRequestString = @"text"; int i = 1; myRequestString = [myRequestString stringByAppendingString:[NSString stringWithFormat: @"t=%d", i]]; That code causes this exception: * -[CFString release]: message sent to deallocated instance 0xb4c43fe0 On a side note, can anyone tell me how to concatenate strings in objective-c like any other normal language... I can't believe that there is no concatenation operator. Any and all help is greatly appreciated.

    Read the article

  • Why can I not receive touch events within my custom UIScrollView subclass?

    - by stefanosn
    i have an uiscrollview with a uiimageview inside. I subclass the uiscrollview but i can not get touches to work touchbegin does not called. What should i do to call uitouch event? what is wrong? .h #import <UIKit/UIKit.h> @interface myScrollView : UIScrollView { } @end .m #import "myScrollView.h" @implementation myScrollView - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view]; if (touch.view.tag > 0) { touch.view.center = location; } NSLog(@"tag=%@", [NSString stringWithFormat:@"%i", touch.view.tag]); }

    Read the article

  • Why are my "tel:" links not working

    - by Griffo
    I have a tableView which has cells with phone numbers. The app is not dialing the numbers though. See the code below - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 2) { UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; NSString *numberToDial = [NSString stringWithFormat:@"tel:%@", selectedCell.detailTextLabel.text]; NSLog(@"%@",numberToDial); [[UIApplication sharedApplication] openURL:[NSURL URLWithString:numberToDial]]; } } Console ouput: 2010-03-08 01:32:30.830 AIB[1217:207] tel:01 8350098 As you can see, the number goes to the console, but doesn't get dialled. The weird thing is, if I change the last statement to this: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:171"]]; the phone dials the number 171 without any issue

    Read the article

  • nsstring - out of scope

    - by alexeyndru
    -(void)loadWebAdress:(NSString*)textAdress { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; adressurl=[NSString stringWithFormat:@"http://%@", textAdress]; NSURL *url=[NSURL URLWithString:adressurl]; NSURLRequest *requestObj=[NSURLRequest requestWithURL:url]; [webview loadRequest:requestObj]; } although url takes it's value from adressurl, adressurl is all the time out of scope when checked in debugger. what is going on? i would like to use it in some other places too. not only in this method. because is out of scope, the app crashes. But, I repeat, it is the one who gives its value to url.

    Read the article

  • iPad UIViewController loads as portrait when device is in landscape

    - by jud
    I have an application with 3 view controllers. They are all have shouldAutoRotateToInterfaceOrientation returning YES. The first two, my main menu and my submenu both autorotate just fine. The third viewcontroller, which programatically loads a UIImageView from a jpg file in the program's bundle, will only display in portrait. In the viewcontroller containing the image, i have this: NSString *imageName = [NSString stringWithFormat:@"%@-00%d.jpg",setPrefix,imageNumber]; UIImageView *pictureView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]]; pictureView.frame = CGRectMake(0, 0, 1024, 768); [self.view addSubview:pictureView]; and again, I have shouldAutoRotateToInterfaceOrientation returning YES for all orientations. My image shows up, but is sideways, and the 0,0,1024,768 values I used to make my rectangle start from the top right corner going down, instead of starting at the top left and going across (holding in landscape). Am I missing a parameter I need to set in order to ensure the imageview shows up in landscape instead of portrait?

    Read the article

  • Adding # & search sign to TableIndex in UITableView

    - by sagar
    In iPhone native Phone book - there is a search character at the top & # character at the bottom. I want to add both of that character in my table Index. Currently I have implemented following code. atoz=[[NSMutableArray alloc] init]; for(int i=0;i<26;i++){ [atoz addObject:[NSString stringWithFormat:@"%c",i+65]]; } - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{ return atoz; } How to have # character & search symbol in my UITableView? Thanks in advance for sharing your knowledge. Sagar

    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

  • Why does my UIButton.titleLabel.text disappear when I place an image in the button?

    - by nickthedude
    I've had this problem before but was able to work around it until now, Basically I'm creating a custom UIbutton setting its image as a uiimage and then the button that has had a label until I implimented the below code now loses its label. I need that label because it is set programatically in code that follows. NSString *imageName = [NSString stringWithFormat:kNameOfButtonimage ]; UIImage *image = [UIImage imageNamed:imageName]; [button setImage:image forState:UIControlStateNormal ]; Any help you could lend would be mucho appreciated. -nick

    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

  • Problem with migrating from Texture2D to CCTexture2D (Setting CCSprite texture)

    - by marie
    My problem is that whenever I change the texture of a sprite, the new texture will retain the size of the original sprite's texture. I have this code: mySprite = [CCSprite spriteWithFile:@"mySprite.png"]]; ... // change current stage here CCTexture2D *newTexture=[[[CCTexture2D alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"stage number %d.png",currentStageNumber]]]autorelease]; [mySprite setTexture:newTexture]; The new sprite is stretched or compressed depending on the size of the original sprite. If the original sprite is larger, the new texture is stretched. I didn't have this problem when I was using cocos2d v0.8 What am I doing wrong?

    Read the article

  • iphone: how do I obtain a list of all files with a given extension on the app's document folder?

    - by Mike
    I have saved all my files using something like this NSString *fileName = [NSString stringWithFormat:@"%@.plist", myName]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName]; [myDict writeToFile:appFile atomically:YES]) //where myDic is a dictionary containing the value of all parameters I would like to save. All these files were saved with the .plist extension. The same directory contains several JPG and PNG files. Now, how do I retrieve the list of all .plist files on that directory? thanks for any help.

    Read the article

  • iPhone in-App email

    - by varunwg
    Hi, I am using iPhone in-App email feature to send email thru my app. The email goes fine but I am having hard time trying to figure out how to retrive email addresses to which the email was sent. MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker setSubject:@"Test"]; // Fill out the email body text NSString *emailBody = [NSString stringWithFormat:@"This is a test data"]; [picker setMessageBody:emailBody isHTML:YES]; picker.navigationBar.barStyle = UIBarStyleBlack; [self presentModalViewController:picker animated:YES]; [picker release]; Is there any way to retrive those email addresses from this function: - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error Thanks!

    Read the article

  • UIImage from NSDocumentDirectory leaking memory

    - by Emil
    Hey. I currently have this code: UIImage *image = [[UIImage alloc] initWithContentsOfFile:[imagesPath stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@.png", [postsArrayID objectAtIndex:indexPath.row]]]]; It's loading in an image to set in a UITableViewCell. This obviously leaks a lot of memory (I do release it, two lines down after setting the cells image to be that image), and I'm not sure if it caches the image at all. Is there another way, that doesen't leak so much, I can use to load in images multiple times, like in a tableView, from the Documents-directory of my app? Thanks.

    Read the article

  • Localizing concatenated or dynamic strings

    - by SooDesuNe
    I'm familiar with using NSLocalizedString() to localize strings, but the problem I have today requires a little more finesse. My situation is like this: NSString *userName; //the users name, entered by the user. Does not need localized NSString *favoriteFood; //the users favorite food, also entered by user, and not needing localized NSString *summary = [NSString stringWithFormat:@"%@'s favorite food is %@", userName, favoriteFood]; This works fine for english, but not every language uses the same word ordering as English, for example, a word-by-word translation of the same sentance from Japanese into English would read: UserName's favorite food pizza is Not to mention that 's is doesn't make a possessive in every language. What techniques are available for localizing this type of concatenated sentence?

    Read the article

  • Saving CSV in cocoa

    - by happyCoding25
    Hello, I need to make a cvs file in cocoa. To see how to set it up I created one in Numbers and opened it with text edit it looked like this: Results,,,,,,,,,,,, ,,,,,,,,,,,, A,10,,,,,,,,,,, B,10,,,,,,,,,,, C,10,,,,,,,,,,, D,10,,,,,,,,,,, E,10,,,,,,,,,,, So to replicate this in cocoa I used: NSString *CVSData = [NSString stringWithFormat:@"Results\n,,,,,,,,,,,,\nA,%@,,,,,,,,,,,\nB,%@,,,,,,,,,,,\nC,%@,,,,,,,,,,,\nD,%@,,,,,,,,,,,\nE,%@,,,,,,,,,,,",[dataA stringValue], [dataB stringValue], [dataC stringValue], [dataD stringValue], [dataE stringValue]]; Then [CVSData writeToFile:[savePanel filename] atomically:YES]; But when I try to open the saved file with Numbers I get the error “Untitled.cvs” could not be handled because Numbers cannot open files in the “Numbers Document” format. Could this be something with the way cocoa is encoding the file? Thanks for any help

    Read the article

  • Dialing a command prefix on the iPhone

    - by tewha
    Our application lets users call phone numbers. Users would like to be able to block their caller ID. On other platforms, we let the user specify a custom dialing prefix. For instance, on my cell provider it's #31#. I've tried two approaches so far. First: id url = [NSURL URLWithString: @"tel:#31#0000000"] // produces nil Second: id encoder = ["#31#0000000" stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; // produces %2331%230000000 id url = [NSURL URLWithString: [NSString stringWithFormat: @"tel:%@", encoded]]; // produces a valid-looking NSURL which doesn't do anything I'm thinking at this point that I'm just not allowed to dial # and *, even from a Cocoa touch application. (I know it's not allowed from a web app.) Is this true, or am I missing something obvious?

    Read the article

  • UIAlertView with subview animating to new view crashes app

    - by William
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Congratulations" message:message delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"View", nil]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(110, 100, 80, 80)]; NSString *imagePath = [NSString stringWithFormat:@"%@", [Array objectAtIndex:x]]; UIImage *bkgImg = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:imagePath ofType:@"png"]]; imageView.image = bkgImg; [bkgImg release]; [alert addSubview:imageView]; [imageView release]; [alert show]; [alert release]; That is the code that I am using to create the alert view. Currently, I have it set up so if the user presses one of the buttons, it will load up a new viewcontroller. It worked fine until I added a subview to the UIAlertView. Now, whenever it animates to the new screen, it just crashes the program. I am fairly new to iPhone development and any help would be appreciated.

    Read the article

  • iPhone facebook connect FQL Query to get Profile URL.

    - by user306641
    Hai. I am using Face book Connect FQL Queries to extract my profile photo url that is src_big,src_small URL. But i am always getting the empty array in below delegate (void)request:(FBRequest*)request didLoad:(id)result My FQL query is. NSString* fql = [NSString stringWithFormat:@"SELECT src_big,src_small FROM photo WHERE pid IN (SELECT cover_pid FROM album WHERE owner =%lld AND name ='Profile Pictures')", session.uid]; NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"]; [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params]; But - (void)request:(FBRequest*)request didLoad:(id)result always return the empty result. Can any one please correct me if there any mistake.

    Read the article

  • iPhone Google Maps KML Search

    - by satyam
    I'm using Google maps with KML Query. But my query string is "Japanese" string "??????" I'm using http://maps.google.co.jp. When requesting data, I'm getting "0" bytes. But the same query when I put in browser, its download a KML file. My code is as follows: query = [NSString stringWithFormat:@"http://maps.google.co.jp/maps?&near=%f,%f&q=??????&output=kml&num=%d", lat,lon, num]; NSURL* url = [NSURL URLWithString:query]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; NSLog(@"Quering URL = %@", url); NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] autorelease]; NSData *myData = [NSURLConnection sendSynchronousRequest:request returningResponse: &response error: nil ]; NSInteger errorcode = [response statusCode]; I'm receiving "myData" with 0 bytes. why?

    Read the article

  • How do I write an IF ELSE to check string contents of an array?

    - by Michael Robinson
    I'm trying to write an IF ELSE statement to enable shipping, If user doesn't add an address the array contents remain as "-" & "-" for the two items in the array. I want to check to see if those are in the array, if they are then I want to enableshipping. Here is the code for getting 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]; How do I write this first line to look for the "-" & "-"? if ([fullFileName isEqualToString:@"-","-"]) { [nnNEP EnableShipping]; } else { [nnNEP DisableShipping]; } Thanks, michael

    Read the article

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