Questions tagged [nsstring]

NSString is the plain-text character-string class in Cocoa and Cocoa Touch. See also NSMutableString, NSData and NSMutableData (for objects that contain bytes rather than human-language characters), and NSAttributedString and NSMutableAttributedString (for rich-text strings).

nsstring
Filter by
Sorted by
Tagged with
11 votes
2 answers
3k views

NSString unique file path to avoid name collisions

Is there a simple way to take a given file path and modify it in order to avoid name collisions? Something like: [StringUtils stringToAvoidNameCollisionForPath:path]; that for a given path of type: /...
daveoncode's user avatar
  • 19.2k
7 votes
15 answers
9k views

Remove http:// from NSString

How do I remove certain text from a NSString such as "http://"? It needs to be exactly in that order. Thanks for your help! Here is the code I am using, however the http:// is not removed. Instead it ...
Jack Humphries's user avatar
0 votes
3 answers
1k views

Call NSString in UIAlertView?

hey I'm coding using theos and I want the value of an NSString to display inside of the fields on the UIAlertView below, how would i go about writing that? here it is: UIAlertView *quickreply = [[...
iExiledDev's user avatar
1 vote
2 answers
311 views

problem while trimming the NSstring in objective c in an iphone app

i have a string like "qytwyqteqe" i want only qytwyqteqe but not the symbol "" i tried to trim this string using the following code but its giving error can any one help me pls, thanx in advance ...
Ravi's user avatar
  • 1,759
0 votes
1 answer
75 views

Array is having extra symbols other than which i added, trimming the array in iphone app using objective c

in my iphone app i am adding string values to the array first strSelectedDir value ill be xxx-jan16-2011-10.30AM later its value ill be xxx-feb16-2011-02.30PM ,,i am adding these 2 values into the ...
Ravi's user avatar
  • 1,759
3 votes
4 answers
5k views

Separate digits in an NSString to display a phone number

I have an NSString that holds something like this: 4434332124 How can I make that into something like this? 443-433-2124
James Dunay's user avatar
  • 2,724
1 vote
2 answers
1k views

Sending hexadecimal data to devices (Converting NSString to hexadecimal data)

I'm trying to send hexadecimal data via WiFi. The code is something like this: NSString *abc = @"0x1b 0x50"; NSData *data = [[[NSData alloc] initWithData:[abc dataUsingEncoding:...
user774150's user avatar
  • 1,072
0 votes
1 answer
124 views

Turning UILabel to NSString with same size and alignment

Is there any way to make a NSString out of a UILabel while keeping the size and alignment? I need this for a section header in a UITableView.
Aaron's user avatar
  • 93
0 votes
1 answer
79 views

Make this code more efficient?

I have the below code, and I would like to make it more efficient. Currently it is a tad slow and I want to make it faster. I know there is something I can do here but not sure what to do to make it ...
SimplyKiwi's user avatar
  • 12.4k
0 votes
1 answer
2k views

Convert NSString->NSDate?

I need to convert my NSString in the end to an NSDate but I am having problems doing so. How would I achieve the same functionality with this code while making the end result an NSDate? //Date and ...
SimplyKiwi's user avatar
  • 12.4k
1 vote
2 answers
1k views

How to set NSString* property from another class?

Please look to the following code. FirstViewController.h: @interface FirstViewController : UIViewController { NSString* inputData; } @property (nonatomic, copy/retain) NSString* inputData; ...
Dmitry's user avatar
  • 14.5k
0 votes
2 answers
731 views

NSString - stringWithFormat released automatically

@property(nonatomic, retain) NSString *password; -(id)init { ... password=[NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]]; OR password=[[NSProcessInfo ...
Bipin M's user avatar
  • 33
0 votes
1 answer
4k views

NSNumber: stringValue crashes, description works

[measureValue stringValue] gives me this exception: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString stringValue]: unrecognized selector sent to ...
aneuryzm's user avatar
  • 64k
0 votes
2 answers
296 views

NSString value not retained

I'm trying to assign data from a string to another string within a different viewcontroller however it seems that the data is not retained - i get a null response in NSLog. I would like to know why, ...
Spike Lee's user avatar
  • 411
0 votes
2 answers
85 views

Why does NSString become empty (without reason)?

I am going crazy with Objective C. Please look to the following code. FirstViewController.h: @interface FirstViewController : UIViewController { IBOutlet UITextView *textView; IBOutlet ...
Dmitry's user avatar
  • 14.5k
4 votes
3 answers
2k views

How to count the number of uppercase characters in a NSString?

I'm trying to find out the best way to count the number of uppercase characters that are in a NSString. I know how to find out if a certain character is uppercase by using this code: NSString *s = @"...
0SX's user avatar
  • 1,272
6 votes
1 answer
1k views

Is this a right and most efficient way to remove blank string from NSArray?

Is this a right and most efficient way to remove blank string from NSArray? int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSMutableArray *...
Parth Bhatt's user avatar
  • 19.5k
0 votes
1 answer
208 views

Releasing a returned-by-reference NSString causes crash

The following method takes a double pointer to NSString and populates this with a value, as follows: @implementation Exp - (int) func:(NSString**) dpStr { //------ *dpStr = [self func_2]; ...
macdev30's user avatar
  • 245
0 votes
1 answer
718 views

How to extract a substring which matches a pattern?

I must parse big html text files and extract substrings which match a certain pattern. For example: <span id='report-9429'>Report for May 2009</span> A lot of code and text. <span id='...
openfrog's user avatar
  • 40.5k
0 votes
2 answers
723 views

Cut out a part of a long NSString

In my app I want to show a String that contains news. This string is being loaded just from a free Website, so the plain source code of the website does not contain only my string, its is more os less ...
JonasG's user avatar
  • 9,314
0 votes
2 answers
236 views

How to convert NSScanner value to string?

hi guys can you tell me how get the value from NSScanner in a string? infect i have to extract int value from a string i am extracting it using scanner now my value is in scanner. now how to get that ...
Mashhadi's user avatar
  • 3,014
1 vote
1 answer
2k views

NSString leaking memory

I'm kinda new in finding memory leaks in objective c and how to fix them. I'm know how to use alloc/init/copy and release/retain but ( a least i think so :-) ) but i have some strange memory leaks in ...
Melvin's user avatar
  • 3,421
0 votes
1 answer
559 views

NSPredicate is not filtering the results of a fetch request

OK. This one has me beat. The CoreData graph matches the code you see below. I want to filter Entities by the inherited UUID. I am creating a predicate and a fetch request using the following ...
Lee's user avatar
  • 1
0 votes
1 answer
196 views

Warning: format not a string literal and no format arguments. Any ideas?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSArray *listData =[self.tableContents objectForKey: [self.sortedKeys objectAtIndex:[...
AnthonyLombardi's user avatar
1 vote
2 answers
352 views

Getting the error "Format not a string literal and no format arguments"

I looked on here and didnt see my same situation. Anyone willing to help, thanks. I have a Grouped Table that displays my football teams games this upcoming season. Home Games and Away Games. ...
Anthony's user avatar
  • 11
1 vote
3 answers
2k views

Objective-C: Reading contents of a file into an NSString object doesn't convert unicode

I have a file, which I'm reading into an NSString object using stringWithContentsOfFile. It contains Unicode for Japanese characters such as: \u305b\u3044\u3075\u304f which I believe is せいふく I ...
rikunx's user avatar
  • 13
-1 votes
2 answers
802 views

EXC_BAD_ACCESS Error

When I run this code NSString *string = [NSString stringWithFormat:@"http://makrr.com/*****/****/*****/****/%@.mp3", [data objectForKey:@"location"]];` Im getting a EXC_BAD_ACCESS. [data ...
Sam Baumgarten's user avatar
2 votes
4 answers
638 views

First three items of of NSArray into an NSString?

What would be the most efficient way of turning the first three objects (or 1 or 2 if that's how big the array is) of an array, into a string, which is comma-separated. I've got a feeling there is a ...
cannyboy's user avatar
  • 24.3k
2 votes
1 answer
520 views

How To Save Data For Bookmarks?

I'm creating a very simple bookmarks menu for my app. I just need to save 3 strings for each object. I was thinking of using core data but I don't want this to be connected with my core database ...
user avatar
0 votes
2 answers
2k views

Invalid Selector sent to instance - objectForKey:

I get an error when running my code. The culprit is me accessing a string from a plist below: NSString *sImageFile = [dictionary objectForKey:@"answerCorrect"]; NSLog(@"%@",sImageFile); I ...
Nungster's user avatar
  • 726
2 votes
4 answers
86 views

Need help with a loop that gobbles up RAM

I'm trying to get this loop to free all of the memory it uses, but it still gobbles up RAM pretty quickly. Hopefully someone can tell me how I can get the strings deallocating as they should. ...
Randall's user avatar
  • 2,083
0 votes
2 answers
2k views

How to give line break to NSString iphone

I'm trying to post an itinerary to facebook as an attachment from my travel app, I'm using NSMutableString to append all the itinerary events and dates but I don't know how to give a line break after ...
Rafael Jimeno's user avatar
0 votes
3 answers
2k views

received memory warning. level 1

I am new to iPhone development. I am creating an application in which i need to create buttons and labels programmatically. So I am doing this in .h file @interface FirstQuizViewControlleriPad : ...
iUser's user avatar
  • 1,075
2 votes
2 answers
2k views

How to sort an array of NSStrings by the number contained within? (in ascending order)

I'm wondering if it is possible to sort an NSArray of NSStrings based on a number value contained within. Basically its a list of process ID's and process names, and I would like to sort the processes ...
Jared Aaron Loo's user avatar
1 vote
4 answers
4k views

Dynamically create variable name

In objective-c is there a way to dynamically create a variable name. Like I pass a string into a method and the method creates an NSString whos name is the string that was passed in. Something like -(...
Clinton Walsh's user avatar
12 votes
4 answers
49k views

Append string with variable

I'm a java guy coming over to Objective-C. In java, to add a variable to a string you'd have to do something along the lines of: someString = "This string is equal to " + someNumber + "."; I can't ...
Peter Kazazes's user avatar
5 votes
5 answers
21k views

disable button when textfields are empty

hi im a beginner to programming and have been stuck on this task for ages and seem to be getting nowhere. basically i have several textfields that generates the input information on a different page ...
Ayub's user avatar
  • 110
22 votes
3 answers
12k views

Padding a number in NSString

I have an int, for example say 45. I want to get NSString from this int padded with 4 zeroes. So the result would be : @"0045". Similar, if the int is 9, I want to get: @"0009". I know I can count ...
RungaDeMungoezz's user avatar
-4 votes
3 answers
234 views

NSArray With NSString Is This Even Possible?

I am trying to build a Grouped Sectioned View. I want to set an array as an object in the dictionary but I came across the empty array Issues. Is this Even possible????? Is There a trick ???? #import ...
ngeran's user avatar
  • 73
0 votes
1 answer
2k views

Displaying 'special' characters from other encodings in UILabel or similar

I'd like to be able to simulate a terminal on my iPhone to play games like Nethack using the primitive graphics I enjoyed on a real DEC terminal. Nethack allows selection of DECgraphics for vt-...
Adam Eberbach's user avatar
4 votes
1 answer
4k views

Matching NSPredicate With String

I have this predicate which works somewhat well. NSPredicate *filter = [NSPredicate predicateWithFormat:@"code contains[cd] %@", predicateFilter]; So if predicateFilter is 112, this finds all code ...
user avatar
0 votes
1 answer
470 views

NSPredicate and NSString Question

I have the following predicate that works fine with numbers such as 555 and 623 (3 digit numbers) The problem is, I have numbers such as 005 and 009 etc (1 digit with two 0 before). NSPredicate *...
user avatar
3 votes
1 answer
1k views

Getting constantValue: unrecognized selector sent to instance error

Getting this error with my fetch's predicate 2011-08-13 13:49:12.405 Codes[16957:10d03] NSlog Array: code BETWEEN {"06", "07"} 2011-08-13 13:49:12.407 Codes[16957:10d03] -[NSCFString constantValue]: ...
user avatar
0 votes
1 answer
799 views

Initializing NSStrings with Large, constant html strings

I have a large constant html string which I'd like to display on my UIWebView. For some reason, when I try to use the constant string ( with @"LARGE_STRING" ) I get some weird errors, saying I have an ...
Niv's user avatar
  • 2,302
1 vote
6 answers
4k views

How to convert a NSString to UTF in the quoted printable form using iOS SDK?

I need to convert a string (probably with non latin characters) to UTF-8, further encoded in a quoted-printable form. For example I have a string, e.g "привет" and I need to convert it to "=D0=BF=D1=...
Davey Jones's user avatar
0 votes
1 answer
523 views

iOS using nsstring from class in UIViewController

I've been bashing my head against this for a week solid, I'm sure its been answered before but in all my research i'm just confusing myself more and more. I'm just simply trying to use an NSString ...
BigB's user avatar
  • 121
0 votes
2 answers
688 views

Cut one string into two others in Objective-C

I have an NSURLRequest being made that to a server that returns a string. string = [[NSMutableString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding]; receivedData is the mutable ...
Peter Kazazes's user avatar
2 votes
1 answer
3k views

App crashing because of glGetString

I am running cocos2d-iphone 1.0.0 and following this tutorial to use cocos2d with ARC. Unfortunately, I am getting a 'SIGABRT' crash error whenever I try to add a TMX Tiled Map to a CCLayer. I have ...
Ethan Lee's user avatar
  • 178
0 votes
1 answer
330 views

NSPredicate not filtering correctly

I'm trying to setup a NSPredicate to filter data. I have a property of an entity called code that is in format like 55.534. I'm trying to fetch all data in a range, for example 50-60. I have this ...
user avatar
0 votes
1 answer
107 views

How to make objective C string manipulations generate the name of a particular constant?

I've created a Constants.h file with a list of: #define kw00 @"foo" #define kw01 @"bar" ... I also use #import Constants.h in the .h. Using newQuote method, I'm trying to randomly select one of the ...
Peter Brockmann's user avatar

1
109 110
111
112 113
143