0

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?

Monolo
  • 18,205
  • 17
  • 69
  • 103
akshata
  • 41
  • 3
  • Do you have ARC turned on, in that case you don't need to release the object. – rckoenes Dec 27 '11 at 08:28
  • 1
    @rckoenes Looks like runtime exception not a compilation error. Whereas ARC is done at compile time. – 0x8badf00d Dec 27 '11 at 08:37
  • possible duplicate : [http://stackoverflow.com/q/1371346/971401](http://stackoverflow.com/q/1371346/971401). –  Dec 27 '11 at 11:54

2 Answers2

2

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.

danyowdee
  • 4,658
  • 2
  • 20
  • 35
0

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.

meronix
  • 6,175
  • 1
  • 23
  • 36