Question: I'm still new to blocks in objective-c and wondering if I have this psuedo code correct. I'm not sure if it's enough to just remove the observer or if i have to call removeObserver:name:object:

```
-(void) scan {
    Scanner *scanner = [[Scanner alloc] init];
    id scanComplete = [[NSNotificationCenter defaultCenter] addObserverForName:@"ScanComplete" 
                        object:scanner 
                        queue:nil 
                        usingBlock:^(NSNotification *notification){
                            /*
                             do something
                             */
                            [[NSNotificationCenter defaultCenter] removeObserver:scanComplete];
                            [scanner release];
                        }];
    [scanner startScan];
}

```

Update: I'm receiving intermittent `EXC_BAD_ACCESS` from this block, so this can't be right.

Answer: 
You should not unregister in the register block. Instead, store the token returned from `addObserverForName` (in this case, your `scanComplete`) as an instance variable or in a collection that is an instance variable, and unregister later when you're about to go out of existence (e.g. in `dealloc`). What I do is keep an NSMutableSet called `observers`. So:

```
id ob = [[NSNotificationCenter defaultCenter] 
     addObserverForName:@"whatever" object:nil queue:nil 
     usingBlock:^(NSNotification *note) {
        // ... whatever ...
}];
[self->observers addObject:ob];

```

And then later:

```
for (id ob in self->observers)
    [[NSNotificationCenter defaultCenter] removeObserver:ob];
self->observers = nil;

```
The scope of the block doesn't have permission to release the scanner object. If you're not using garbage collection, removing the `release` and making the scanner autorelease (`[[[Scanner alloc] init] autorelease]`) should do the trick.

You should also be able to safely move the call to `removeObserver` outside of the block.

For the case of `EXC_BAD_ACCESS`: Entering `bt` in the console window after the application crashes will give you a backtrace, and should inform you where the error occurred.