I use NSString in a (typedef struct) data structure.
typedef struct {
...
NSTring *name;
...
} MyStruct;
I use calloc() to allocate the structure. When I set the value of the name just once then it shows correctly for the life of the app.
my_struct->name = @"Hello";
If I modify the string using the NSString function stringWithFormat, then the name is correct until the current function completes, then after that, the name contains garbage.
Here's and example of how I modify it.
my_struct->name = [NSString stringWithFormat"World"];
I can do the following in the beginning of my app, and the corrupted string shows up as soon as the app does any processing outside of the initialization function.
my_struct->name = @"Hello";
my_struct->name = [NSString stringWithFormat"World"];
but if I do the following, then the string never gets corrupted:
my_struct->name = @"Hello";
my_struct->name = @"World";
I need to use stringWithFormat to create name in different ways.
Any clues as to what the issue is?
Thank you,
Michael
typedef struct {
...
NSTring *name;
...
} MyStruct;
I use calloc() to allocate the structure. When I set the value of the name just once then it shows correctly for the life of the app.
my_struct->name = @"Hello";
If I modify the string using the NSString function stringWithFormat, then the name is correct until the current function completes, then after that, the name contains garbage.
Here's and example of how I modify it.
my_struct->name = [NSString stringWithFormat"World"];
I can do the following in the beginning of my app, and the corrupted string shows up as soon as the app does any processing outside of the initialization function.
my_struct->name = @"Hello";
my_struct->name = [NSString stringWithFormat"World"];
but if I do the following, then the string never gets corrupted:
my_struct->name = @"Hello";
my_struct->name = @"World";
I need to use stringWithFormat to create name in different ways.
Any clues as to what the issue is?
Thank you,
Michael