Re: GC memory leak - what is it?

2010-01-04 Thread Rippit the Ogg Frog



jonat...@mugginsoft.com wrote:

A recent post mentioned the concept of GC memory leakage.

How is is this defined? Is it merely a failure to nil out a rooted reference?


Yes.  If you hold a reference to memory you don't need anymore, you have 
a leak.


I've gotten into huge flamewars over this, but I'm convinced of its truth.

Consider a Java Document Object Model tree.  Every node holds a 
reference to its parent and all of its children.  If you hold a 
reference to any node in the tree, you prevent the entire tree from 
being collected.


If you can't be sure that some other code will nil out your references, 
then nil them out yourself.


Rippit the Ogg Frog
rip...@oggfrog.com
http://www.oggfrog.com/
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Wierd Crash Report

2009-12-14 Thread Rippit the Ogg Frog

From your crash log:


Code Type:   PPC (Translated)


Translated - does that mean it's running under Rosetta on Intel?

It can happen that there are Rosetta bugs that don't occur on native 
PowerPC hardware.  While that shouldn't ever be the case, we all know 
that programmers are only human.


David Blanton wrote:



I ask this here as I have seen questions on Crash Reports.

This is is Universal Binary ... why is there any PPC involved as it is 
running on Intel




Process: Convert it [817]
Path:/Applications/Convert it.app/Contents/MacOS/Convert it
Identifier:  com.BriTonLeap.convertitmac
Version: 1.42b (7309)
Code Type:   PPC (Translated)
Parent Process:  launchd [74]


Mike Crawford
rip...@oggfrog.com
http://www.oggfrog.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Data-Driven Animation

2009-12-12 Thread Rippit the Ogg Frog
I'm working on what is now a Mac OS X prototype, that I'll be porting to 
the iPhone once I have a better architecture in place.


Please forgive me for being vague about the precise nature of my 
product. :-D


I need to better understand how to architect a 2-D animation in my app. 
 I'm happy to Read The Fine Manual if you can give me some pointers as 
to where to look.


I have a data model that is represented in graphical form on the screen. 
 The data model updates many times per second.  Each time the data 
model updates, I'd like to update the screen.


What I do now I'm certain isn't correct.  Whenever the data model has 
changed, the view object that holds the graphical representation calls:


[self setNeedsDisplay: YES];

In the drawRect method, I convert the data model into its graphical 
representation.


I'd like the data model to update as fast as it can; sometimes there 
will be several updates to the data model in between screen refreshes. 
That would actually be OK, if I don't see some of the steps in between 
refreshes; I just want whatever I do see to be completely consistent.


A problem I see is that when drawRect is called, the data model might be 
part-way through updating.  So the screen would have an inconsistent 
graphic drawn on it.


I think what might work better is to have two off-screen graphics 
buffers.  One of them will be updated according to the model, then only 
when that buffer is complete, a pointer will be switched that makes it 
the current graphics buffer, that is used by drawRect.


Having two graphics buffers would enable me to draw into one without 
fear of screwing up the on-screen image, while the other has a 
completely consistent image.


The current buffer would be copied to the screen by whatever Cocoa 
uses instead of the old Classic CopyBits.


I know that Quartz has built-in double buffering.  Could that help me 
somehow?


Thanks for any advice you can give me.

Mike Crawford
rip...@oggfrog.com
http://www.oggfrog.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: EXC_BAD_ACCESS in a Core Data application

2009-09-04 Thread Rippit the Ogg Frog



Eric Hermanson wrote:
3. Attempting to access or return a local variable that has not been 
initialized (although you may get a segmentation fault instead of a 
BAD_ACCESS, I can't remember).  For example,


- (BOOL)someMethod
{
BOOL returnValue;
// code in the method that never sets the returnValue to anything
return returnValue;  // this is bad.
}


That's not really the best example.  If someMethod returns a BOOL, than 
no matter what value happens to occupy the memory that returnValue is 
placed into, it will always be taken as true or false.  It might not do 
the right thing, but won't be likely to cause a crash.


A better example of code that would cause a crash is to return either an 
uninitialized pointer, or a pointer to a struct that is a local variable.


--
Rippit the Ogg Frog
rip...@oggfrog.com
http://www.oggfrog.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Listening to Eject command

2009-07-30 Thread Rippit the Ogg Frog



Ed Wynne wrote:

you want DA for DiskArbitration.


DiskArbitration is unfortunately rather poorly documented.  It will take 
some trial and error to figure out how to make it work for you.  But 
there are some developer blogs that yield some insight...


... unfortunately the bookmarks I had for them are on my other Mac, some 
sixty miles from where I am now...


... but Google could be your friend.

I'm afraid I can't just post my source.  But what I suggest you do is 
create a very simple application that has an NSTextView in it, and when 
you get any kind of notifications from DiskArbitration, append a message 
to the text view.


Then put some buttons in your window, such that pressing the buttons 
result in commands being sent to DiskArbitration to mount, dismount and 
eject a volume, whose BSD name you can either enter manually in an 
NSTextField, or you could capture the BSD names that DiskArbitration 
tells you about and populate a menu with them.


Note that you can dismount a volume without ejecting it.  If you do that 
then launch Disk Utility, you'll see the volume's BSD name in Disk 
Utility's list, but greyed out.  The volume is still known to the 
system, but just doesn't have a mounted filesystem.


If you make such a testbed application as I describe, eventually 
DiskArbitration's operation will become quite clear and even appear 
sensibly designed.  It's not that it's so difficult, it's that it's just 
undocumented.


Ever Faithful,

Rippit the Ogg Frog
rip...@oggfrog.com
http://www.oggfrog.com/


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa Document-Based App v. Windows MDI App

2009-07-28 Thread Rippit the Ogg Frog
The prevalence of MDI interfaces on Windows is one of the primary 
reasons I stick with the Mac, both as a user and as a developer.


That is, it's not just that I prefer to use the Mac-standard user 
interface myself, but I also don't want to have to subject my users to 
user interfaces that I wouldn't willingly use myself.


I've been a software engineer for twenty-one years, the majority of 
those spent coding for the Mac.  And I can tell you - and you can quote 
me - that just about the best way for a Mac product to achieve poor 
reviews in the trade press is to make it look and act just like a 
Windows program.


Look up the Macintosh User Interface guidelines at 
http://developer.apple.com/ and send the link to your coworkers. 
Emphasize the importance of a native look and feel.


--
Rippit the Ogg Frog
rip...@oggfrog.com
http://www.oggfrog.com/
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Identifying NSTextViews

2009-07-28 Thread Rippit the Ogg Frog
How can one identify which of several NSTextViews has a given piece of 
text in it?


I have a window with six NSTextViews.  I made the window's controller 
the delegate for each of them - or rather for their NSText base class. 
My delegate's -textDidChange method gets called whenever the user edits 
any of the views, and I can get the text like this:


- (void) textDidChange: (NSNotification*) notification
{
NSString *text = [[notification object] string];

// But which view was it?

return;
}

If my text items were NSTextFields rather than NSTextViews, I could set 
a tag for each of them and check the tag in -textDidChange.  But 
NSTextViews don't have tags.  NSTextFields have tags because they 
subclass NSControl, but NSTextView isn't a subclass of NSControl.


I need to use views and not fields so they can have scrollbars and allow 
multiple lines of text.


One way I could do it would be to subclass NSTextView and implement -tag 
and -setTag in my subclass.  But that seems like a lot of trouble to go 
to for what must be a very common problem.  Surely there is a better way.


In the list archives I saw a mention of creating a separate outlet in 
the controller for each NSTextView, with each view being connected to a 
separate outlet.  I think that would work fine for me but I don't quite 
understand how to go about it - I haven't done much Cocoa programming 
before.


My objective is just to capture the text from each view when the window 
is dismissed, so there could be another way to do what I want without 
using a delegate.  It's not necessary for me to get called for every 
character the user types.


Thanks!

--
Rippit the Ogg Frog
rip...@oggfrog.com
http://www.oggfrog.com/
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Identifying NSTextViews

2009-07-28 Thread Rippit the Ogg Frog

Graham Cox wrote:


On 29/07/2009, at 1:56 PM, Rippit the Ogg Frog wrote:


- (void) textDidChange: (NSNotification*) notification
{
NSString *text = [[notification object] string];

// But which view was it?


return;
}



[notification object] is it.


Thanks, but that doesn't solve my problem.  Maybe I should be more clear:

My problem isn't getting a pointer to one of the NSTextViews.  My 
problem is figuring out which of those NSTextViews a given pointer 
refers to.


I have the views arranged in three rows and two columns, for a total of six.

When my delegate's method gets called, what I need to know is which row 
and column the text view is located in, that called the delegate.


If I could use tags, as with NSTextField, then I would set the tags to 
be integers ranging from 1 to 6.  I could then check the tag and copy 
the text into the appropriate member variable in my window's controller.


But I can't use tags because they're views and not fields.

Just having the pointer doesn't help unless I can use that to find out 
which of the six views it points to.


Thanks!

--
Rippit the Ogg Frog
rip...@oggfrog.com
http://www.oggfrog.com/
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Identifying NSTextViews

2009-07-28 Thread Rippit the Ogg Frog
Sorry I hadn't seen Andy Lees response before I sent my immediately 
previous post.  I think his solution will do what I need.  I'll try it 
out and let you know.


--
Rippit the Ogg Frog
rip...@oggfrog.com
http://www.oggfrog.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Identifying NSTextViews

2009-07-28 Thread Rippit the Ogg Frog
This worked perfectly, however the window delegate method I needed in my 
particular case was windowDidResignKey, because I'm not actually closing 
the window when the user dismisses it, but calling orderOut:.


Also NSTextView's string method returns a pointer to its internal 
buffer, so one should copy it and use the copy.


Thanks for all your help everyone.

Andy Lee wrote:
In the list archives I saw a mention of creating a separate outlet in 
the controller for each NSTextView, with each view being connected to 
a separate outlet.  I think that would work fine for me but I don't 
quite understand how to go about it - I haven't done much Cocoa 
programming before.


In the header of your window controller class, declare instance 
variables like this:


IBOutlet NSTextView * textViewOne;
IBOutlet NSTextView * textViewTwo;
... etc. ...

Save the file and return to Interface Builder.  The new outlets will 
show up and you'll be able to make connections from your window 
controller to the various text views.


== NOTE: make sure to connect to the text views and not the scroll 
views that enclose them.


My objective is just to capture the text from each view when the 
window is dismissed, so there could be another way to do what I want 
without using a delegate.  It's not necessary for me to get called for 
every character the user types.


Implement the window delegate method windowWillClose:.  Your window 
controller is probably already the window's delegate, but if it isn't, 
make that connection in IB.  Then in windowWillClose:, collect the data 
from your six text views using [textViewOne string], [textViewTwo 
string], etc.


--Andy




--
Rippit the Ogg Frog
rip...@oggfrog.com
http://www.oggfrog.com/
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com