Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Integer Table View Cell issues #58

Closed
SolfaMode opened this issue Nov 20, 2014 · 2 comments
Closed

Integer Table View Cell issues #58

SolfaMode opened this issue Nov 20, 2014 · 2 comments

Comments

@SolfaMode
Copy link

In _FBTweakTableViewCell the mode is sometimes not set correctly, leading to wrong step values.

Problem:
[value objCType] is only checked for NSInteger and NSUInteger, but not for short, int, long (to name other popular types).

Fix:

  • (void)setTweak:(FBTweak *)tweak
    {
    if (_tweak != tweak) {
    _tweak = tweak;

    self.textLabel.text = tweak.name;

    FBTweakValue value = (_tweak.currentValue ?: _tweak.defaultValue);

    _FBTweakTableViewCellMode mode = _FBTweakTableViewCellModeNone;
    if ([value isKindOfClass:[NSString class]]) {
    mode = _FBTweakTableViewCellModeString;
    } else if ([value isKindOfClass:[NSNumber class]]) {
    // In the 64-bit runtime, BOOL is a real boolean.
    // NSNumber doesn't always agree; compare both.
    const char *objCType=[value objCType];
    if (strcmp(objCType, @encode(char)) == 0 ||
    strcmp(objCType, @encode(_Bool)) == 0) {
    mode = _FBTweakTableViewCellModeBoolean;
    } else if (strcmp(objCType, @encode(NSInteger)) == 0 ||
    strcmp(objCType, @encode(NSUInteger)) == 0 ||
    strcmp(objCType, @encode(short)) == 0 ||
    strcmp(objCType, @encode(unsigned short)) == 0 ||
    strcmp(objCType, @encode(int)) == 0 ||
    strcmp(objCType, @encode(unsigned int)) == 0 ||
    strcmp(objCType, @encode(long)) == 0 ||
    strcmp(objCType, @encode(unsigned long)) == 0
    ) { // jg added int, unsigned int
    mode = _FBTweakTableViewCellModeInteger;
    } else {
    mode = _FBTweakTableViewCellModeReal;
    }
    } else if ([_tweak isAction]) {
    mode = _FBTweakTableViewCellModeAction;
    }

    [self _updateMode:mode];
    [self _updateValue:value primary:YES write:NO];
    }
    }

@ghost
Copy link

ghost commented Aug 4, 2015

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

@grp
Copy link
Contributor

grp commented Aug 4, 2015

A few more types are checked now, which seems to cover the common cases.

@grp grp closed this as completed Aug 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants