Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
NSMutableArry and “EXC_BAD_ACCESS”
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="fontdesigner" data-source="post: 905697" data-attributes="member: 120549"><p>Could somebody help me?</p><p></p><p>I declared NSMutableArray in header file like this:</p><p>TPEditGlyphView.h:</p><p></p><p>@interface TPEditGlyphView : NSView</p><p>{</p><p> ... </p><p> NSMutableArray * observedKnots;</p><p> .... </p><p>}</p><p></p><p>Next I try to use one, but any access makes "EXC_BAD_ACCESS"..</p><p></p><p>TPEditGlyphView.m:</p><p>//only places where observedKnots appears</p><p>.....</p><p>-(void) awakeFromNib </p><p>{ </p><p> .....</p><p> observedKnots = [NSMutableArray arrayWithCapacity:0]; //CRASH, EXPLOSION...</p><p>}</p><p></p><p>-(void) observeValueForKeyPath: keyPath ofObject: object change: change context:context {</p><p> if (context == TPKnotsSelectionDidChangedContext) {</p><p> for (TPKnot *knot in observedKnots) { //CRASH, EXPLOSION...</p><p> ....</p><p> }</p><p> observedKnots = [NSMutableArray arrayWithCapacity:0];</p><p> for (TPKnot *knot in [knotsController selectedObjects]) {</p><p> ....</p><p> [observedKnots addObject: knot];</p><p> ....</p><p> }</p><p>}</p><p>....</p><p></p><p>Where could be bug?</p></blockquote><p></p>
[QUOTE="fontdesigner, post: 905697, member: 120549"] Could somebody help me? I declared NSMutableArray in header file like this: TPEditGlyphView.h: @interface TPEditGlyphView : NSView { ... NSMutableArray * observedKnots; .... } Next I try to use one, but any access makes "EXC_BAD_ACCESS".. TPEditGlyphView.m: //only places where observedKnots appears ..... -(void) awakeFromNib { ..... observedKnots = [NSMutableArray arrayWithCapacity:0]; //CRASH, EXPLOSION... } -(void) observeValueForKeyPath: keyPath ofObject: object change: change context:context { if (context == TPKnotsSelectionDidChangedContext) { for (TPKnot *knot in observedKnots) { //CRASH, EXPLOSION... .... } observedKnots = [NSMutableArray arrayWithCapacity:0]; for (TPKnot *knot in [knotsController selectedObjects]) { .... [observedKnots addObject: knot]; .... } } .... Where could be bug? [/QUOTE]
Verification
Name this item. 🍎
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
NSMutableArry and “EXC_BAD_ACCESS”
Top