nsstring

NSString memory leak

//opening DB if(sqlite3_step(statement) == SQLITE_ROW) result = [NSString stringWithUTF8String:(char*)sqlite3_column_text(statement,0)]; //! else result nil; return result; //close DB ...

How to get subString of a page of a long NSString, font size variable?

I have a very long text, I defined it as NSString, so I need paging, there will be different paging for different fonts, say I'd like to display one page on a multiple line UILabel. So at frist I need to get substring of page by page of the long string. Does anyone know good solution for this? Thanks in advance. I know there is a NSStr...

How to parse a file for iphone? Should I use NSScanner?

Hi, So I am new to iphone development, but am trying to learn how to take a file that is CSV and read it and save it using Core Data (I think that is the best way?) so that I can display it in a tableview on the iphone. Below is an example of the type of csv file I am working with; 13,1,1,History,,,,,,1 ,263,1,Smith,Bob,Freshman ,317,...

iPhone SDK initializing NSString warning messag

I think this is a quick question and answer - I'm reading a dictionary entry for a detail view which is pushed from a tableview row. but in the detail view, when I'm picking up the data to display (as an HTML page) I'm getting the message: incompatible Objective-C types initializing 'struct NSDictionary *'. expected 'struct NSString *' C...

iPhone SDK : NSString NSNumber IEEE-754

Hi everybody ! Can someone help me ? I have a NSString with @"12.34" and I want to convert it into a NSString with the same float number but in single precision 32bits binary floating-point format IEEE-754 : like @"\x41\x45\x70\xa4" (with hexa characters) or @"AEp¤"... I'm sure it's something easy but after many hours of reading the doc...

Adding a newline to a UITextView

I've been searching for an answer to this question on google and some other forums, but I haven't found the answer yet. It seems like a simple enough question: how do I manually insert a newline into UITextView's text field? If it matters, I'm reading my string from an SQLite database. That means that I'm translating a const char (I thi...

Trying to Understand NSString::initWithBytes

I'm attempting conversion of a legacy C++ program to objective-C. The program needs an array of the 256 possible ASCII characters (8-bits per character). I'm attempting to use the NSString method initWithBytes:length:encoding: to do so. Unfortunately, when coded as shown below, it crashes (although it compiles). NSString* charass...

How to set a CGFloat to a UILabel's text property

I have a UILabel called optionsDisplayerBrushSizeLabel who's text property I want to set to a CGFloat: brushSizeVal. I understand that the text property needs to be a string but I don't know how to convert a CGFloat to an NSString. ...

Problem with stringByTrimmingCharactersInSet:

Hi all, I'm doing a very simple trimming from a string. Basically it goes like this: int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *s = [[NSString alloc] initWithString:@"Some other string"]; s = [s stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceA...

URLWithString: returns nil

Hi, it may be very easy, but I don't seems to find out why is URLWithString: returning nil here. //localisationName is a arbitrary string here NSString* webName = [localisationName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString* stringURL = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@,Mon...

Merge 5 NSStrings in Objective-C

I have multiple NSStrings and i wish to merge them into one other, here is my code so far... NSString *newURL = [_parameters objectForKey:@"url"]; NSString *emailBody = @"Hey!<br>I just snipped my long url with <a href=\"http://itunes.com/app/SnippetySnip\"&gt;Snippety Snip for iPhone</a> in just a few seconds, why not check it out?<p><...

NSString sizeWithAttributes: content rect

How do I get a NSString's size as if it drew in an NSRect. The problem is when I try -[NSString sizeWithAttributes:], it returns an NSSize as if it had infinite width. I want to give a maximum width to the method. Is there any way of doing so? (BTW: Mac OS, not iPhone OS) Thanks, Alex ...

Extract first word from UITextView

In my app I have a UILabel which is the title and a UITextView which is the description and I want the title UILabel to be the first word typed into the UITextView. Does anyone know how to do this? ...

How to get a string from a UITextField?

How would I go about getting a string from a UITextField in the iPhone SDK? I'm trying to insert it into another concatenated string. ...

Cocoa Array of Objects to String

Hey there, I have an NSMutableArray of objects. Each object has a property called "Name". I want to join them together in a string with a separator " > ". So if the name property in each of the objects in my array is "one", "two" and "three" respectively, the result would be "one > two > three". Thanks, howie ...

Cocoa array to string truncated

I'm trying to join an array of objects into a string that will ultimately be used to populate the detail label of a table cell. if the text is too long it will automatcally truncate and add an elipse at the end. I want to avoid this by checking that the string is less than say 40 characters and adding an elipse in the middle instead. ...

How to check if NSString is numeric or not

Possible Duplicate: iphone how to check that a string is numeric only I have one NSString, then i want check the string is number or not. I mean NSString *val = @"5555" ; if(val isNumber ){ return true; }else{ retun false; } How can I do this in Objective C? ...

Saving file from NSString. Objective-c

Hello Everyone! How can i do this? I know ho to do this on windows, but here.. im newer )) SDK: Mac OS X 10.5 ...

NSString: newline escape in plist

I'm writing a property list to be in the resources bundle of my application. An NSString object in the plist needs to have line-breaks in it. I tried \n, but that doesn't work. What do I do to have newlines in my string in the plist? Thanks. ...

NSString self modifying category dilema

Both work, but... Which one would you use and why ? @implementation NSString (Extender) -(NSString *) stringByTrimmingPrefix:(NSString *)strPrefix { while ([self hasPrefix:strPrefix]) { self = [self substringFromIndex:strPrefix.length]; } return self; } @end or @implementati...