iOS Variable is not a CFString at this time - Error

Young Developer

macrumors newbie
Original poster
Aug 26, 2012
4
0
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.
 
Last edited by a moderator:

Young Developer

macrumors newbie
Original poster
Aug 26, 2012
4
0
Code:
@interface SDKRegistry : NSObject
{
}
+ (NSString *)returnNSStringFromComponent: (NSString *)component;


@implementation SDKRegistry : NSObject

+ (NSString *)returnNSStringFromComponent: (NSString *)component
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];    
    return [defaults stringForKey:component];
}
 
Last edited by a moderator:

idelovski

macrumors regular
Sep 11, 2008
235
0
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:...];
 

dejo

Moderator
Staff member
Sep 2, 2004
15,981
447
The Centennial State
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?
 

Young Developer

macrumors newbie
Original poster
Aug 26, 2012
4
0
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"
 
Last edited: