Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

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:
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:
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:...];
 
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?
 
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:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.