2014年3月10日 星期一

在switch中要加上判斷的code,要用{ }大刮號

NSString *title, *subtitle;
        switch (indexPath.row) {
            case PROFILE_NAME:
                title = @"User name";
                subtitle = _userEntity.name;
                break;
            case PROFILE_BIRTHDAY:
                title = @"Birthday";
                subtitle = [_userEntity.birthday yyyy__MM__dd];
                break;
            case PROFILE_HEIGHT:
                title = @"Height";
                if (unitUSA) {
                    NSInteger feet, inch;
                    [UserEntity translateMeter:_userEntity.height.integerValue toFeet:&feet inch:&inch];
                    subtitle = [NSString stringWithFormat:@"%d'%d\"", feet, inch];
                } else
                    subtitle = [NSString stringWithFormat:@"%d cm", _userEntity.height.integerValue];
                break;
            case PROFILE_WEIGHT:
                title = @"Weight";
                subtitle =unitUSA ? [NSString stringWithFormat:@"%.1f lbs", [UserEntity translateLbFromKg:_userEntity.weight.integerValue]] : [NSString stringWithFormat:@"%d kg", _userEntity.weight.integerValue];
                break;
            case PROFILE_STRIDE:
                title = @"Stride";
                subtitle = unitUSA ? [NSString stringWithFormat:@"%d\"", (int)(_userEntity.stride.integerValue / 2.54)] : [NSString stringWithFormat:@"%d cm", _userEntity.stride.integerValue];
                break;
            case PROFILE_EMAIL:
                title = @"Email";
                subtitle = [apis getUserEmail];
            {
                UIView *_subview = [cell.contentView viewWithTag:978];
                if( _subview )
                {
                    [_subview removeFromSuperview];
                }
                
            }
                break;
            default:
                break;

        }

沒有留言:

張貼留言