Reputation: 41
I started developing a project in ios-5, I have created database in my application.
Here I create bdgDBArr in appDelegate that contains values like 93,55,68,95,45...
I want to create string like badge_id= @"93,55,68,95,45"
here appDelegate.sb is NSString
type and sb1 is NSMutableString
type
This is my code
NSMutableString *sb1 = [[NSMutableString alloc] init];
if (![appDelegate.bdgDBArr count]==0) {
for (int i=0; i < [appDelegate.bdgDBArr count]; i++) {
if (!i==0) {
[sb1 appendString:@","];
}
[sb1 appendString:[[appDelegate.bdgDBArr objectAtIndex:i] valueForKey:@"key1"]];
}
}
else {
[sb1 appendString:@""];
}
appDelegate.sb = sb1;
NSLog(@"appDelegate.sb showSB===%@",appDelegate.sb);
[sb1 release]; //error wait_fences: failed to receive reply: 10004003
sb1 = nil;
This code is working perfectly and get the output 93,55,68,45 but at the same time I got this error in NSLog
wait_fences: failed to receive reply: 10004003
Any ideas?
Upvotes: 0
Views: 340
Reputation: 6176
just to try: use autorelease instead of release. does it change something?
is your property appDelegate.sb used in app delegate with a @syntetise setter/getter, or did you used your own code for the setter? in this case post your code, please.
Upvotes: 0
Reputation: 4698
I can't help with your problem but you can — and should — reduce your code down to a one-liner: appDelegate.sb = [appDelegate.bdgDBArr componentsJoinedByString:@","];
which is much more expressive and does the right thing.
And while we're there:
Objective-C makes it rather easy to write code that can be read like prose. Don't break that by using member/variable names like sb
or bdgDBArr
.
Oh and there is an operator to test for inequality: !=
use that instead of negating the result of an equality test. Your future self and every other person looking at your code will be thankful.
Upvotes: 2