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];
        if (trim ==[chtable substringWithRange: NSMakeRange (scan, 1) ]) {
    return scan;

Recommended Answers

All 4 Replies

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)]]) {

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] )

You work in classes, it's a method, not a function. Hehe

Also, that break might be screwing stuff up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.