Implicit Conversion from NSInteger to NSString not allowed in ARC.. what workaround should be used to deal with Integers

11,103

So if I've understood correctly, setText: takes an NSString and you have an NSInteger? If that's correct you can explicitly convert them as follows:

[self.abilitygeneration setText:[NSString stringWithFormat:@"%d",((TestAbility *)[self.testabilities objectAtIndex:0]).abilitygeneration]];
Share:
11,103

Related videos on Youtube

Pang Zi Yang
Author by

Pang Zi Yang

Updated on June 04, 2022

Comments

  • Pang Zi Yang
    Pang Zi Yang over 1 year

    This is my code in my viewcontroller.m file

    - (void)viewDidLoad{
    [super viewDidLoad];
    [self.abilitygeneration setText:((TestAbility *)[self.testabilities objectAtIndex:0]).abilitygeneration]; }
    

    It gives me an error implicit conversion of NSInteger aka int to NSString is disallowed with ARC. How do I enable ARC and have a workaround for this.Instead of setText what can I use?

    abilitygeneration is set as NSInteger in TestAbility.h file.. thanks

  • Pang Zi Yang
    Pang Zi Yang almost 12 years
    Thanks for the help.. Precise and accurate