0

By the way I have this declared in my .h file.

Even if there is a string method for this I would like to know how I could do this.
Here is my code.

 -(NSInteger) RetrieveAscCode:(NSString*) inchr{
    NSString *chtable =@"0123456789.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    NSInteger scan;
    NSString *trim;
    trim = [inchr substringToIndex:1];
    for(scan=0;scan<255;scan++){
        if (trim ==[chtable substringWithRange: NSMakeRange (scan, 1) ]) {
            break;
        }
    }
    return scan;
}`
4
Contributors
4
Replies
21
Views
3 Years
Discussion Span
Last Post by matrixdevuk
0

What result are you getting from it as it is now?
I would use isEqualToString to compare two strings:

if( [trim isEqualtToString: [chtable subStringWithRange: NSMakeRange (scan, 1)]]) {
0

are you not getting any error ?
this code looks good. Anyway to perform character based operations, you can convert the NSString to char array by

char* chtable = [@"123456......." UTF8String];
char* inchar = [inchr UTF8String];
.
.
.
if(inchar[0] == chtable[i] )
.
.
.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.