 |
 |
Crashing when working with an array passed via NSNotification
|
 |
|
 |
|
Mac Enthusiast
Join Date: Apr 2001
Location: Newton, MA, USA
Status:
Offline
|
|
I've been banging my head against the wall for a while on this one, and was wondering if anyone might be able to suggest anything that i might've stupidly overlooked (i'm just a hobbyist, and have precious little training in programming).
Basically what's going on is that my document class stores information in two arrays, one being derived from a process upon the other. The idea is to use that information to draw a graph that appears in a second window. The custom view object doesn't exist until that second window is summoned, though, so the information makes kind of a roundabout trip to get there. I'm using Notifications to pass the object from the document to the application controller, which passes it to the graph window controller at the time the view is created. and this works great the first time around; the custom view receives the array and can work with the information therein. But if i close one document and open the other, the custom view code crashes the program as soon as i do something like foo=[incomingArray count] or something.
The behavior's consistent with a situation where i'm accessing something that's been thrown away or something, but i've gone over that a hundred times now, and haven't been able to find it.
Any suggestions on what i might be missing? Is this a completely brain-dead way to pass the information (i've tried an interlocking set of get/set functions that accomplish the same task, too)?
Thanks as always for any advice; should i ever become smart enough to lend a hand, rest assured i will try to return the favor.
(Last edited by calamar1; Apr 27, 2004 at 01:36 PM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status:
Offline
|
|
Yes, that object is definitely over-released. Without seeing the source, it's hard to find any cause, but I'd guess that you're releasing something on window close and aren't replacing it. Try setting everything to nil after release, that should help tracking it down (messages to nil are ignored).
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
You're probably passing something that's been autoreleased before you even got it? In which case you shouldn't be releasing it at all yourself.
In any case, why are you using a notification to communicate between your two objects? Can't you call one object's method directly from the other object? (May require making sure both objects are aware of each other when the controller initialises the other object).
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: May 2001
Location: Cupertino, CA
Status:
Offline
|
|
Without seeing some of your code, I'm guessing you used a convenience method to initialize the array, or you autoreleased it, but you did not retain it within the window controller. If that's not the case, we can probably help you better if you posted some of your code relevant to this issue.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Apr 2001
Location: Newton, MA, USA
Status:
Offline
|
|
thanks all.
i did find it eventually, and it was something that was being released prematurely (i wound up leaving myself a trail of NSLogs to highlight my problem, and that found it). a dumb mistake (i'm good at those).
as for why i'm using notifications, it's due to the fact that the array resides in a document class and is being passed through the application controller class to a window controller class to a custom view which may or may not exist yet. at any rate, none of them can call a method of the document class. i did try making interlocking methods to play 'telephone' with all of them, but i suspect the same mistake probably caused me to abandon that effort.
thank you again...
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|