Variable is not a CFString at this time - Error

Discussion in 'iPhone/iPad Programming' started by Young Developer, Aug 26, 2012.

  1. Young Developer, Aug 26, 2012
    Last edited by a moderator: Aug 26, 2012

    macrumors newbie

    Joined:
    Aug 26, 2012
    #1
    I have got this error during the debugging through device. In simulator it is working fine. How to solve that issue?
    Code:
    - (IBAction)buttonDigitPressed1: (UIButton *)button
    {
        NSString *integerPart = [SDKRegistry returnNSStringFromComponent:@"integerPart"];
    
        NSLog(@"class is %@",[integerPart class]);
        NSLog(@"pointer is %p", integerPart);
    
        if (!integerPart) integerPart = @"";
        NSString *one = @"1";
            integerPart = [SDKRegistry updateRegistryComponent:@"integerPart" withString:
                           [integerPart stringByAppendingString: one]];
        [self performConversion];
    }
    
    class is __NSCFConstantString pointer is 0x5922c

    When I am pressing number "1", appears that error - integerPart - "Variable is not a CFString at this time"

    I have tried to made the following in .m file:
    Code:
    NSString *integerPart; @property (nonatomic, retain) NSString *integerPart;
    
    then in .h file:
    Code:
    @synthesize integerPart;
    
    and change the code above:
    Code:
    integerPart = [[NSString alloc] initWithString:[SDKRegistry returnNSStringFromComponent:@"integerPart"]];
    ...
    [integerPart release];
    
    But nothing was changed. Please help me to find an answer to solve this.
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    What is SDKRegistry?
     
  3. Young Developer, Aug 27, 2012
    Last edited by a moderator: Aug 27, 2012

    thread starter macrumors newbie

    Joined:
    Aug 26, 2012
    #3
    Code:
    @interface SDKRegistry : NSObject
    {
    }
    + (NSString *)returnNSStringFromComponent: (NSString *)component;
    
    
    @implementation SDKRegistry : NSObject
    
    + (NSString *)returnNSStringFromComponent: (NSString *)component
    {
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];    
        return [defaults stringForKey:component];
    }
     
  4. macrumors regular

    Joined:
    Sep 11, 2008
    #4
    Looks like you over-released or failed to retain that variable and then something else pops in that block of memory. Simulator has much more free memory and that's why that block is not reused immediately.

    Other than that, the last line in the method - buttonDigitPressed1: makes no sense; you have formed this integerPart string and then what? Why do you need it in the first place? I think there is more than what we have here.

    ;)

    Could it be the last line [self performConversion] is actually [self performSelector... afterDelay:...];
     
  5. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    A few more concerns:

    - You haven't shown how updateRegistryComponent:withString: is defined.

    - As idelovski mentioned, why reassign integerPart and then do nothing with it?

    - You haven't shown what performConversion is.

    - Which line is giving you the "Variable is not a CFString at this time" error?
     
  6. Young Developer, Aug 27, 2012
    Last edited: Aug 27, 2012

    thread starter macrumors newbie

    Joined:
    Aug 26, 2012
    #6
    Code:
    + (NSString *)updateRegistryComponent: (NSString *)component withString: (NSString *)value
    {
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
            
        [defaults setValue:value forKey:component];
        [defaults synchronize];
        
        return value;
    }
    
    performConversion - only update the screen.

    But error appears before it on the line:
    Code:
    if (!integerPart) integerPart = @"";  // "Variable is not a CFString at this time"
     
  7. dejo, Aug 27, 2012
    Last edited: Aug 27, 2012

    Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
  8. thread starter macrumors newbie

    Joined:
    Aug 26, 2012
    #8
    class is __NSCFConstantString

    pointer is 0x5922c
     

Share This Page