Hey, Im a newbie in cocoa and I have a string and I am trying to count how long it is. I have been searching through Apples docs but I can't find anything.
NSString *word = @"word";
How would I figure out how many characters is in a string?
Thanks
...
Is it possible to order an NSMutableArray where it's values are NSStrings? I'm looking to order alphabetically. Thanks
...
I'm using stringWithFormat @"%ls" to do it and I only see the first character copied, which makes me think it's still assuming it's a single byte char.
Any ideas?
...
I know you can do it on Mac OS X with NSAttributedString but I haven't had much luck with that on the iPhone.
I'm trying to basically do a string like "$200" except the dollar sign is replaced by a custom symbol.
...
I got a string from parsing a XML file which looks like this: Fri, 09 Apr 2010 00:00:45 +0200
and the corresponding pattern should be this "EEE, dd MMM yyyy HH:mm:ss ZZ", but I get (null).
This is my code:
NSString *dateString = @"Fri, 09 Apr 2010 00:00:45 +0200";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateF...
I have a scenario where i show stuff like:
-----------------------------------
titleview (UITextView)
______________
tArea (UIScrollView)
ttextview (UITextView)
-----------------------------------
Now here is the condition:
Length of titleview's text is dynamic, varies based on ...
So I am seemingly encountering some strange behavior when using NSString's -sizeWithFont family of method calls depending on whether or not I'm invoking it on the iPhone Simulator or an actual device.
Simply enough, when the receiver of the -sizeWithFont:constrainedToSize:lineBreakMode: method call is nil, the resulting CGSize passed ba...
I can read the data in file.txt file located in local disk.
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"txt"];
NSString* Data = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&error ];
now, I upload the file.txt file into a website. how can i read the data from the txt ...
In a SOAP app, all communication with the server is as text, when the server needs an integer it is the text value that gets sent and returned integers are sent back as text.
To have the app working with integers one has to convert the returned strings into numbers e.g. NSInteger but then to, for example, save them to an array they must...
Hello all, this is my first post. I am building an iPhone app and stuck with the following:
unsigned char hashedChars[32];
CC_SHA256([inputString UTF8String], [inputString lengthOfBytesUsingEncoding:NSASCIIStringEncoding], hashedChars);
NSData *hashedData = [NSData dataWithBytes:hashedChars length:32];
NSLog(@"hashedData = %@", hashedDa...
Hey guys I need to send the content of an NSMutableArray through email. I have a mailing function but I'm not sure on how to place the content of the array into a NSString to be displayed on the email under each other. Is there a way to place all the content of the array into the string with maybe HTML nextline command between each array...
Hello !
This is a (very) simplified version of my iPhone code :
@interface x {
NSString * name1;
NSString * name2;
}
-init {
name1 = @"";
name2 = @"";
}
-(void) a {
Foo * foo = [Foo alloc];
name1 = @"uhuh";
name2 = [foo bar]; // return a (NSString *)
[foo release];
...
I am having an issue with NSDictionary returning null for an NSString even though the string is in the dictionary. Here is the code:
- (void)sourceDidChange:(NSNotification *)aNote {
NSDictionary *aDict = [aNote userInfo];
DLog(@"%@", aDict);
NSString *newSourceString = [aDict objectForKey:@"newSource"];
DLog(@"%@", newS...
I thought these two methods were (memory allocation-wise) equivalent, however, I was seeing "out of scope" and "NSCFString" in the debugger if I used what I thought was the convenient method (commented out below) and when I switched to the more explicit method my code stopped crashing! Notice that I am getting the string that is being s...
Hi.
A "quicky": how can I get the size (width) of a NSString?
I'm trying to see if the string width of a string to see if it is bigger than a given width of screen, case in which I have to "crop" it and append it with "...", getting the usual behavior of a UILabel. string.length won't do the trick since AAAAAAAA and iiiiii have the sam...
Hi, in my application, a RSS reader, I get memory leaks that I can't fix because I can't understand from where they come from. Here is the code pointed out by Instruments.
-(void) readArticlesFromDatabase {
[self setDatabaseInfo];
sqlite3 *database;
articles = [[NSMutableArray alloc] init];
if(sqlite3_open([databasePath UTF8String]...
I'm storing large unicode characters (0x10000+) as long types which eventually need to be converted to NSStrings. Smaller unicode characters can be created as a unichar, and an NSString can be created using
[NSString stringWithCharacters:(const unichar *)characters length:(NSUInteger)length]
So, I imagine the best way to get an NSStri...
Hi, I have leaks in the following code :
NSString * string;
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)str{
string = [NSString stringWithFormat:@"%@", str];
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
...
Lets assume I have the string:
"Hello I like your shoes #today...!"
I am tokenizing the string by spaces:
return [string componentsSeparatedByString:@" "];
So my array contains:
Hello
I
like
your
shoes
#today...!
I want to focus on "#today...!" any word that has a # in the prefix I am changing the font color.
How can I make sur...
I know there is this one:
sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode:
But since the CGSize always has the same height and doesn't adjust to any shrinked text or whatsoever, the CGSize is not telling how heigh the text is.
Example: Make a UILabel with 320 x 55 points and put a loooooooooooooong text in there. Let t...