How does one find a '.' in a string object in Object-C
Posted
by
NaZer
on Stack Overflow
See other posts from Stack Overflow
or by NaZer
Published on 2011-01-14T05:01:08Z
Indexed on
2011/01/15
4:53 UTC
Read the original article
Hit count: 133
I am working on getting a simple calculator working as part of my adventure to learning Object-C and iOS development.
In Object-C using NSString, how does one look for a period in a string?
Based on the comments this is what I got so far.
NSString * tmp = [display text];
NSLog(@"%@", tmp); // Shows the number on the display correctly
int x = [tmp rangeOfString:@"."].location;
NSLog(@"%i", x); // Shows some random signed number
if (x < 0) {
[display setText:[[display text] stringByAppendingFormat:@"."]];
}
It is still not working :(
© Stack Overflow or respective owner