nsstring

how to remove a particular sign from a string ?

i have a string gpbusd~buy~~~~update~HIT 40 PIPS~HIT 110 PIPS~~gpbusd~buy~~~BREAK EVEN~update~HIT~100+~~gpbusd~buy~1.5500/25~1.5455~~new~40~100+~~gpbusd~buy~~~~update~CLOSE 0 TO 10 PIPS N~~~gpbusd~buy~1.5335/50~1.5320~~new~40~80+~~gpbusd~buy~~~~update~~15-20 PIPS CLOSE~KEEP OPEN~gpbusd~buy~1.5530/50~~1.5505~update~HIT~80~KEEP OPEN~gpbu...

Getting Wikipedia Article Summary using NSScanner Problem

hello, I am trying to get the summary of an article and download it as a string. This works great with some articles, but the wikipedia website is inconsistent. So NSScanner fails pretty often while it works fine for other articles. Here's my NSScanner implementation: NSString *separatorString = @"<table id=\"toc\" class=\"toc\">"; ...

Expected specifier-qualifier-list before '*' token Objective C

Hello Would anyone be kind enough to explain to me what I'm doing wrong. I'm giving it : #import <Foundation/Foundation.h> @interface Product : NSObject { NSString *imageAddress; NSString *name; NSString *title; } @property (nonatomic, retain) *imageAddress; @property (nonatomic, retain) *name; @property (nonatomic, re...

iPhone POST request truncates string

Hello all, When I try to send out a POST request to a specific site the string I try to send gets cut off. When I check the length of the string in Xcode it is about 55000 characters long. The amount of characters received on the site is about 4500. This is my code: -(IBAction)convert { NSString *rosterText = [webView stringByEvaluat...

How to use printf with NSString

I need to use something like NSLog but without the timestamp and newline character, so I'm using printf. How can I use this with NSString? ...

How to get a single character from an NSString

This is what I'm using [[remaining_string substringFromIndex:k] substringToIndex:1] Is there a better way? ...

How to convert an NSString to char

I am trying to convert an NSString to a ResType, as defined below in MacTypes.h. FourCharCode // A 32-bit value made by packing four 1 byte characters together typedef FourCharCode ResType; I think I could use [aString getCharacters:range:], but is there a more straight forward way to make this conversion? After trying suggestions fr...

Why does this sometimes crash

Inside the function - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { I create an NSString, then give cell.textLabel.text the value of this string. Then I release it. The program will crash on getting one of the fields at the end. If I don't release the NSString, then the progr...

When not to alloc and init an NSString

Whenever I need to create a new NSString variable I always alloc and init it. It seems that there are times when you don't want to do this. How do you know when to alloc and init an NSString and when not to? ...

Matching Strings in Objective C

I have a for loop which loops through an array and want to match a search field's text to an object in the array. I have the following code for (int i = 0; i < [data2 count]; i++) { if ([data2 objectAtIndex:i] == searchField.text) { NSLog(@"MATCH"); break; } } I know in Java it can be done by e.g. if(searchFi...

id type to NSString

is there any way by which I can change an id type to NSString object? note the following line of my code. NSString *value = [appDelegate.bird_arr objectAtIndex:rowClicked] ; in this appDelegate is object of my AppDelegate class in a navigation based program and bird_arr is object of NSMutableArray. I want to use the string written in ...

How to create this string encoding thing?

I have an NSURL object to an text file, but the simple reader method of NSString is deprecated. Now, there's this complex one: + (id)stringWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)error How can I provide the correct encoding here? I have an text file which I created in Smultron and edited in Xcod...

How to split long NSString into pages

I have a long NSString I want to display over a couple of pages. But to do this, I need to find out how much text will actually fit on the page. [NSString sizeWithFont: ...] Is not enough, it will just tell me if the text fits in the rectangle or not, if its does not, it will silently truncate the string, but it won't tell me where it ...

iphone NSString directly use cause memory leaks?

Hello For NSString, we can use NSString *str = [[NSString alloc] initWithString:@"hi"] NSString *str = [NSString stringWithString:@"hi"]; NSString *str = @"hi"; Can someone pls told me in the form of point 3, whether str own @"hi"? I mean whether I need to [str release] when clean up? Thanks for point 1, yes, I need; for point 2...

Objective-C: Facebook username from link returned by Graph API call

Fetching http://graph.facebook.com/514417 from the Facebook Graph API gives me the NSString @"http://www.facebook.com/mattdipasquale". How do I extract just mattdipasquale every time? Can I assume the link will be the same format every time? In that case, I could just do: NSString *fbUsername = [[result valueForKey:@"link"] substringFro...

NSString issue for iphone application

I'm using a NSDictionary to get a NSString from a plist with the following code: NSString *fullPath = [[NSBundle mainBundle] pathForResource:@"TestIds" ofType:@"plist"]; NSDictionary *dictionary = [[NSDictionary dictionaryWithContentsOfFile:fullPath] retain]; NSString *testid = [dictionary objectForKey:@"testId"]; and then I save it i...

Is it possible to bold an NSString?

Is it possible to make an NSString bold? If so, how? I am not using UILabel or UIIextView for some reason. ...

Writing a string to disk in OPENSTEP (YellowBox)

I'm debugging an old OPENSTEP (YellowBox) app, written in Objective-C, running on Windows 2000, built with Project Builder. The only easy way I can find to write a string to disk in Obj-C is [NSString writeToFile], a Cocoa/iOS-era method which doesn't seem to have been written yet in the version of OPENSTEP that I'm compiling against (us...

iPhone: Return NSMutableArray in method while still releasing

I am trying to understand a little more about memory management. Knowing that I need to release anything that I have init or alloc'ed I am confused about the following: - (NSMutableArray *)getData { NSMutableArray *data = [[NSMutableArray alloc] init]; NSString *first = @"First object"; [data addObject:first]; NSString ...

How to get a single NSString character from an NSString

I want to get a character from somewhere inside an NSString. I want the result to be an NSString. This is the code I use to get a single character at index it: [[s substringToIndex:i] substringToIndex:1] Is there a better way to do it? ...