Question

I'm trying to format the text inside a textview depending upon the device type, but it's not working. The 'else condition' always outputs in the simulator. Is this because of the viewDidLoad?

#import "Rules.h"

@implementation Rules

@synthesize rulesTextView;

- (void)viewDidLoad {
    [super viewDidLoad]       

    NSString *rulesText;
    NSString *deviceType = [UIDevice currentDevice].model;

    if([deviceType isEqualToString:@"iPhone"]){
        rulesText = @"2, 3, 4, 5, 6\t\t are counted as +1.\n7, 8, 9\t\t\t are counted as 0.\n10, J, Q, K, A\t are counted as -1.\n\nThe higher the plus count, the higher the percentage of ten-point cards and aces remaining to be dealt, meaning that the advantage is to player and they should increase their wager.\n\nIf the running count is around zero, the deck or shoe is neutral and neither the player nor the dealer has an advantage.\n\nThe higher the minus count, the greater the disadvantage is to the player, as a higher than normal percentage of low\ncards remain to be dealt. In this case a player should be making their minimum wager or leave the table.";
    }
    else{
        rulesText = @"2, 3, 4, 5, 6\t\t are counted as +1.\n7, 8, 9\t\t\t\t are counted as 0.\n10, J, Q, K, A\t are counted as -1.\n\nThe higher the plus count, the higher the percentage of ten-point cards and aces remaining to be dealt, meaning that the advantage is to player and they should increase their wager.\n\nIf the running count is around zero, the deck or shoe is neutral and neither the player nor the dealer has an advantage.\n\nThe higher the minus count, the greater the disadvantage is to the player, as a higher than normal percentage of low\ncards remain to be dealt. In this case a player should be making their minimum wager or leave the table.";
     }

    rulesTextView.text = rulesText;

}
Was it helpful?

Solution

It's because of the simulator. The model on the simulator is 'iPhone Simulator', not 'iPhone'. A better choice might be to base it off of [[UIDevice currentDevice] userInterfaceIdiom]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top