UITableView Cases

Discussion in 'iOS Development' started by spoonforknife, Feb 20, 2009.

  1. spoonforknife

    spoonforknife Retired Moderator

    Joined:
    Nov 15, 2007
    Messages:
    6,896
    Likes Received:
    317
    Is there any way to make the case insensitive on the UITableView? I've looked through the documentation several times and found nothing on this. What I mean by this is that I want Dangerous and dangerous in the same section, regardless of capitalization.

    Is this possible?
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    look at NSString methods. you may want to just convert all your strings like that to one type.

    example:

    Code:
    [myString uppercaseString];
    i believe would return "Dangerous"

    but that may also be

    Code:
    [myString capitalizedString];
    play around with it =]
  3. spoonforknife

    spoonforknife Retired Moderator

    Joined:
    Nov 15, 2007
    Messages:
    6,896
    Likes Received:
    317
    This doesn't bode well with iSomething or gSomething.

    Please Register or Log in to view images


    Anybody have a solution?
  4. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    I don't understand the problem. Just add both of those to the same section.
  5. spoonforknife

    spoonforknife Retired Moderator

    Joined:
    Nov 15, 2007
    Messages:
    6,896
    Likes Received:
    317
    I have a UITable. It reads a plist and sticks the name into the table. This way, I can keep the plist online and auto-update the application something new comes around, verifding itself of bunches of unnecessary database updates. Then, name values are put into the table automatically. This poses a problem for lower case letters, as they don't happen to mix well with upper case letters, unless i'm missing something.
  6. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Although i'm defiantly not an expert, but i think you might be missing something. I can't see why this wouldn't work.
  7. spoonforknife

    spoonforknife Retired Moderator

    Joined:
    Nov 15, 2007
    Messages:
    6,896
    Likes Received:
    317
    I haven't been the clearest about this. Dangerous will pop up on the table. So will dangerous. They're just in different sections. Dangerous is in the D section and dangerous is in the d section. Is there a way around this?
  8. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Ohh i see what you mean now. That's weird, i think there should be a way around. Sorry i can't help though.
  9. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    I still don't see why this is a problem, just add them to the same section. End of story; unless you don't understand the way tables work.

    If you're doing something screwy and don't to use a simpler method you can use a crap ton of methods to compare the strings. This might be the easiest possible thing:

    Code:
    NSDictionary * yourDictionary = [blah, blah, blah... yourPlist];
    if(NSString *theFirstLetterInUppercase = [[[yourDictionary objectAtIndex:anIndex] substringToIndex:0] uppercaseString]) {
    [INDENT]//  DO SOMETHING WITH THE CAPITAL LETTER 
    //  LIKE PUT THE ITEM INTO THE CORRECT SECTION[/INDENT]
    } else {
    [INDENT]//  YOUR STRING DIDN'T BEGINE WITH A LETTER.  (I'm assuming, I never use this, preferring C to do string work)
    //DO SOMETHING ELSE WITH IT
    }[/INDENT]
    

    Ideally, simply look into sorting arrays, and all your problem will be nonexistent.

Share This Page