nsstring

Where are constant NSStrings allocated?

I understand that constant CStrings are allocated statically, rather than on the heap. I also noticed that constant NSStrings have an infinite retain count. Does it hold true that constant NSStrings are also allocated statically, rather than on the heap? ...

Comparing an [NSURL path] to an NSString doesn't work

I have this code: NSLog([url path]); if([url path] == @"/connect/login_success.html") { NSLog("IT WORKZ"); } When I run my application, do the login etc... my console says: 2010-05-04 23:49:57.297 Framebook Test Application[8069:a0f] /connect/login_success.html But it should also print IT WORKZ to the console, which it does not...

Objective-C "miscasting" a string/int using stringWithFormat and %d

Hi, I think this is a relatively simple question, but I don't precisely know what's happening. I have a method that tries to build a string using NSString's stringWithFormat It looks like this: NSString *line1 = [NSString stringWithFormat:@"the car is %d miles away", self.ma]; In the above line "self.ma" should be an int, but in my ...

Get a string with ascii code objective-c

I have a ascii code, for the letter 'a', and I want to get a string by its ascii code, is it possible with NSString? ...

Convert a NSString

My situation is explained in the code below. I need to send via a socket NSString drawn from a TextBox Thank you very much NSString *string = fieldTesto.txt; // I Find an istruction for insert s string in to the CFSocketSend UInt8 message[] = "Hello world"; CFDataRef data = CFDataCreate(NULL, message, sizeof(message)); CF...

NSString Library... Anyone know of a helper library for NSString?

Coming from a ruby background, I'm wishing NSString had some convenient methods like the following: [@"John" contains:@"ohn"] => BOOL [@"1,2,3,4," split:@","] => NSArray Anyone know of such an NSString helper library? ...

NSString to NSURL objects

Hello, I have an array that I populated with my plist file, which looks something like this: <array> <string>http://www.apple.com&lt;/string&gt; <string>http://www.google.com&lt;/string&gt; <string>http://www.amazon.com&lt;/string&gt; </array> So, I'm looking to convert these NSString objects to NSURL objects when I call them...

stringByAppendingFormat not working

I have an NSString and fail to apply the following statement: NSString *myString = @"some text"; [myString stringByAppendingFormat:@"some text = %d", 3]; no log or error, the string just doesn't get changed. I already tried with NSString (as documented) and NSMutableString. any clues most welcome. ...

Load a file in a group objective-c Xcode

I'd like to load a file from a specific Group in Xcode/Objective-c for example: I have TWO files named "SomeFile.txt" that are in two different folders (folders not groups yet) in the OS: SomeFolderOne |- SomeFile.txt SomeFolderTwo |- SomeFile.txt Inner Xcode I make two folders, and I put a REFERENCE to these two files: SomeGroupOn...

How to convert an NSString to an unsigned int in Cocoa?

My application gets handed an NSString containing an unsigned int. NSString doesn't have an [myString unsignedIntegerValue]; method. I'd like to be able to take the value out of the string without mangling it, and then place it inside an NSNumber. I'm trying to do it like so: NSString *myUnsignedIntString = [self someMethodReturn...

Trouble correctly formatting NSString for JSON.

Having a little trouble processing my NSStrings into a valid JSON string. NSString *version = @"1.1"; NSString *callMethod = @"auth.login"; NSString *paramsConfig = [NSString stringWithFormat:@"{\"email\":\"%@\",\"password\":\"%@\"}", usernameString, passwordString]; int queryId = arc4random()% 10000000; NSDictionary *us...

Objective-C Decimal to Base 16 Hex conversion

Does anyone have a code snippet or a class that will take a long long and turn it into a 16 byte Hex string? I'm looking to turn data like this long long decimalRepresentation = 1719886131591410351; and turn it into this //Base 16 Hex Output: 17DE435307A07300 The %x operator doesn't want to work for me NSLog(@"Hex: %x",decimalRep...

Get String Value from NSDictionary

I have the following code: NSMutableDictionary *jsonObj = [parser objectWithString:json_string error:nil]; NSString *test = [[[jsonObj objectForKey:@"questions"] valueForKey:@"owner"] valueForKey:key]; but what I get back is: ( 1a19f089a2bc4ee42bff1c102c6e89b8 ) The actual value is fine, but I get those parenthesis, which show up ...

Quick and dirty way to store NSStrings (or other data) from launch to launch?

I want to allow my user to store custom phrases, to be displayed in an editable UITableView. What's a quick and dirty to store these strings? I'm fairly new at iPhone development. I know about Core Data, but not how to use it. i would stay away form that just for this particular project if possible. Are PLIST files a possibility here?...

Detect if NSString contains a URL and generate a "link" to open inside the app a Safari View

I have am reading a twitter feed in my iPhone application and can do it correctly, but I'd like to evolve it in a way to detect if the whole NSString contains any URL or URLs and create a "link" that will open a UIWebView within the same application. Can you guide me on how to perform this task? -(void) setTextTwitter:(NSString *)text ...

iPhone NSString drawAtPoint linebreakmodeWordWrap

Hello, Since I had a very slow scrolling tableView I'm now trying to catch up with the direct draw method, similiar to the Tweetie App sample or Apples TableViewSuite code. So right now I'm struggling to draw NSString with more than one line. I'm using the [NSString drawAtPoint: forWidth: withFont: linebreakMode:] method, and it "brea...

How Do I Test for Existence of an External Constant NSString?

In iPhone SDK 3.2, the MediaPlayer framework was expanded. One of the constants newly defined in the framework is MPMediaPlaybackIsPreparedToPlayDidChangeNotification. I'm building a universal app. How can I test at run time for the existence of this constant? If the constant exists, then my app can use this newer notification. If not,...

[SOLVED] Iphone NSXMLParser NSCFString memory leak

I am building an app that parses an rss feed. In the app there are two different types of feeds with different names for the elements in the feed, so I have created an NSXMLParser NSObject that takes the name of the elements of each feed before parsing. Here is my code: NewsFeedParser.h #import @interface NewsFeedParser : NSObjec...

how can I copy a string displayed in a UITableViewCell into another NSString?

Hey I am writing a program, and one part of my program has a UItableView in which I set cell contents manually by using the following... cell.textLabel.text = @"CELL CONTENTS HERE!"; How can I copy a string displayed in a particular TableView Cell into another NSString? ...

How do I convert an NSMutableString to NSString when using Frameworks?

I have written an Objective-C framework which builds some HTML code with NSMutableString which returns the value as an NSString. I have declared an NSString and NSMutableString in the inteface .h file: NSString *_outputLanguage; // Tests language output NSMutableString *outputBuilder; NSString *output; This is a sample from th...