Not reading data from the array always displaying no preference

Hi all I am currently working on an iPhone application. The application is for a an estate agent, and the app reads information in from a feed. The client is able to have various options on the app which allows them to select a community then a sub community. Obviously I can't have all of the sub communities displayed in one go because they only exist in certain communities. So what i was trying to do was the following : Here is a snippet of my code from the URL Query generator: The following is for the community.

[urlString appendString:@"&Tier1_ID="];
            switch ([_appDelegate int_Tier1_ID]) {
                case 0: [urlString appendString:@"0"]; break;//No preference
                case 1: [urlString appendString:@"190"]; break;
                case 2: [urlString appendString:@"85"]; break;
                case 3: [urlString appendString:@"88"]; break;
                case 4: [urlString appendString:@"89"]; break;

And here is what i am trying to do in the URLQueryGenerator for the Sub community:

        [urlString appendString:@"&Tier2_ID="];
        switch ([_appDelegate int_Tier1_ID]) {

            case 0: [urlString appendString:@"0"]; break;

            case 1:switch (_appDelegate.int_Tier2_ID){
                case 0: [urlString appendString:@"0"];break;
            case 1: [urlString appendString:@"200"]; break;
            case 2: [urlString appendString:@"201"]; break;
            case 3: [urlString appendString:@"202"]; break;
            case 4: [urlString appendString:@"203"]; break;
            case 5: [urlString appendString:@"204"]; break;
            case 6: [urlString appendString:@"205"]; break;
            case 7: [urlString appendString:@"206"]; break;
            case 8: [urlString appendString:@"207"]; break;

            case 2:switch (_appDelegate.int_Tier2_ID){
                case 0: [urlString appendString:@"0"];break;
                case 1: [urlString appendString:@"285"]; break;
                case 2: [urlString appendString:@"286"]; break;
                case 3: [urlString appendString:@"287"]; break;
                case 4: [urlString appendString:@"288"]; break;
                case 5: [urlString appendString:@"289"]; break;
                case 6: [urlString appendString:@"290"]; break;
                case 7: [urlString appendString:@"408"]; break;
                case 8: [urlString appendString:@"291"]; break;
                case 9: [urlString appendString:@"292"]; break;
                case 10: [urlString appendString:@"293"]; break;
                case 11: [urlString appendString:@"403"]; break;
                case 12: [urlString appendString:@"294"]; break;
                case 13: [urlString appendString:@"295"]; break;
                case 14: [urlString appendString:@"296"]; break;
                case 15: [urlString appendString:@"297"]; break;
                case 16: [urlString appendString:@"298"]; break;
                case 17: [urlString appendString:@"309"]; break;
                case 18: [urlString appendString:@"299"]; break;
                case 19: [urlString appendString:@"402"]; break;
                case 20: [urlString appendString:@"300"]; break;
                case 21: [urlString appendString:@"301"]; break;
                case 22: [urlString appendString:@"406"]; break;
                case 23: [urlString appendString:@"302"]; break;
                case 24: [urlString appendString:@"308"]; break;
                default:[urlString appendString:@"0"]; break;
            default:[urlString appendString:@"0"]; break;

Here is a snippet of the subcommuinity delegate:

FindPropertyAppDelegate  * _appDelegate = [[UIApplication sharedApplication] delegate];
    NSArray* array;

    switch (_appDelegate.int_Tier1_ID) {
        case 0:
            array = [[NSArray alloc] initWithObjects:
                     NSLocalizedString(@"No Preference", nil),

        case 1://DIFC
            array = [[NSArray alloc] initWithObjects:
                     NSLocalizedString(@"No Preference", nil),
                     @"Central Park Tower",
                     @"Currency House",
                     @"DIFC Tower",
                     @"Emirates Financial Towers",
                     @"Gate Boulevard",
                     @"Park Towers",
                     @"The Gate Precint",
        case2://Dubai Marina
            array = [[NSArray alloc] initWithObjects:
                     NSLocalizedString(@"No Preference", nil),
                     @"Al Atina",
                     @"Al Fattan Marine",
                     @"Al Majara",
                     @"Al Marjan Villas",
                     @"Al Sahab",
                     @"Bay Central",

However when i click on the picker it always only displays "No Preference".

The user should get the relevant results when they choose a community.

Can any one help I'm so confused.

Thank you.


Whatever your base problem is, your going to spin yourself into more trouble then you deserve by writing code this way. It's probably an anti-pattern to use AppDelegate as a dumping ground for just any random thing. And based on what little I can glean from your example, you should probably be creating a new class

@interface FeedInfo

// set these
@property (nonatomic) NSUInteger tier1ID;    
@property (nonatomic) NSUInteger tier2ID;

// and then get these
@property (readonly) NSString *urlString;
@property (readonly) NSArray *subCommunities;


You could then break some of your multiple nested switch statements into single methods inside your implementation, which you can compose internally into your urlString.

If you learn the standards of how to program in Objective-C, you'll probably be saving yourself pain in the long run. I understand, that may not put the product in the hands of your client quickly (this time... possibly), but it will improve the quality of what they do get immensely.

Need Your Help

Update a datagridview trick for checkbox

c# winforms data-binding datagridview

I have a windows form which has a gridview. I want to update it by the trick.

Unable to identify Wbfgrid if it has large number of rows

qtp hp-uft

I have a weird situation where QTP will not identify a WBFgrid if it has a large(800+) rows of data. However it will identify if it has (5-100) rows of data.