RE: Adding text to NSImage using lockFocus/unlockFocus not working

2009-02-25 Thread Ashish Tiwari
I am sorry for typo, actually only images are shown *without titles. I want
to see image as well as their title.
Mean while I added your imageAttributes in IKBrowserItem.m with no luck.

I put various NSLog and looked in console to find out that
imageTitle, imageSubtitle, imageAttributes are not getting called. Just
imageUID, imageRepresentation and imageRepresentationType methods are being
called.
Is this correct behavior.

Ashish

-Original Message-
From: Graham Cox 


On 25/02/2009, at 4:04 PM, ashish_tiw...@persistent.co.in wrote:


 Hi Graham,

 I tried what you have suggested still only images are shown with  
 titles.


I'm not clear what the problem is - what did you expect to see?

 - (NSString*) imageSubtitle
 {
   NSDictionary* attribs = [image imageAttributes];

   int w, h;

   w = [[attribs objectForKey:@PixelWidth] intValue];
   h = [[attribs objectForKey:@PixelHeight] intValue];

 return [NSString stringWithFormat:@%d x %d, w, h];
 }


This won't work - NSImage doesn't have a method called - 
imageAttributes. In my code the attributes are retrieved using [self  
imageAttributes], and that method looks like this:

- (NSDictionary*)   imageAttributes
{
// returns the image's attributes dictionary using CGImageSource to

read the file's header. This is fast as the image
// itself isn't loaded.

NSURL*url = [NSURL fileURLWithPath:mPath];
CGImageSourceRef  srcRef = CGImageSourceCreateWithURL((CFURLRef)
url,  
NULL );
NSDictionary* imgProps = (NSDictionary*)  
CGImageSourceCopyPropertiesAtIndex( srcRef, 0, NULL);

CFRelease(srcRef);

//NSLog(@attributes for '%@': %@, mPath, imgProps );

return [imgProps autorelease];
}


I suspect your method is asserting when it's called due to the  
unimplemented method and that is stopping the browser view working  
properly. Check your console output.



--Graham



___

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: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-25 Thread Jerry Krinock


On 2009 Feb 24, at 21:17, Karolis Ramanauskas wrote:


Any thoughts?


I downloaded your project and inserted the code that I gave you  
yesterday into your -[MyView doSomething] method.  From the log, I  
then learned that the Fruit I inserted was being updated.  Here's what  
happens:


1.  You move the mouse over your view.
2.  As you move the mouse, Cocoa needs to redraw the area of your  
view which

  ^was^ covered by the mouse cursor/arrow.
3.  So, Cocoa invokes -[MyView drawRect:]
4.  -[MyView drawRect:] invokes -[Fruit draw]
5.  -[Fruit draw] invokes setName: on itself
6.  which causes an  
NSManagedObjectContextObjectsDidChangeNotification

7.  which is observed and runs -[MyView doSomething:]


Go to fruit class, comment out: [self setName:@Banana];
... problem is gone.



Yes, you've eliminated reaction 5 from the above.

Everything is behaving as expected.  You fixed it.  You're done.

Lesson: Don't change model data in a -draw method.  I really can't  
think of any reason why you'd want to do this.   -draw is for drawing.


___

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


Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Jerry Krinock


On 2009 Feb 24, at 20:02, Dave Fernandes wrote:

I can't say I have the ideal solution, and I am also using KVO, but  
one might want to heed Ben Trumbull's warning before going down this  
path...




Complex KVO observer actions need to be carefully constrained. If  
they simply grow organically, then it's pretty easy to fall into  
the trap of observers creating side effects that trigger other  
observers that cascade to yet more observers.  [1]



Thanks, Dave.  I was worried about that, but didn't see any  
performance hit after implementing it.  Certainly you want to keep  
observations to a canonical minimum, but if indeed A could cause B to  
change which could cause C to change, if you ^really^ want to view C,  
you've got to observe A and B.


I'm only just getting familiar with the idiosyncrasies of Leopard,  
however, in Tiger didTurnIntoFault might be called many times, but  
awakeFromInsert or awakeFromFetch was only called once for the  
lifetime of the MOC (not the lifetime of the object). Thus, if you  
delete the object, and then undo that action, your observers will be  
removed by didTurnIntoFault and not added back since awakeFromFetch  
is not called again.


Well, that was easy to test and indeed I found that you found a bug in  
my idea.  The only way to fix it would be if we Apple had given us a - 
didUnturnIntoFault method, but they did not.


So, it looks like, for observing changes to the properties of managed  
objects ---


*  Using NSManagedObjectContextObjectsDidChangeNotification is no good
 since it doesn't give you specific information on the current  
change

 which actually caused the notification.

*  Using KVO is no good because observers must be removed before an
 object becomes a fault, and there is no mechanism to find out
 when the object un-becomes a fault, which you need to restore
 your observers.

So, my conclusion is that writing Custom Setters for any properties  
that need to be observed and posting a  notification (coalesced, for  
efficiency) within the custom setter is the only viable technique.


Does anyone have any better ideas?

Jerry



[1]  http://www.cocoabuilder.com/archive/message/cocoa/2008/3/28/202594
___

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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-25 Thread Jon C. Munson II
After a clearer head/mind (yeah, verily, I was crapheaded yesterday), much Crow 
 Humble Pie for breakfast, much thinking, and much observation (especially 
after Jerry Krinock's post on thread re: Strange 
NSManagedObjectContextObjectsDidChangeNotification behavior), and in my case, I 
decided the best route for me was to use the -objectEnumerator found in the 
NSSet documentation coupled with the -isKindOfClass method to check for my 
class.  While it would be nice to actually see if a certain attribute got 
updated (inserted/deleted is something that needs handling regardless), I can 
live with not knowing that piece of information.

Based on what I saw, read, and thought, this approach seems best to me.  If 
there is a better idea, I'd love to read about it.

Thanks for dealing with me, sorry about the narrow-minded, fogged, clouded, 
idiocy of yesterday.  I'll endeavor to do better.

Peace, Love, and Light,

/s/ Jon C. Munson II


 -Original Message-
 From: cocoa-dev-bounces+jmunson=his@lists.apple.com [mailto:cocoa-dev-
 bounces+jmunson=his@lists.apple.com] On Behalf Of Michael Ash
 Sent: Tuesday, February 24, 2009 9:12 PM
 To: cocoa-dev
 Subject: Re: [Q] What causes an NSArrayController to know that an entity
 was inserted via a different window?
 
 On Tue, Feb 24, 2009 at 3:37 PM, Jon C. Munson II jmun...@his.com wrote:
  In the method,
  -(void)managedObjectContextUpdatedNotification:(NSNotification *)notif,
 the
  notif contains userInfo.  [userInfo valueForKey:] returns an NSSet.
  This
  set has a -description, which returns a string formatted as a property
 list.
  And there's where the documentation ends.  In the debugger console,
 printing
  out that description gives an array dump, so I can see what is in the
  description.
 
  My current solution is to call -rangeOfString on that description to
 look
  for the data specific to the entity in which I'm interested (the name of
 the
  entity in my case).  That works pretty well.  As the userInfo
 description
  isn't too big (small entities), this works fine.  However, I'm not
 convinced
  this is the best way to get at that data.
 
 It's good that you're not convinced, because it's not the best way. In
 fact, I believe it could very well be the absolute worst way possible.
 
 What happens if the description of one of the other objects just
 happens to look like the description for yours? Disaster.
 
 You know that you have an NSSet. The documentation for NSSet will tell
 you how to inspect it to discover the presence or absence of an object
 within it, without going through such a crazy roundabout process.
 
 Mike
 ___
 
 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/jmunson%40his.com
 
 This email sent to jmun...@his.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: Stop edit session with a NSTextField

2009-02-25 Thread Eric Gorr

Hello Patrick,

On Feb 25, 2009, at 12:38 AM, Patrick Mau wrote:

I was going through your last messages on this list, because I'm  
working on a similar problem.
Reading through the code snippets you showed here, it isn't clear to  
me how your controls are being created.


I have a XIB with a NSTextField...here is an over all picture of what  
that XIB contains:


http://ericgorr.net/cocoadev/outlinetable/namedparts.png

This is simple one item among many (perhaps a few thousand) as  
pictured here:


http://ericgorr.net/cocoadev/outlinetable/outlineview.png

If you need more details, let me know.

This table I am using is of my own creation as none of Apple's table  
views or the image browser worked the way I needed them to...so, I  
have to write my own custom solution mostly from scratch.


Are you creating a subclass of NSControl and afterwards add your GUI  
elements as sub-views programatically?
I could not figure out if you use one NSControl with NSCell's, sorry  
if I missed it.


No, I am just using NSControl's. I am not using any NSCell's explicitly.


Unfortunately, it does not work either.

If anyone has any further ideas on how to correctly end an editing  
session of a NSTextField, I am interested.


To summarize the proposed and failed solutions:

*** [[[self view] window] endEditingFor:nil];

Pressing return or pressing the tab key will not end the editing  
session


As far as I understand, TAB will focus the next control using the  
responder chain.
It is not really remove the editor, because you could TAB back to  
your control/cell

and still have the same state for editing.


I am more concerned that I don't have a way to guarantee the edit  
session will stop. This seems very odd and very broken to me.


However, in my case, I believe it is appropriate for the edit session  
to stop when the tab key is pressed. I have attempted to setup my  
custom table view as a responder and this is what I switch to when the  
user presses the return key. hummm...perhaps what is happening is that  
I switch to my custom table view, but the processing of the tab key  
hasn't completed yet so it moves onto to the next responder which is  
still that very annoying NSTextView that just won't go away.



*** [[[self view] window] makeFirstResponder:[self view]];

Pressing return will allow the editing session to end, but pressing  
the tab key will not.


I would suggest you write a small debug function to output the  
responder chain.
Call it after all your elements are setup and again after you  
started editing.


Good idea.

*** NSTextView *fieldEditor = [[aNotification userInfo]  
objectForKey:@NSFieldEditor];

  NSView *v = fieldEditor;
  while ( v  ( [v superview] != [aNotification object] ) )
  v = [v superview];
  [v removeFromSuperview];

Pressing return or pressing the tab key will not end the editing  
session


It works for me using one NSView only drawing NSCell objects.
But it was only a hack I tried to remove the field editor.

What happens when you NSLog all views you traverse on your way up?
Could you send the output?


NSTextView	*fieldEditor	= [[aNotification userInfo]  
objectForKey:@NSFieldEditor];

NSView  *v  = fieldEditor;
while ( v  ( [v superview] != [aNotification object] ) ) {
NSLog( @ResourceItemController: v: %@,  v );
v = [v superview];
}   
NSLog( @ResourceItemController: v: %@,  v );
[v removeFromSuperview];


outputs:


2009-02-25 09:36:12.860 OutlineCollection-VB[56709:813]  
ResourceItemController: v: NSTextView: 0x3afd20
Frame = {{0.00, 0.00}, {76.00, 13.00}}, Bounds = {{0.00, 0.00},  
{76.00, 13.00}}

Horizontally resizable: NO, Vertically resizable: YES
MinSize = {76.00, 12.00}, MaxSize = {4.00, 4.00}

2009-02-25 09:36:34.532 OutlineCollection-VB[56709:813]  
ResourceItemController: v: _NSKeyboardFocusClipView: 0x3f3040




What I am just about ready to do is stop using the NSTextField control  
and do the drawing myself using drawWithRect:options:attributes:. I  
believe I can get the metric I want, which doesn't seem possible with  
a NSTextField, with boundingRectWithSize:options:attributes: ... of  
course, this may not work as I believe I would loose the ability to  
accurately determine on which character the user clicked so I could  
begin an edit session with the cursor positioned correctly. However,  
since I would be explicitly brining the NSTextView into existence for  
editing, I should be able to get rid of it completely.


sigh.

___

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: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-25 Thread Karolis Ramanauskas
Lesson: Don't change model data in a -draw method.  I really can't think of 
any reason why you'd want to do this.   -draw is for drawing.

Yes, perhaps, but I have to change it, perhaps not in a draw method
itself, but in another method that get's called before it. In my real
program I have one, let's call it, MAIN object that has a draw method
and within it, it calls to draw methods of all its input objects:

NSSet * myInputs = [self inputs];

int inputCount = [myInputs count];

if (inputCount != 0) {

int n = 0;

for (KRSimInput * input in myInputs) {

[input setLocationX: ([self locationX] + ([self width] /
inputCount) * n++ + ([self width] / 2) / inputCount) - ([input width]
/ 2)];
[input setLocationY: ([self locationY] - [input height] -
[input strokeWidth])];

[input draw];

}
}

As you can see, before I can -draw an input I have to position it
right above the MAIN object. This position, as you can see from the
code, depends on inputCount and n, the current index. So I can't avoid
setters in -draw. Any suggestions?
___

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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-25 Thread I. Savant
On Wed, Feb 25, 2009 at 9:43 AM, Jon C. Munson II jmun...@his.com wrote:

 While it would be nice to actually see if a certain attribute got updated

  This is where a thorough understanding of KVC/KVO (with emphasis on
the KVO part) comes in. I'll point you to mmalc's examples:

http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

  Check out the Graphics Bindings example. There may be other examples
that highlight what I'm about to mention, but I'm not really familiar
- the Graphics Bindings example was what really helped to seal my
understanding (after many, many hours of studying / experimenting with
ALL the relevant documentation).

  The thing to pay attention to is that, in this example, you have a
custom array controller subclass which does special things on certain
events (a key to your understanding), as well as a couple of custom
views.

  The real meat is in the view classes. Specifically to your case, the
GraphicsView class. Note how -bind:... is overridden and calls
-startObservingGraphics: (and -unbind:... calls
-stopObservingGraphics:). This is crucial because it shows how a view
that's interested in the *properties* of the objects fed to it via
bindings manages to observe specific *properties* of each bound
object.

  That is, it specifically registers interest in the properties of
each of the objects in its purview, and unregisters interest when the
object is no longer in its purview.

  The -bind: method is called from the MyDocument class, so you can
see that the @shadowAngle and @shadowOffset key paths are observed
for each graphic object.

--
I.S.
___

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


Running Cocoa applications from file servers

2009-02-25 Thread Erik Buck
There is a interesting but long rant about software installers at 
http://www.bynkii.com/archives/2009/02/on_installers.html.  Most of the rant is 
about problems with pushing applications to remote client computers.
 
I'll try to keep this Cocoa related:  All of the applications I develop are 
Cocoa applications, so for me at least, the answers will only be relevant to 
Cocoa.
 
We have had the discussion about drag and drop vs. installers before, so let's 
avoid that.  My question is about why we install anything locally at all?  For 
years, I used a lab full of NeXTstep and Openstep machines that all NFS mounted 
a Sun file server.  The applications were placed (I don't want to say 
installed) on the Sun server.  
 
From any particular computer in the lab, I would just double click on 
someapplication.app in the /LabApps folder, and the application would start up 
an run.  It didn't matter if I sat at an Intel, 68K, or SPARC system due to 
the magic of fat binaries.  The application was never on the local hard disk 
at all.
 
If we wanted to deploy a new application, we just copied it to the Sun server 
and anyone who wanted it could double click.  When we upgraded an application, 
we just copied the new version to the Sun server.  There was no pushing of 
applications.
 
Where did the fetish for installing every single application on the local hard 
disk come from ?  Isn't it insane to have 35 installed copies of OmniGraffle 
using up disk space just because you have 35 licenses ?  Why is MS Word on 
every disk instead of just the server?
 
So, to keep this Cocoa specific, have there been any framework changes that 
impede running Cocoa applications from a read-only server mount ?  Are 
preferences a problem?  Are fonts an issue ?  Is access to 
~/Library/Application Support an issue ?  I can't think of any reason running 
from a remote read only mount would be a problem, but I'm not in a position to 
try right now.
 
 
 
 
___

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: [Q] What causes an NSArrayController to know that an entity was inserted via a different window?

2009-02-25 Thread Jon C. Munson II
Thanks for that, I will take a look at it, and study it, and study it some
more...

Peace, Love, and Light,

/s/ Jon C. Munson II

 -Original Message-
 From: I. Savant [mailto:idiotsavant2...@gmail.com]
 Sent: Wednesday, February 25, 2009 10:36 AM
 To: jmun...@his.com
 Cc: cocoa-dev
 Subject: Re: [Q] What causes an NSArrayController to know that an entity
 was inserted via a different window?
 
 On Wed, Feb 25, 2009 at 9:43 AM, Jon C. Munson II jmun...@his.com wrote:
 
  While it would be nice to actually see if a certain attribute got
 updated
 
   This is where a thorough understanding of KVC/KVO (with emphasis on
 the KVO part) comes in. I'll point you to mmalc's examples:
 
 http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
 
   Check out the Graphics Bindings example. There may be other examples
 that highlight what I'm about to mention, but I'm not really familiar
 - the Graphics Bindings example was what really helped to seal my
 understanding (after many, many hours of studying / experimenting with
 ALL the relevant documentation).
 
   The thing to pay attention to is that, in this example, you have a
 custom array controller subclass which does special things on certain
 events (a key to your understanding), as well as a couple of custom
 views.
 
   The real meat is in the view classes. Specifically to your case, the
 GraphicsView class. Note how -bind:... is overridden and calls
 -startObservingGraphics: (and -unbind:... calls
 -stopObservingGraphics:). This is crucial because it shows how a view
 that's interested in the *properties* of the objects fed to it via
 bindings manages to observe specific *properties* of each bound
 object.
 
   That is, it specifically registers interest in the properties of
 each of the objects in its purview, and unregisters interest when the
 object is no longer in its purview.
 
   The -bind: method is called from the MyDocument class, so you can
 see that the @shadowAngle and @shadowOffset key paths are observed
 for each graphic object.
 
 --
 I.S.

___

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: Stop edit session with a NSTextField

2009-02-25 Thread Andy Lee

On Feb 24, 2009, at 6:08 PM, Eric Gorr wrote:

*** [[[self view] window] makeFirstResponder:[self view]];

Pressing return will allow the editing session to end, but pressing  
the tab key will not


Looks like controlTextDidEndEditing: is too deep within the text  
field's event handling to muck with the first responder.  Delaying the  
call to makeFirstResponder: seems to work:


[[[self view] window]  
performSelector:@selector(makeFirstResponder:) withObject:nil  
afterDelay:0.0];


(Note this passes nil to makeFirstResponder: rather than the view.)  I  
don't know if this is foolproof -- for example, I haven't tried it  
with different accessibility settings.  And note that if you normally  
have a tab loop this will defeat the tab loop.


--Andy


aglee

___

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


willAnimateFirstHalfOfRotationToInterfaceOrientation not called...

2009-02-25 Thread Oscar Alejandro Alvarado Prieto
Hi, I need swap views when changing from landsacpe to portrait and
viceversa. The problem is that
willAnimateFirstHalfOfRotationToInterfaceOrientation
is not called. Of course I return YES from
shouldAutorotateToInterfaceOrientation.

I guess the problem should be at nib file but i can't find it. The most
external interface element is a tabbar that doesn't rotates.


Any hint will be apreciated.


Thanks in advance.
-- 
Oscar A. Alvarado
___

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: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-25 Thread Jerry Krinock


On 2009 Feb 25, at 06:55, Karolis Ramanauskas wrote:

Lesson: Don't change model data in a -draw method.  I really can't  
think of any reason why you'd want to do this.   -draw is for  
drawing.


Yes, perhaps, but I have to change it, perhaps not in a draw method
itself, but in another method that get's called before it.



...  [input setLocationX: ([self locationX] + ...



Any suggestions?


Is locationY the model attribute which you have to change?  If so, I  
suggest that this is not rightfully a model or managed object  
attribute.  Obviously, it's more of a 'view' thing than a 'model'  
thing.  Remove it from your data model.  Make it a regular instance  
variable instead or, better yet, remove it entirely from your model  
class and calculate it in your view class when you need to draw.   
Thousands of apps do it that way -- it will work for your app too!


___

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


Subclassing with more restrictive initializers

2009-02-25 Thread Andy Klepack
I've run up against this situation more than once and I'd be interested in any 
opinions and best-practices out there.

I have a class that has one or more initializers that accept parameters. The 
class also has behavior.

I want to implement a second class that has the behavior of the first in 
addition to its own behavior. This class should also have more restrictive 
initializers. That is, the second class should not allow the kind of 
parameterization that the first class does.

On the one hand this feel a like inheritance: the second class really is-a kind 
of the first class. But those pesky initializers (from the first class) don't 
make sense for the subclass.

On the other hand, this looks kinda like trying to create an instance through 
sub-classing (and that would be wrong) except that behavior is being added as 
well.

On the other-other hand this feel like it could be composition (instances of 
the second class have-a member of the first class), but the behavior of the 
first class would have to be accessed through a wrapper provided by the second 
class.

To make things more concrete (this isn't the actual case I've run into, but 
it's a similar, simpler illustration) consider a class File that has an 
initializer 'initWithPath:' and behavior 'delete', 'rename', etc. Then consider 
wanting to implement a class like 'PreferenceFile' that should only refer to 
files in the Preferences directory and thus has an 'initWithName: initializer. 
initWithPath provides too much parameterization since it could refer to any 
file outside of the Preferences directory. Finally, the PreferenceFile class 
should have the same behavior as File and add some of its own (e.g. 
setPrefValue:ForKey:).

Should PreferenceFile inherit from File despite the initialize behavior being 
undesirable? Is composition somehow more appropriate? Is this confusion the 
result of thinking about the problem from the wrong direction?

Any advice about how to think about and approach this sort of design problem 
would be great.

-Andy
___

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: Adding text to NSImage using lockFocus/unlockFocus not working

2009-02-25 Thread Michael Ash
On Tue, Feb 24, 2009 at 5:50 AM, Ashish Tiwari
ashish_tiw...@persistent.co.in wrote:
 //NSImage *img = [[NSImage
 alloc]initWithContentsOfFile:@/Users/ashisht/Desktop/downloads.png];
...
  [img lockFocus];

Don't try to create an image and then draw into it in this way. You're
likely to end up with multiple NSImageReps only one of which contains
your drawing, and then it'll be a crapshoot as to whether the one with
your drawing is the one that's used to display later on.

Instead, create a second NSImage. Lock focus on that one, draw both
the original image and your other stuff into it. Then use the second
image.

Mike
___

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: do i need to create autorelease pool?

2009-02-25 Thread Michael Ash
On Wed, Feb 25, 2009 at 12:00 AM, Peter N Lewis pe...@stairways.com.au wrote:
 The Application Kit creates an autorelease pool on the main thread at the
 beginning of every cycle of the event loop, and drains it at the end,
 thereby releasing any autoreleased objects generated while processing an
 event.

 This is assuming iPhone or Leopard, I believe the NSAutoreleasePool creation
 was required for older versions of Mac OS X.

The semantics haven't changed on Leopard as far as I know. The above
has been the case forever: pools are created and destroyed on
*events*, but not timers. If you simply run a timer forever and never
process events, your memory usage will grow without limit. A pool
exists, so you don't explicitly leak, but the pool is only drained
when an event arrives. If you're going to be running something in
timers or other non-event sources, you'll want to post a fake event to
the main event loop from time to time (or just after every action you
take) to force the pool to drain.

I have *no* idea how much of that, if any, applies to the iPhone. In
any case if you're processing events on a regular basis as well then
you don't have to worry about anything.

Mike
___

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


Gamma problem (?) with CIFilter output

2009-02-25 Thread Shamyl Zakariya

Hi,

If this should be posted to another list let me know, but I didn't see  
a Core Image list, so I figured Cocoa might be a good catch-all.


Anyway, I'm writing my first Core Image filter, a simple bump-map to  
tangent-space-normalmap filter. I've done this in GLSL before, and  
I've even done it in straight C. I figured it would make a good hello- 
world for Core Image. The kernel just computes changes in luminance  
along x  y and converts that to a normal.


Here's an example source ( bumpmap ) image:
http://shamyl.zakariya.net/etc/Bump.png

And here's what my vanilla C implementation outputs:
http://shamyl.zakariya.net/etc/Bump_NM.png

And here's what my CI Filter outputs:
http://shamyl.zakariya.net/etc/Bump_Ugly.png

The good news is that I'm outputting what superficially appears to be  
correct output. The colors are tinting in the right direction.


The bad news is that some sort of color-space conversion seems to be  
happening -- I figure it's a gamma correction for my LCD. But I don't  
want any correction: I want the output to be the numbers I compute.


To make certain I wasn't crazy, I did some simple tests, where I  
output a solid color, and then used photoshop to sample screenshots  
( crude, I know ).


- return vec4( 0,0,0,1 ) resulted in pure black: GOOD
- return vec4( 1,1,1,1 ) results in pure white: GOOD
	- vec4( 1,0.5,0.5,1 ) gives me something like ( 1,0.66,0.66,1.0) -  
BAD!



Also, I googled, and found the following thread:
http://lists.apple.com/archives/quartz-dev/2008/Jan/threads.html#00061

It seems like the issue is one of color profiles, but what I don't  
know is how to get CI to use a linear or generic profile.


Of course, I might also be barking up the wrong tree.

Thanks,

shamyl zakariya
- pillow-shaped and vaguely striated
   to echo piratical treasure chests

___

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: Running Cocoa applications from file servers

2009-02-25 Thread I. Savant
On Wed, Feb 25, 2009 at 10:43 AM, Erik Buck erik.b...@sbcglobal.net wrote:

 Where did the fetish for installing every single application on the local 
 hard disk come from ?  Isn't it insane to have 35 installed copies of 
 OmniGraffle using up disk space just because you have 35 licenses ?  Why is 
 MS Word on every disk instead of just the server?

  ... because network interruptions (especially intermittent ones) can
wreak havoc on your running apps. :-) That's my main reason.

--
I.S.
___

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: Subclassing with more restrictive initializers

2009-02-25 Thread Michael Ash
On Wed, Feb 25, 2009 at 11:39 AM, Andy Klepack
andy.klep...@microsoft.com wrote:
 To make things more concrete (this isn't the actual case I've run into, but 
 it's a similar, simpler illustration) consider a class File that has an 
 initializer 'initWithPath:' and behavior 'delete', 'rename', etc. Then 
 consider wanting to implement a class like 'PreferenceFile' that should only 
 refer to files in the Preferences directory and thus has an 'initWithName: 
 initializer. initWithPath provides too much parameterization since it could 
 refer to any file outside of the Preferences directory. Finally, the 
 PreferenceFile class should have the same behavior as File and add some of 
 its own (e.g. setPrefValue:ForKey:).

 Should PreferenceFile inherit from File despite the initialize behavior being 
 undesirable? Is composition somehow more appropriate? Is this confusion the 
 result of thinking about the problem from the wrong direction?

I'd say that there are three reasonable approaches, depending on your
tolerance for complexity.

1) Subclass and stick a note somewhere that says, Don't call
initWithPath:. Alternatively, *allow* initWithPath: too. This would
give you a preferences file in some other location.

2) Have the note that says Don't call initWithPath:, *and* override
it to fail in some obvious fashion so that you can catch the places
where you've used it inadvertently.

3) Don't subclass. Have a has-a relationship with the File class.
Either have a getter that returns the File instance or use message
forwarding to make it look like you have all those File methods you
really don't.

My personal preference would be for #1. Convention is sufficient for
this sort of thing, no need to enforce it.

Mike
___

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: NSDate And Super Class

2009-02-25 Thread Richard Good
Thanks for looking at the code.  I tried to simplify things for the  
example so I removed as much as possible (maybe too much) that I  
thought was not directly relevant.  However making all of your  
suggested changes  and maybe an extra retain or two, still yields an  
Out of scope problem in the debugger.  In fact at NO time during the  
initialization does the debugger show the super types NSDate's  
instance variable in scope.

-(DateTest*)init{
if (self=[super init])  {
aDate =[[NSDate date]retain];
return self;
}
return nil;
}
-(DatesubClass*)init{
if (self =[super init]) {

testStr= @Test;
return self;
}
return nil;

}
@end

DatesubClass* theDate = [[[DatesubClass alloc]init]retain];


DatesubClass* datesubClass = [[DatesubClass alloc]init];
would allocate the
On Feb 24, 2009, at 7:01 PM, Andy Lee wrote:


On Feb 24, 2009, at 8:25 PM, Richard Good wrote:

-(DateTest*)init{
[super init];
aDate =[NSDate date];
return self;
}


Wait a minute.  I just figured out you're saying the *debugger* says  
datesubClass.aDate is out of scope, not the compiler as I thought.   
The reason is that you're not retaining aDate in the init method.   
It gets deallocated prematurely and the pointer is invalid, hence  
out of scope.  Try


aDate = [[NSDate date] retain];

If it's unclear why you need to do this, you need to study memory  
management -- it's a prominent chapter in the docs, you should be  
able to find it, plus it's linked to many, many times in the list  
archives.


There are other coding issues: init methods should return id, and  
they should check the result of [super init].  There's a chapter on  
writing initializers or some such -- look for that too.


--Andy



___

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: Subclassing with more restrictive initializers

2009-02-25 Thread Andy Lee

This is a variation of the Square-Circle problem, aka Circle-Ellipse:

http://www.google.com/search?q=square+rectangle+inheritance
http://www.google.com/search?q=circle+ellipse+inheritance
http://en.wikipedia.org/wiki/Circle-ellipse_problem

You have a class that conceptually is a refinement of another class,  
which typically suggests a class-superclass relationship.  The problem  
is that the subclass would have to disallow some behavior that is  
promised by the contract of the superclass.  For example, in human- 
speak, a Square is a Rectangle, but in OO-speak, you could  
reasonably have a method -[Rectangle initWithWidth:height:] but it  
wouldn't make sense for Square.  To use your example, a PreferenceFile  
is a File, but it wouldn't make sense for it to respond to - 
initWithPath:.


The Wikipedia article linked above lists some approaches to the  
problem.  One approach that comes to mind -- use a class cluster -- is  
a variation of the Limit the interfaces option.


--Andy


On Feb 25, 2009, at 11:39 AM, Andy Klepack wrote:

I've run up against this situation more than once and I'd be  
interested in any opinions and best-practices out there.


I have a class that has one or more initializers that accept  
parameters. The class also has behavior.


I want to implement a second class that has the behavior of the  
first in addition to its own behavior. This class should also have  
more restrictive initializers. That is, the second class should not  
allow the kind of parameterization that the first class does.


On the one hand this feel a like inheritance: the second class  
really is-a kind of the first class. But those pesky initializers  
(from the first class) don't make sense for the subclass.


On the other hand, this looks kinda like trying to create an  
instance through sub-classing (and that would be wrong) except that  
behavior is being added as well.


On the other-other hand this feel like it could be composition  
(instances of the second class have-a member of the first class),  
but the behavior of the first class would have to be accessed  
through a wrapper provided by the second class.


To make things more concrete (this isn't the actual case I've run  
into, but it's a similar, simpler illustration) consider a class  
File that has an initializer 'initWithPath:' and behavior  
'delete', 'rename', etc. Then consider wanting to implement a class  
like 'PreferenceFile' that should only refer to files in the  
Preferences directory and thus has an 'initWithName: initializer.  
initWithPath provides too much parameterization since it could  
refer to any file outside of the Preferences directory. Finally, the  
PreferenceFile class should have the same behavior as File and add  
some of its own (e.g. setPrefValue:ForKey:).


Should PreferenceFile inherit from File despite the initialize  
behavior being undesirable? Is composition somehow more appropriate?  
Is this confusion the result of thinking about the problem from the  
wrong direction?


Any advice about how to think about and approach this sort of design  
problem would be great.


-Andy



aglee



___

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: Stop edit session with a NSTextField

2009-02-25 Thread Eric Gorr

Hi Andy,

On Feb 25, 2009, at 11:14 AM, Andy Lee wrote:


On Feb 24, 2009, at 6:08 PM, Eric Gorr wrote:

*** [[[self view] window] makeFirstResponder:[self view]];

Pressing return will allow the editing session to end, but pressing  
the tab key will not


Looks like controlTextDidEndEditing: is too deep within the text  
field's event handling to muck with the first responder.  Delaying  
the call to makeFirstResponder: seems to work:


   [[[self view] window]  
performSelector:@selector(makeFirstResponder:) withObject:nil  
afterDelay:0.0];


(Note this passes nil to makeFirstResponder: rather than the view.)   
I don't know if this is foolproof -- for example, I haven't tried it  
with different accessibility settings.  And note that if you  
normally have a tab loop this will defeat the tab loop.


With only a slight modification, this worked.

Since I needed to do some more work after the first responder changed,  
I ended up doing:


   [collectionView performSelector:@selector(labelStoppedEditing:)  
withObject:[self view] afterDelay:0.0];


The collectionView is my custom table that holds all of my items. I  
simply added a selector called labelStoppedEditing to it and passed as  
the object the item with the label that just stopped editing ([self  
view]).


I don't have to worry about a tab loop...at least at this point. But,  
this might change, so I am hoping that there still might be another  
solution that would support a tab loop and would not have any of the  
accessibility problems you were concerned about. As my collectionView  
can accept first responder status, I find it odd that tabbing out of  
the NSTextView does not cycle around to it. After I start the edit  
session, I printed out my responder chain:


2009-02-25 12:01:55.217 NNAOutlineCollection-VB[62103:813] first  
responder: NSTextView: 0x3e9aa0
2009-02-25 12:02:08.002 NNAOutlineCollection-VB[62103:813] next  
responder: _NSKeyboardFocusClipView: 0x3f3000
2009-02-25 12:02:16.629 NNAOutlineCollection-VB[62103:813] next  
responder: ResourceItemLabel: 0x348170
2009-02-25 12:02:19.549 NNAOutlineCollection-VB[62103:813] next  
responder: ResourceItem: 0x356690
2009-02-25 12:02:21.798 NNAOutlineCollection-VB[62103:813] next  
responder: OutlineCollectionView: 0x331e10
2009-02-25 12:02:27.142 NNAOutlineCollection-VB[62103:813] next  
responder: NSClipView: 0x326d50
2009-02-25 12:02:29.197 NNAOutlineCollection-VB[62103:813] next  
responder: OutlineCollectionScroller: 0x325650
2009-02-25 12:02:30.484 NNAOutlineCollection-VB[62103:813] next  
responder: NSView: 0x30f420
2009-02-25 12:02:31.758 NNAOutlineCollection-VB[62103:813] next  
responder: NSWindow: 0x3347d0
2009-02-25 12:02:32.938 NNAOutlineCollection-VB[62103:813] next  
responder: (null)


After I receive controlTextDidEndEditing:, the responder chain looks  
like:


2009-02-25 12:14:33.284 NNAOutlineCollection-VB[62596:813] first  
responder: NSWindow: 0x3345f0
2009-02-25 12:14:36.413 NNAOutlineCollection-VB[62596:813] next  
responder: (null)


which seems very odd. It doesn't look like a tab loop is going to work  
if I did have one. I removed the call to  
performSelector:withObject:afterDelay: and tried sticking an editable  
NSTextField on my window just to see if I could tab to it and I could  
not.



Thanks again for the suggestion. If nothing else, I did learn a little  
bit more about cocoa because of it.




___

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: NSDate And Super Class

2009-02-25 Thread Andy Lee

On Feb 25, 2009, at 12:03 PM, Richard Good wrote:
Thanks for looking at the code.  I tried to simplify things for the  
example so I removed as much as possible (maybe too much) that I  
thought was not directly relevant.  However making all of your  
suggested changes  and maybe an extra retain or two, still yields an  
Out of scope problem in the debugger.  In fact at NO time during  
the initialization does the debugger show the super types NSDate's  
instance variable in scope.


Hm, come to think of it, although your code did have a bad memory bug  
(which could have led to a crash later on), in my test I think aDate  
was still pending autorelease so that didn't explain the out of  
scope.  Also, I was assuming you're not using garbage collection,  
which may not be true.  I'm afraid I don't know what the actual  
explanation is.


BTW, if you're not using GC, don't forget to implement -dealloc to  
release the ivars you've retained, or you'll have a memory leak.


--Andy



-(DateTest*)init{
if (self=[super init])  {
aDate =[[NSDate date]retain];
return self;
}
return nil;
}
-(DatesubClass*)init{
if (self =[super init]) {

testStr= @Test;
return self;
}
return nil;

}
@end

DatesubClass* theDate = [[[DatesubClass alloc]init]retain];


DatesubClass* datesubClass = [[DatesubClass alloc]init];
would allocate the
On Feb 24, 2009, at 7:01 PM, Andy Lee wrote:


On Feb 24, 2009, at 8:25 PM, Richard Good wrote:

-(DateTest*)init{
[super init];
aDate =[NSDate date];
return self;
}


Wait a minute.  I just figured out you're saying the *debugger*  
says datesubClass.aDate is out of scope, not the compiler as I  
thought.  The reason is that you're not retaining aDate in the init  
method.  It gets deallocated prematurely and the pointer is  
invalid, hence out of scope.  Try


aDate = [[NSDate date] retain];

If it's unclear why you need to do this, you need to study memory  
management -- it's a prominent chapter in the docs, you should be  
able to find it, plus it's linked to many, many times in the list  
archives.


There are other coding issues: init methods should return id, and  
they should check the result of [super init].  There's a chapter on  
writing initializers or some such -- look for that too.


--Andy






aglee



___

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: NSDate And Super Class

2009-02-25 Thread Andy Lee

On Feb 25, 2009, at 12:28 PM, Andy Lee wrote:


On Feb 25, 2009, at 12:03 PM, Richard Good wrote:
Thanks for looking at the code.  I tried to simplify things for the  
example so I removed as much as possible (maybe too much) that I  
thought was not directly relevant.  However making all of your  
suggested changes  and maybe an extra retain or two, still yields  
an Out of scope problem in the debugger.  In fact at NO time  
during the initialization does the debugger show the super types  
NSDate's instance variable in scope.


Hm, come to think of it, although your code did have a bad memory  
bug (which could have led to a crash later on), in my test I think  
aDate was still pending autorelease so that didn't explain the out  
of scope.  Also, I was assuming you're not using garbage  
collection, which may not be true.  I'm afraid I don't know what the  
actual explanation is.


Come to think of it, I'm guessing it has to do with the fact the  
NSDate is a class cluster.


--Andy

___

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: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-25 Thread Frédéric Testuz

Le 25 févr. 09 à 00:44, Jonathan Hess a écrit :



On Feb 20, 2009, at 1:05 AM, Alexander Spohr wrote:



Am 20.02.2009 um 04:18 schrieb mmalc Crawford:



On Feb 19, 2009, at 12:34 PM, mmalc Crawford wrote:

See also updated: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmNibObjects.html 





The Doc states:
You should therefore also set outlet variables to nil in dealloc:

- (void)dealloc {
// release outlets and set outlet variables to nil
[anOutlet release], anOutlet = nil;
[super dealloc];
}

why not just use

[self setAnOutlet = nil];
or
self.anOutlet = nil;

Any danger in this? (except a bad implementation of setAnOutlet:)



Any of the standard arguments about not calling setters in dealloc  
and init would apply. For example, if you were subclassed, and your  
subclass had an override of one of your setters, and you called it  
from dealloc you'd be calling one of their methods after they'd  
called [super dealloc]. Or, you might later implement side-effects  
for one of your setters not thinking about the called-from-dealloc- 
case and introduce a subtle bug into your own code.


One question about this.

If I understand correctly the 64bit runtime, for property we don't  
have to declare ivar.

Then, if I want to init a property and clear it in dealloc I must do :

self.myProperty = anObject;  // in init

and

self.myProperty = nil;  // in dealloc

Does it mean I must always declare ivars even for 64bit only  
architecture ?


Frédéric___

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: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-25 Thread mmalc Crawford
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_4.html#//apple_ref/doc/uid/TP30001163-CH17-SW16 



mmalc

___

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: Strange NSManagedObjectContextObjectsDidChangeNotification behavior

2009-02-25 Thread Karolis Ramanauskas
 Is locationY the model attribute which you have to change?  If so, I
 suggest that this is not rightfully a model or managed object attribute.
  Obviously, it's more of a 'view' thing than a 'model' thing.  Remove it
 from your data model.  Make it a regular instance variable instead or,
 better yet, remove it entirely from your model class and calculate it in
 your view class when you need to draw.  Thousands of apps do it that way --
 it will work for your app too!

All this time thinking, concocting amazingly elaborate schemes how I
will make this work using several notifications, etc... This never
occurred to me! Thanks! It's true, I always dynamically calculate
this... Thanks again.
___

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: do i need to create autorelease pool?

2009-02-25 Thread Memo Akten
Ah ok, thats what I wasn't sure about, whether or not the pool would  
be released after every timer update. So if no events come in for a  
few seconds, Ill have my runloops autorelease pool swelling up -  
which is not desired. My solution of creating my own autorelease pool  
before all app update+draw works, but is there a convention for the  
handling of this situation? Create my own autorelease pool vs. posting  
a fake event? For readability sake I guess creating a second pool  
makes more sense?



On 25 Feb 2009, at 16:44, Michael Ash wrote:

On Wed, Feb 25, 2009 at 12:00 AM, Peter N Lewis pe...@stairways.com.au 
 wrote:
The Application Kit creates an autorelease pool on the main thread  
at the
beginning of every cycle of the event loop, and drains it at the  
end,
thereby releasing any autoreleased objects generated while  
processing an

event.


This is assuming iPhone or Leopard, I believe the NSAutoreleasePool  
creation

was required for older versions of Mac OS X.


The semantics haven't changed on Leopard as far as I know. The above
has been the case forever: pools are created and destroyed on
*events*, but not timers. If you simply run a timer forever and never
process events, your memory usage will grow without limit. A pool
exists, so you don't explicitly leak, but the pool is only drained
when an event arrives. If you're going to be running something in
timers or other non-event sources, you'll want to post a fake event to
the main event loop from time to time (or just after every action you
take) to force the pool to drain.

I have *no* idea how much of that, if any, applies to the iPhone. In
any case if you're processing events on a regular basis as well then
you don't have to worry about anything.

Mike
___

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/memo%40memo.tv

This email sent to m...@memo.tv


___

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: Subclassing with more restrictive initializers

2009-02-25 Thread Andy Klepack
Ah, it looks like I'm in good company :)

Thanks for the references!

-Andy

-Original Message-
From: Andy Lee [mailto:ag...@mac.com] 
Sent: Wednesday, February 25, 2009 9:16 AM
To: Andy Klepack
Cc: Cocoa-dev@lists.apple.com
Subject: Re: Subclassing with more restrictive initializers

This is a variation of the Square-Circle problem, aka Circle-Ellipse:

http://www.google.com/search?q=square+rectangle+inheritance
http://www.google.com/search?q=circle+ellipse+inheritance
http://en.wikipedia.org/wiki/Circle-ellipse_problem

You have a class that conceptually is a refinement of another class,  
which typically suggests a class-superclass relationship.  The problem  
is that the subclass would have to disallow some behavior that is  
promised by the contract of the superclass.  For example, in human- 
speak, a Square is a Rectangle, but in OO-speak, you could  
reasonably have a method -[Rectangle initWithWidth:height:] but it  
wouldn't make sense for Square.  To use your example, a PreferenceFile  
is a File, but it wouldn't make sense for it to respond to - 
initWithPath:.

The Wikipedia article linked above lists some approaches to the  
problem.  One approach that comes to mind -- use a class cluster -- is  
a variation of the Limit the interfaces option.

--Andy


On Feb 25, 2009, at 11:39 AM, Andy Klepack wrote:

 I've run up against this situation more than once and I'd be  
 interested in any opinions and best-practices out there.

 I have a class that has one or more initializers that accept  
 parameters. The class also has behavior.

 I want to implement a second class that has the behavior of the  
 first in addition to its own behavior. This class should also have  
 more restrictive initializers. That is, the second class should not  
 allow the kind of parameterization that the first class does.

 On the one hand this feel a like inheritance: the second class  
 really is-a kind of the first class. But those pesky initializers  
 (from the first class) don't make sense for the subclass.

 On the other hand, this looks kinda like trying to create an  
 instance through sub-classing (and that would be wrong) except that  
 behavior is being added as well.

 On the other-other hand this feel like it could be composition  
 (instances of the second class have-a member of the first class),  
 but the behavior of the first class would have to be accessed  
 through a wrapper provided by the second class.

 To make things more concrete (this isn't the actual case I've run  
 into, but it's a similar, simpler illustration) consider a class  
 File that has an initializer 'initWithPath:' and behavior  
 'delete', 'rename', etc. Then consider wanting to implement a class  
 like 'PreferenceFile' that should only refer to files in the  
 Preferences directory and thus has an 'initWithName: initializer.  
 initWithPath provides too much parameterization since it could  
 refer to any file outside of the Preferences directory. Finally, the  
 PreferenceFile class should have the same behavior as File and add  
 some of its own (e.g. setPrefValue:ForKey:).

 Should PreferenceFile inherit from File despite the initialize  
 behavior being undesirable? Is composition somehow more appropriate?  
 Is this confusion the result of thinking about the problem from the  
 wrong direction?

 Any advice about how to think about and approach this sort of design  
 problem would be great.

 -Andy


aglee




___

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: Stop edit session with a NSTextField

2009-02-25 Thread Eric Gorr


On Feb 25, 2009, at 12:20 PM, Eric Gorr wrote:


On Feb 25, 2009, at 11:14 AM, Andy Lee wrote:


On Feb 24, 2009, at 6:08 PM, Eric Gorr wrote:

*** [[[self view] window] makeFirstResponder:[self view]];

Pressing return will allow the editing session to end, but  
pressing the tab key will not


Looks like controlTextDidEndEditing: is too deep within the text  
field's event handling to muck with the first responder.  Delaying  
the call to makeFirstResponder: seems to work:


  [[[self view] window]  
performSelector:@selector(makeFirstResponder:) withObject:nil  
afterDelay:0.0];


(Note this passes nil to makeFirstResponder: rather than the  
view.)  I don't know if this is foolproof -- for example, I haven't  
tried it with different accessibility settings.  And note that if  
you normally have a tab loop this will defeat the tab loop.


With only a slight modification, this worked.

Since I needed to do some more work after the first responder  
changed, I ended up doing:


  [collectionView performSelector:@selector(labelStoppedEditing:)  
withObject:[self view] afterDelay:0.0];


The collectionView is my custom table that holds all of my items. I  
simply added a selector called labelStoppedEditing to it and passed  
as the object the item with the label that just stopped editing  
([self view]).


I don't have to worry about a tab loop...at least at this point.  
But, this might change, so I am hoping that there still might be  
another solution that would support a tab loop and would not have  
any of the accessibility problems you were concerned about. As my  
collectionView can accept first responder status, I find it odd that  
tabbing out of the NSTextView does not cycle around to it. After I  
start the edit session, I printed out my responder chain:


2009-02-25 12:01:55.217 NNAOutlineCollection-VB[62103:813] first  
responder: NSTextView: 0x3e9aa0
2009-02-25 12:02:08.002 NNAOutlineCollection-VB[62103:813] next  
responder: _NSKeyboardFocusClipView: 0x3f3000
2009-02-25 12:02:16.629 NNAOutlineCollection-VB[62103:813] next  
responder: ResourceItemLabel: 0x348170
2009-02-25 12:02:19.549 NNAOutlineCollection-VB[62103:813] next  
responder: ResourceItem: 0x356690
2009-02-25 12:02:21.798 NNAOutlineCollection-VB[62103:813] next  
responder: OutlineCollectionView: 0x331e10
2009-02-25 12:02:27.142 NNAOutlineCollection-VB[62103:813] next  
responder: NSClipView: 0x326d50
2009-02-25 12:02:29.197 NNAOutlineCollection-VB[62103:813] next  
responder: OutlineCollectionScroller: 0x325650
2009-02-25 12:02:30.484 NNAOutlineCollection-VB[62103:813] next  
responder: NSView: 0x30f420
2009-02-25 12:02:31.758 NNAOutlineCollection-VB[62103:813] next  
responder: NSWindow: 0x3347d0
2009-02-25 12:02:32.938 NNAOutlineCollection-VB[62103:813] next  
responder: (null)


After I receive controlTextDidEndEditing:, the responder chain looks  
like:


2009-02-25 12:14:33.284 NNAOutlineCollection-VB[62596:813] first  
responder: NSWindow: 0x3345f0
2009-02-25 12:14:36.413 NNAOutlineCollection-VB[62596:813] next  
responder: (null)


which seems very odd. It doesn't look like a tab loop is going to  
work if I did have one. I removed the call to  
performSelector:withObject:afterDelay: and tried sticking an  
editable NSTextField on my window just to see if I could tab to it  
and I could not.


So, now what seems to be working well is:

1. Make the NSTextField not selectable or editable by default
2. When the user clicks on the NSTextField, change it to be selectable  
and editable
3. When controlTextDidEndEditing: is called, change the field back to  
not being selectable or editable


With this there isn't a need try to manually change the first  
responder, remove the NSTextView from the window, or do a delayed  
performSelector call.


There still may be something funky with the tab loop...I am still  
looking into it.

___

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: Running Cocoa applications from file servers

2009-02-25 Thread Kyle Sluder
On Wed, Feb 25, 2009 at 11:48 AM, I. Savant idiotsavant2...@gmail.com wrote:
  ... because network interruptions (especially intermittent ones) can
 wreak havoc on your running apps. :-) That's my main reason.

How so?  Resource loading?  I guess it was less of an issue back in
the NeXT days.  But I've got ten machines in my lab, and an Xserve
serving out /Network/Library... why can't I use /Network/Applications
and have it Just Work(TM)?  I'm not all that worried about network
interruptions.

--Kyle Sluder
___

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: Running Cocoa applications from file servers

2009-02-25 Thread I. Savant
On Wed, Feb 25, 2009 at 11:48 AM, I. Savant idiotsavant2...@gmail.com wrote:
 On Wed, Feb 25, 2009 at 10:43 AM, Erik Buck erik.b...@sbcglobal.net wrote:

 Where did the fetish for installing every single application on the local 
 hard disk come from ?  Isn't it insane to have 35 installed copies of 
 OmniGraffle using up disk space just because you have 35 licenses ?  Why is 
 MS Word on every disk instead of just the server?

  ... because network interruptions (especially intermittent ones) can
 wreak havoc on your running apps. :-) That's my main reason.

  I was rushing off to a meeting, but I wanted to expand on this a
bit. Most complicated applications won't be loading all their
resources when they're launched (if they're worth a damn, that is), so
consider what would happen if, as happened today at my place of
employment, a wide-spread electrical problem caused all the internal
switches to randomly go up and down for half the day.

  What if I were performing a function in such a server-hosted app
which needs to load one or more resources? Would the app handle the
situation properly? Probably not. If properly can include throwing
an error and dying, well, okay, many apps are developed carefully
enough that this situation would be handled, but when there are
network issues, the app is pretty much not usable when these issues
are going on. At least if it's local (as are the temp files it may
create) and you're working on a local document, network be damned.

  Let's face it, though, most of us couldn't claim with absolute
confidence that our application would handle network interruptions
gracefully if it were being run from a network volume. Sure, if I
can't load a NIB or some other vital resource, my apps throw errors
and quit (refusing to save changes because in some cases that could be
dangerous), but it takes a lot of development effort to be sure that
the sudden inability to reach a resource on disk is handled well in
every case. The fact is, I don't have much faith that many apps out
there do so.

--
I.S.
___

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: Subclassing with more restrictive initializers

2009-02-25 Thread Quincey Morris

On Feb 25, 2009, at 08:39, Andy Klepack wrote:

Should PreferenceFile inherit from File despite the initialize  
behavior being undesirable? Is composition somehow more appropriate?  
Is this confusion the result of thinking about the problem from the  
wrong direction?


Any advice about how to think about and approach this sort of design  
problem would be great.


Also see:

	http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_4.html#/ 
/apple_ref/doc/uid/TP30001163-CH22-SW5


which sort of contains an answer to your question:

A class must also make sure that all inherited initialization methods  
work. For example, if class A defines an init method and its subclass  
B defines an initWithName: method ..., B must also make sure that an  
init message successfully initializes B instances. The easiest way to  
do that is to replace the inherited init method with a version that  
invokes initWithName: ... Covering inherited initialization methods  
makes the class you define more portable to other applications. If you  
leave an inherited method uncovered, someone else may use it to  
produce incorrectly initialized instances of your class.


In practice, though, I agree with Michael that leaving superclass  
initializers uncovered is not a big problem, unless it exposes some  
kind of security exploit.



___

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


NSTableView Cell edit values.

2009-02-25 Thread Totte Alm

Hello cocoa experts,

I've stumbled on a problem with a GUI, where the user can edit values  
using a NSTableView, but if the user types something in a cell, then  
click the do stuff button while the cell is still in editmode, the  
current change is not propagated back to underlying object.


So, the question:
How can I tell the NSTableView to propagate current changes, i.e.  
stop being in edit mode?


// Totte

==
Experience is what you get when you expected something else.




___

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: Running Cocoa applications from file servers

2009-02-25 Thread I. Savant
On Wed, Feb 25, 2009 at 1:16 PM, Kyle Sluder kyle.slu...@gmail.com wrote:

 How so?  Resource loading?  I guess it was less of an issue back in
 the NeXT days.  But I've got ten machines in my lab, and an Xserve
 serving out /Network/Library... why can't I use /Network/Applications
 and have it Just Work(TM)?

  Well, see my last response for the general overview of my reasoning.
For specifics, though, consider that your setup is not the only
network topology.

  Imagine a complicated app with many resources (its UI divided up
into many nibs like Mail.app, and different sounds and plug-ins,
etc.). To mitigate this problem so that it just works (as long as
you can initially launch the application successfully), the
application would have to load *everything*, which obviates most of
the benefit of separating things into separate nibs, loading them only
when needed. Obviously, this is even less desirable on a larger app
that's being loaded over the network (loading everything takes
longer).


 I'm not all that worried about network interruptions.

  Must be nice. ;-)  Even in the simplest topologies, they happen, so
you *should* be ...

  Imagine a more complicated network topology. Many business and other
institutions are larger and more complicated. The application server
might be centrally managed by corporate headquarters, which may or may
not be where you are. We pay top dollar for the fastest
point-to-point connections, so it'll load plenty fast, they say. What
they don't think of are interruptions and they certainly don't tend to
test even business-critical applications for robustness in this
scenario ... how many man-hours are lost if the app fails ungracefully
and whacks important data?

  More than that, though, are sprawling LANS with old equipment or
power problems. Wireless networks which are prone to interference.
Network interruptions *happen*, so while one network might be
reliable, it's been my experience in the many business and institutes
I've worked for that most aren't 100%.

  There's no planning for the many kinds of network environments on
which your apps may be run, but you can at least plan for plenty of
those environments being unreliable. In this case, your only choice is
to load every resource the app needs at launch, or over-engineer the
hell out of the app so that it intelligently handles every possibility
that can arise from a resource not being available at runtime (and
deciding whether it's safe to save data in that state, etc).

  Personally, my previous employers were an engineering firm who ran
*everything* from the server. Apps, home folders, the works. A screwed
up server installation (which the admin team refused to accept and
handle for weeks) ended up corrupting drawings, losing business
documents, and more until tens of thousands of dollars of man-hours
were wasted and deadlines were missed. With sufficient screaming from
management, the problem was fixed, but it highlighted the dangerous
nature of the problem.

Lessons learned:

 - Use portable home folders, rather than server-hosted home folders.
 - Install apps locally since many of them freaked the hell out when
they couldn't load resources all the sudden, disallowing even a local
save to their machine.
 - When your server(s) are everything, don't let them get so bad they
bring down the whole f*g company!
 - Even software developers can point out specific OS issues for the
admin team ... ;-)

  Put simply, yes, there are other problems caused by intermittent
network outages, but like those other problems, there're no simple
solutions. You always sacrifice convenience for safety or the other
way around. In this case, you can load all your resources or
over-engineer the app to handle every 'missing resource' situation
perfectly.

--
I.S.
___

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: NSTableView Cell edit values.

2009-02-25 Thread Corbin Dunn


Le Feb 25, 2009 à 10:44 AM, Totte Alm a écrit :


Hello cocoa experts,

I've stumbled on a problem with a GUI, where the user can edit  
values using a NSTableView, but if the user types something in a  
cell, then click the do stuff button while the cell is still in  
editmode, the current change is not propagated back to underlying  
object.


So, the question:
How can I tell the NSTableView to propagate current changes, i.e.  
stop being in edit mode?


Make the field editor resign first responder status; if it did  
successfully do that, then the change was committed. If not, a  
validation error happened. IE:


[self.window makeFirstResponder:tableView];

.corbin


___

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: Subclassing with more restrictive initializers

2009-02-25 Thread Paul Sanders
My solution would be to cover *all* inherited initialisers and assert in any 
not supported by the subclass.  The idea, surely, is to catch any 
programming errors as early as possible.  Not covering an initialiser which, 
if called, would lead to unpredictable results seems to me to be taking an 
unnecessary risk (of introducing a bug).

*Now* all we need is an implementation of assert that does something a 
little more useful than SIGABRT.  But that is a detail.

- Original Message - 
From: Quincey Morris quinceymor...@earthlink.net
To: cocoa-dev@lists.apple.com
Sent: Wednesday, February 25, 2009 6:38 PM
Subject: Re: Subclassing with more restrictive initializers


On Feb 25, 2009, at 08:39, Andy Klepack wrote:

 Should PreferenceFile inherit from File despite the initialize
 behavior being undesirable? Is composition somehow more appropriate?
 Is this confusion the result of thinking about the problem from the
 wrong direction?

 Any advice about how to think about and approach this sort of design
 problem would be great.

Also see:

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_4.html#/
/apple_ref/doc/uid/TP30001163-CH22-SW5

which sort of contains an answer to your question:

A class must also make sure that all inherited initialization methods
work. For example, if class A defines an init method and its subclass
B defines an initWithName: method ..., B must also make sure that an
init message successfully initializes B instances. The easiest way to
do that is to replace the inherited init method with a version that
invokes initWithName: ... Covering inherited initialization methods
makes the class you define more portable to other applications. If you
leave an inherited method uncovered, someone else may use it to
produce incorrectly initialized instances of your class.

In practice, though, I agree with Michael that leaving superclass
initializers uncovered is not a big problem, unless it exposes some
kind of security exploit.


___

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/p.sanders%40dsl.pipex.com

This email sent to p.sand...@dsl.pipex.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: Running Cocoa applications from file servers

2009-02-25 Thread Jonathan Hendry


On Feb 25, 2009, at 11:48 AM, I. Savant wrote:

On Wed, Feb 25, 2009 at 10:43 AM, Erik Buck  
erik.b...@sbcglobal.net wrote:


Where did the fetish for installing every single application on the  
local hard disk come from ?  Isn't it insane to have 35 installed  
copies of OmniGraffle using up disk space just because you have 35  
licenses ?  Why is MS Word on every disk instead of just the server?


 ... because network interruptions (especially intermittent ones) can
wreak havoc on your running apps. :-) That's my main reason.


This is even more the case for the Citrix/Terminal Server model of  
application use, but that's quite popular.


It was quite convenient at the bank I worked at, to be able to change  
machines at will because home directories and /Network/Applications  
were NFS-mounted. You could even go to another building several  
streets away and get the same setup.


Yes, sometimes NFS hosed up and the NeXTStep machines went into  
spinning-disk land for extended periods, but it wasn't a crippling  
problem, and only happened a handful of times in several years.



___

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: NSTableView Cell edit values.

2009-02-25 Thread Totte Alm

hello,

thx for the fast answer, but it seems to be more to it.

The save is done in a IBAction, trigged by a button. I moved all  
save code from that method to another method, and set an NSTimer to  
call that mathod, and before that I told the the Window to set the  
focus. The problem is that no matter what time I set on the NSTimer,  
the setObjectValue delegate for the NSTableView (which get the newly  
edited value) is called after the method called from the NSTimer is  
called, which does the save.


There must be a way to trigger setObjectValue directly so it is  
handled now and not later.


cheers,

/ Totte

25 feb 2009 kl. 19.58 skrev Corbin Dunn:



Le Feb 25, 2009 à 10:44 AM, Totte Alm a écrit :


Hello cocoa experts,

I've stumbled on a problem with a GUI, where the user can edit  
values using a NSTableView, but if the user types something in a  
cell, then click the do stuff button while the cell is still in  
editmode, the current change is not propagated back to underlying  
object.


So, the question:
How can I tell the NSTableView to propagate current changes, i.e.  
stop being in edit mode?


Make the field editor resign first responder status; if it did  
successfully do that, then the change was committed. If not, a  
validation error happened. IE:


[self.window makeFirstResponder:tableView];

.corbin





--
- There is no spoon. / Neo

___

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: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-25 Thread Frédéric Testuz

Le 25 févr. 09 à 18:37, mmalc Crawford a écrit :

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_4.html#//apple_ref/doc/uid/TP30001163-CH17-SW16 



mmalc


OK, thank you

Frédéric

___

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: Running Cocoa applications from file servers

2009-02-25 Thread Michael Ash
On Wed, Feb 25, 2009 at 1:21 PM, I. Savant idiotsavant2...@gmail.com wrote:
  I was rushing off to a meeting, but I wanted to expand on this a
 bit. Most complicated applications won't be loading all their
 resources when they're launched (if they're worth a damn, that is), so
 consider what would happen if, as happened today at my place of
 employment, a wide-spread electrical problem caused all the internal
 switches to randomly go up and down for half the day.

Note that there's no need to add the qualifier most complicated
here. *All* applications load resources lazily, simply because OS X
uses memory-mapped executables. The binary doesn't get loaded into RAM
all at once, it gets loaded on demand. If the network dies and then
you try to access some code that either was never loaded or got
purged, game over. If the network disk is gone then the application
will segfault and crash. If the network disk is still mounted then it
will freeze until either you can convince the system to start it
working again, or until it goes away and then the app will segfault.

Mike
___

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


-[_NSControllerObjectProxy entity]: unrecognized selector sent to instance

2009-02-25 Thread Daniel Child

Hi All,

I am trying to add an object in a to-many relationship and get this  
error:


-[_NSControllerObjectProxy entity]: unrecognized selector sent to  
instance the instance


The object I'm adding was obtained by using
NSManagedObject *theWord = [wordList selection]
This yields a proxy object instead of an MO. (Does anyone know why?)

If I obtain the object using:
*theWord = [[wordList selectedObjects] objectAtIndex: 0];
 then when I try to add the Word to my relatedWords relationship to  
character, I instead get this error.


-[NSManagedObject copyWithZone:]: unrecognized selector sent to  
instance 0x1adf50


I simply don't see what I've done wrong. Here is the code. Thanks for  
looking


 - (IBAction) relateSelectedWordToConstituentCharacters: (id) sender
{
NSManagedObjectContext *moc = [self managedObjectContext];

	// NSManagedObject *theWord = [wordList selection]; // PROBLEM HERE  
(yields proxy object!!! not MO / unclear why)
	NSManagedObject *theWord = [[wordList selectedObjects] objectAtIndex:  
0]; // OR HERE (causes mutable copy error below)


NSManagedObject *charObject;
NSMutableSet *relatedWords;
NSString *wordAsString = [theWord valueForKey: @compound];
	NSMutableArray *constituentChars =  
getConstituentCharacters(wordAsString);

BOOL charExists;
for (NSString *oneChar in constituentChars) {
charExists = characterExistsInCharacterEntity(oneChar);
if (!charExists) {
			charObject = [NSEntityDescription insertNewObjectForEntityForName:  
@Characters inManagedObjectContext: moc];

[charObject setValue: oneChar forKey: @character];
}
else {
			charObject = getCharObject(oneChar); // function to execute the  
fetch based on the oneChar string

}
relatedWords = [charObject mutableSetValueForKey: @words];
[relatedWords addObject: theWord]; // mutable copy error here
// NEED TO SAVE CHANGES TO MOC HERE ONCE IT WORKS
}
}

___

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: NSTableView Cell edit values.

2009-02-25 Thread Corbin Dunn
I can tell you for sure that resigning the first responder will make  
it happen. Maybe something else is wrong in your code. I can't tell  
without more information.


corbin

Le Feb 25, 2009 à 11:19 AM, Totte Alm a écrit :


hello,

thx for the fast answer, but it seems to be more to it.

The save is done in a IBAction, trigged by a button. I moved all  
save code from that method to another method, and set an NSTimer to  
call that mathod, and before that I told the the Window to set the  
focus. The problem is that no matter what time I set on the NSTimer,  
the setObjectValue delegate for the NSTableView (which get the newly  
edited value) is called after the method called from the NSTimer is  
called, which does the save.


There must be a way to trigger setObjectValue directly so it is  
handled now and not later.


cheers,

/ Totte

25 feb 2009 kl. 19.58 skrev Corbin Dunn:



Le Feb 25, 2009 à 10:44 AM, Totte Alm a écrit :


Hello cocoa experts,

I've stumbled on a problem with a GUI, where the user can edit  
values using a NSTableView, but if the user types something in a  
cell, then click the do stuff button while the cell is still in  
editmode, the current change is not propagated back to underlying  
object.


So, the question:
How can I tell the NSTableView to propagate current changes,  
i.e. stop being in edit mode?


Make the field editor resign first responder status; if it did  
successfully do that, then the change was committed. If not, a  
validation error happened. IE:


[self.window makeFirstResponder:tableView];

.corbin





--
- There is no spoon. / Neo



___

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: Running Cocoa applications from file servers

2009-02-25 Thread Quincey Morris

On Feb 25, 2009, at 10:54, I. Savant wrote:

On Wed, Feb 25, 2009 at 1:16 PM, Kyle Sluder kyle.slu...@gmail.com  
wrote:



How so?  Resource loading?  I guess it was less of an issue back in
the NeXT days.  But I've got ten machines in my lab, and an Xserve
serving out /Network/Library... why can't I use /Network/Applications
and have it Just Work(TM)?


 Well, see my last response for the general overview of my reasoning.


And there's a performance consideration as well as a failure  
consideration. Eventually, in general, there'll be enough concurrent  
users slinging enough data around the network to make noticeable  
delays. That applies at the level of overall network bandwidth, and at  
the level of individual machine network interface bandwidth (which is  
typically a lot smaller).

___

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


[Q] SQLite corruption issue[?] and how to avoid[?]

2009-02-25 Thread Jon C. Munson II
Namaste!

I have a niggling problem that isn't repeatable, nor consistent, but seems
to occur only when my application starts up.  That problem is various SQLite
errors when an attempt is made to get to the database.  While I'm not sure
*when* this happens exactly, I'm guessing it happens either in the initial
-persistentStoreCoordinator app delegate method, or when the first fetch is
executed.  Since the problem doesn't occur with any frequency nor is
repeatable, I'm not really able to catch it.

Right now my app crashes outright, then it takes several application
restarts to get the database back to usability.

I do know that one possible cause of the problem was a power outage we
experienced last night.  While my app wasn't running, I did have to power up
the Mac.  When I ran my app, it crashed with a final SQLite3Error.  Several
application restarts later I have no trouble using the application.

I did check the Core Data Programming Guide to see if there were any
housekeeping methods I could use, and also did some digging on the 'net (I
did find I.S.' thread on housekeeping from nearly a year ago which discussed
VACUUM and auto_vacuum).  However, I wasn't able to find anything leaning
towards what I'd like to do.

So, what I'd like to do is put an initial check in
-persistentStoreCoordinator (or somewhere better) that could verify the
database's file integrity, and if kaboshed, repair it.

If anyone has a way of doing that, I'd appreciate knowing about it.

Many thanks in advance!

Peace, Love, and Light,

/s/ Jon C. Munson II



___

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: -[_NSControllerObjectProxy entity]: unrecognized selector sent to instance

2009-02-25 Thread Kyle Sluder
On Wed, Feb 25, 2009 at 2:43 PM, Daniel Child wch...@hawaii.edu wrote:
 The object I'm adding was obtained by using
 NSManagedObject *theWord = [wordList selection]
 This yields a proxy object instead of an MO. (Does anyone know why?)

Read the documentation for -[NSObjectController selection].  It's
right there in black and white: A proxy object representing the
receiver’s selection. This object is fully key-value coding compliant,
but note that it is a proxy and so does not provide the full range of
functionality that might be available in the source object.

 -[NSManagedObject copyWithZone:]: unrecognized selector sent to instance
 0x1adf50

Typically this happens when you've bound a view to the selectedObjects
of a controller and not provided a keypath.  Often times views copy
their object values, but NSManagedObjectContext does not support
NSCopying.  Make sure that all your bindings are to keypaths, not just
to the objects themselves.

--Kyle Sluder
___

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: NSTableView Cell edit values.

2009-02-25 Thread Totte Alm

Hello,

25 feb 2009 kl. 19.58 skrev Corbin Dunn:

Make the field editor resign first responder status; if it did  
successfully do that, then the change was committed. If not, a  
validation error happened. IE:


[self.window makeFirstResponder:tableView];



I might be doing this part wrong

This is the Action method involved

// --
// doFlaggning
// --
- (IBAction) doFlaggning:(id)sender
{

// Fix focus
[mWindow makeFirstResponder:mNameList];

	[NSTimer scheduledTimerWithTimeInterval:kTestTime target:self  
selector:@selector(realDoFlagging:) userInfo:nil repeats:NO];

}

The result is this from my logs.

2009-02-25 20:14:25.266 ABolag-III[52341:813] realDoFLagging
2009-02-25 20:14:25.433 ABolag-III[52341:813] setObjectValue called

// Totte


=
Why do programmers always mixup christmas and halloween?
OCT 30; Halloween
DEC 24; Christmas



___

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: Metrics for a NSTextField

2009-02-25 Thread Eric Gorr

Hello Martin,

Martin Wierschin wrote:

 Hi Eric,

  NSTextView *fieldEditor = (NSTextView*)[[self window]  
fieldEditor:YES
   
forObject:self];

  NSRect usedRect = [[fieldEditor layoutManager]
 usedRectForTextContainer:[fieldEditor  
textContainer]];

 
  But the used rect returned is empty and [self stringValue] does  
contain a

  string of  0 characters.

 If you check the documentation for the usedRectForTextContainer:
 method, it does not trigger any layout. So you'll want to first call
 something like ensureLayoutForTextContainer: before asking your
 question.

I thought that was going to work, but unfortunately, it doesn't quite.

What I want to do is (mostly) pictured at:

http://ericgorr.net/cocoadev/outlinetable/namedparts.png

Instead of the black rectangle drawn around the text in the  
NSTextField, I would like to draw something akin to what one sees for  
a label in a IKImageBrowserView. In order to do that, I need to know  
the rectangle of the text in the field.


In order to do this, I subclassed my NSTextField and altered the  
drawRect: method to be:


- (void) drawRect:(NSRect)dirtyRect
{
NSTextView  *currentEditor  = (NSTextView*)[self currentEditor];
NSLog( @ResourceItemLabel: drawRect: currentEditor: %@,  
currentEditor );


if ( currentEditor == nil ) {
NSTextView *fieldEditor = (NSTextView*)[[self window]  
fieldEditor:YES forObject:self];

[fieldEditor setString:[self stringValue]];

NSLog( @ResourceItemLabel: fieldEditor: %@,
   fieldEditor );

NSLog( @ResourceItemLabel: layoutManager: %@,
   [fieldEditor layoutManager] );

NSLog( @ResourceItemLabel: textContainer: %@, %@,
   [fieldEditor textContainer],
   NSStringFromSize( [[fieldEditor textContainer]  
containerSize] ) );


[[fieldEditor layoutManager]
 ensureLayoutForTextContainer:[fieldEditor textContainer]];

NSRect usedRect = [[fieldEditor layoutManager]  
usedRectForTextContainer:[fieldEditor textContainer]];


NSLog( @usedRectForTextContainer: %@, %@,
   NSStringFromRect( usedRect ), [self stringValue] );

[[NSColor blueColor] setFill];
[NSBezierPath fillRect:usedRect];

}

[super drawRect:dirtyRect];
}


I only want to do this special drawing when the user isn't editing the  
label and asking for the currentEditor allows me to do that.


The output when it draws the label is:

2009-02-25 14:35:32.146 OutlineCollection-VB[69495:813]  
ResourceItemLabel: drawRect: currentEditor: (null)


2009-02-25 14:35:37.445 OutlineCollection-VB[69495:813]  
ResourceItemLabel: fieldEditor: NSTextView: 0x36f1d0
Frame = {{0.00, 0.00}, {0.00, 0.00}}, Bounds = {{0.00, 0.00},  
{0.00, 0.00}}

Horizontally resizable: NO, Vertically resizable: YES
MinSize = {0.00, 0.00}, MaxSize = {0.00, 1000.00}

2009-02-25 14:35:38.809 OutlineCollection-VB[69495:813]  
ResourceItemLabel: layoutManager: NSLayoutManager: 0x36fe10

1 containers, text backing has 8 characters
selected character range {8, 0} affinity: upstream granularity:  
character

marked character range {8, 0}
Currently holding 8 glyphs.
Glyph tree contents:  8 characters, 8 glyphs, 1 nodes, 32 node  
bytes, 0 storage bytes, 32 total bytes, 4.00 bytes per character, 4.00  
bytes per glyph
Layout tree contents:  8 characters, 8 glyphs, 0 laid glyphs, 0  
laid line fragments, 1 nodes, 32 node bytes, 0 storage bytes, 32 total  
bytes, 4.00 bytes per character, 4.00 bytes per glyph, 0.00 laid  
glyphs per laid line fragment, 0.00 bytes per laid line fragment


2009-02-25 14:35:44.824 OutlineCollection-VB[69495:813]  
ResourceItemLabel: textContainer: NSTextContainer: 0x370530, {0, 1e 
+07}


2009-02-25 14:35:46.633 OutlineCollection-VB[69495:813]  
usedRectForTextContainer: {{0, 0}, {0, 0}}, nacreous



The usedRect empty. I believe the reason why is because the  
fieldEditor that the window has given me has a zero width.


Eventually, I will want to use usedRect to determine the height of the  
label, so it is not a solution to simply do:


  [[NSColor blueColor] setFill];
  [NSBezierPath fillRect:[self bounds]];

I did just spot boundingRectForGlyphRange:inTextContainer: which  
apparently will force the layout to occur, saving me from needing to  
call ensureLayoutForTextContainer: myself. However, until I can get a  
valid field editor for the NSTextField, I'm stuck.



If anyone has a suggestion on how to better accomplish this task, I am  
interested.


___

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 

Re: Gamma problem (?) with CIFilter output

2009-02-25 Thread Shamyl Zakariya
Well, with some experimentation I solved it by creating a CIContext  
with a device rgb color space... my initial perusal of the CIContext  
docs didn't make it immediately obvious to me that I could create a  
CIContext from the current NSGraphicsContext displayPort.




On Feb 25, 2009, at 11:47 AM, Shamyl Zakariya wrote:


Hi,

If this should be posted to another list let me know, but I didn't  
see a Core Image list, so I figured Cocoa might be a good catch-all.


Anyway, I'm writing my first Core Image filter, a simple bump-map to  
tangent-space-normalmap filter. I've done this in GLSL before, and  
I've even done it in straight C. I figured it would make a good  
hello-world for Core Image. The kernel just computes changes in  
luminance along x  y and converts that to a normal.


Here's an example source ( bumpmap ) image:
http://shamyl.zakariya.net/etc/Bump.png

And here's what my vanilla C implementation outputs:
http://shamyl.zakariya.net/etc/Bump_NM.png

And here's what my CI Filter outputs:
http://shamyl.zakariya.net/etc/Bump_Ugly.png

The good news is that I'm outputting what superficially appears to  
be correct output. The colors are tinting in the right direction.


The bad news is that some sort of color-space conversion seems to be  
happening -- I figure it's a gamma correction for my LCD. But I  
don't want any correction: I want the output to be the numbers I  
compute.


To make certain I wasn't crazy, I did some simple tests, where I  
output a solid color, and then used photoshop to sample screenshots  
( crude, I know ).


- return vec4( 0,0,0,1 ) resulted in pure black: GOOD
- return vec4( 1,1,1,1 ) results in pure white: GOOD
	- vec4( 1,0.5,0.5,1 ) gives me something like ( 1,0.66,0.66,1.0) -  
BAD!



Also, I googled, and found the following thread:
http://lists.apple.com/archives/quartz-dev/2008/Jan/threads.html#00061

It seems like the issue is one of color profiles, but what I don't  
know is how to get CI to use a linear or generic profile.


Of course, I might also be barking up the wrong tree.

Thanks,

shamyl zakariya
   - pillow-shaped and vaguely striated
  to echo piratical treasure chests



___

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: Gamma problem (?) with CIFilter output

2009-02-25 Thread Kyle Sluder
On Wed, Feb 25, 2009 at 11:47 AM, Shamyl Zakariya sha...@gmail.com wrote:
 If this should be posted to another list let me know, but I didn't see a
 Core Image list, so I figured Cocoa might be a good catch-all.

quartz-dev might be your best bet.

--Kyle Sluder
___

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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Jerry Krinock


On 2009 Feb 25, at 11:24, Quincey Morris wrote:

I'm not making any absolute assertions here, but this doesn't seem  
right to me. If 'awakeFromFetch' isn't called when an object is  
faulted in, then transient properties (for example) could never be  
worth a damn. I couldn't see anything in the documentation that  
*explicitly* says that 'awakeFromFetch' is called in these  
circumstances, but nothing else makes any sense.


To confirm the breaking of the observer after delete and undo which I  
saw in my app, I did a quick experiment with DepartmentAndEmployees .   
I added NSLogs to -awakeFromInsert, -awakeFromFetch and - 
didTurnIntoFault. [1]



TEST #1 Using a Newly-Inserted Object

Click the Add button to add an Employee...
12:09:35 -[Employee awakeFromInsert]

Click the Add button on the sheet, to, I guess, set attributes:
12:09:46 -[Employee awakeFromInsert]
12:09:46 -[Employee didTurnIntoFault]

Select the new Employee and click Remove...
Employee disappears from GUI and...
12:09:56 -[Employee didTurnIntoFault]

Click Edit  Undo.  Employee reappears in GUI, but...
Nothing logged

You see, there is no -awakeFromAnything when it reappears and, we  
presume, faulted back in as you say.  Further, had I had added an  
observer in -awakeFromInsert and removed an observer in - 
didTurnIntoFault, although I now have an Employee alive in the GUI the  
number of its observers is  +1 +1 -1 -1 = 0.  No good!


I then performed another test, saving, closing and re-opening the  
document to see how it worked with a fetch.  The document closed OK,  
again with +1+1-1-1=0 observers, and executed an -awakeFromFetch upon  
reopening.  So far, so good.  One Employee, one observer.  Then I  
deleted the Employee, but I did not get -didTurnIntoFault.  Then I  
undoed to bring it back, and again no -awakeFromFetch, but this is  
because for some implementation-dependent reason it did not fault when  
I deleted it.


Dave's earlier comment on this contains some assumptions that are  
suspect. I don't know of any guarantee that deleting an object  
causes the object to first be faulted out and/or to receive a  
'didTurnIntoFault' message, but perhaps it's so, or perhaps it's a  
current implementation detail that can't be relied on in the future.


Agreed.  As I have just shown, faulting occurs with a newly-inserted  
object but not one that was fetched from the persistent store.


Further, I wouldn't expect 'awakeFromFetch' to be called as a result  
of undo. I might expect 'awakeFromInsert' to be called as a result  
of undoing a deletion, but, given Core Data undo's overall  
inscrutability, it's possible that it just restores the previous MOC  
state directly,


Indeed, that is what I see.


without invoking the various supporting notification methods.


Well, from prior experience I'm pretty sure that, for example,  
NSManagedObjectContextObjectsDidChangeNotification is invoked.


(Undo does, for example, restore the values of transient properties,  
so *that* reason for needing some kind of 'awakeFrom...' is obviated.)


Yes, so that explains your paradox you raised initially.

So, my conclusion is that Dave is correct and that my Class Observers  
idea is no good because performing Delete and Undo causes an object to  
lose its observer and not get it back.


Jerry


[1]  Replace the -awakeFromInsert at Employee.m:35 with this code:

- (void)awakeFromInsert
{
NSLog(@%s, __PRETTY_FUNCTION__) ;
static int tempID = 1;
[self setValue:[NSNumber numberWithInt:tempID++]
forKey:@employeeID];
}

- (void)awakeFromFetch
{
NSLog(@%s, __PRETTY_FUNCTION__) ;
[super awakeFromFetch] ;
}

- (void)didTurnIntoFault
{
NSLog(@%s, __PRETTY_FUNCTION__) ;
[super didTurnIntoFault] ;
}

___

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 Support for Mail

2009-02-25 Thread Damien Cooke

All,
I need to send email from my app.  I have chosen EDMessage and added  
the frameworks to my project but it fails with error 5 can not find  
the EDCommon image.  So I am told this is because the frameworks are  
designed to be embedded within the project.


This is what I need some help with.  I checked the apple docs (http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html#/ 
/apple_ref/doc/uid/20002258-SW1)  This was not particularly useful to  
me as I tried in turn all of the ways to achieve what I want from the  
docs but I am unable to drag from one project the product to my  
target's Link Binary With Libraries.  I am sure it is almost  
impossible to assist me unless someone out there has had a similar  
issue and if that is the case can you please let me know what you did  
to fix it?


Regards
Damien

On 08/01/2009, at 9:49 AM, Torsten Curdt wrote:

EDMessage had fallen into disrepair and would not build when I  
looked at it
last year. I updated the source and merged in SSL and  
authentication from
OPMessageServices, and turned it over to the original EDMessage  
team. The

updated source is now on the web at:

http://www.mulle-kybernetik.com/software/EDFrameworks/

You need both EDMessage and EDCommon. The EDMessage framework has  
an example

app included. Both frameworks build 4-way Universal.


Are my patches included now? :)

I had some problems building it for 10.4. You find a 10.4/10.5  
version at


http://github.com/tcurdt/edmessage/tree/master

...following the svn trunk via git-svn

I have successfully used these frameworks to send mail to both  
gmail and

.mac as well as other ISPs.


Same here!

A while ago I compared the frameworks and ended up using Pantomime.

http://vafer.org/blog/20080604120118

But I ended up having quite some trouble with it. So far the updated
EdMessage seems quite reliable. *knock on wood* My new first choice.

cheers
--
Torsten
___

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/damien.cooke%40internode.on.net

This email sent to damien.co...@internode.on.net


We act as though comfort and luxury were the chief requirements of  
life, when all that we need to make us happy is something to be  
enthusiastic about.


-- Albert Einstein




___

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: Running Cocoa applications from file servers

2009-02-25 Thread I. Savant
On Wed, Feb 25, 2009 at 2:41 PM, Michael Ash michael@gmail.com wrote:

 Note that there's no need to add the qualifier most complicated
 here. *All* applications load resources lazily, simply because OS X
 uses memory-mapped executables.

  I thought I remembered reading this, but I couldn't remember and was
too lazy to look it up, so I didn't comment on this. :-)

  So, assuming Quincey's point is valid but outside the influence of
the Cocoa app, in answer to Erik's post, we have two reasons:

1 - Resource loading.
2 - Memory-mapped executables.

  Both of these affects are avoidable if the executable is *really
small* and loads all resources at once. :-)

--
I.S.
___

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: NSTableView Cell edit values.

2009-02-25 Thread Corbin Dunn


On Feb 25, 2009, at 12:14 PM, Totte Alm wrote:


Hello,

25 feb 2009 kl. 19.58 skrev Corbin Dunn:

Make the field editor resign first responder status; if it did  
successfully do that, then the change was committed. If not, a  
validation error happened. IE:


[self.window makeFirstResponder:tableView];



I might be doing this part wrong

This is the Action method involved

// --
// doFlaggning
// --
- (IBAction) doFlaggning:(id)sender
{

// Fix focus
[mWindow makeFirstResponder:mNameList];

	[NSTimer scheduledTimerWithTimeInterval:kTestTime target:self  
selector:@selector(realDoFlagging:) userInfo:nil repeats:NO];

}

The result is this from my logs.

2009-02-25 20:14:25.266 ABolag-III[52341:813] realDoFLagging
2009-02-25 20:14:25.433 ABolag-III[52341:813] setObjectValue called


I'd suggest debugging in Xcode and figuring out what the bt is when  
your setObjectValue is called, and what is making that happen. It  
should be the resigning of the first responder for the field editor.


corbin
___

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


IKFilterUIView binding?

2009-02-25 Thread Albert Martin
I am having trouble getting an IKFilterUIView to bind to it's  
CIFilter.  I don't get any compile or runtime errors, but when I'm  
editing the settings in the IKFilterUIView it doesn't update the  
CIFilter settings that are being applied to a CALayer.  Here's the  
code ... what am I doing wrong?


// setting up the CIFilter
filterContainer_Bloom = [CIFilter filterWithName:@CIBloom];
[filterContainer_Bloom setDefaults];

// setting up the IKFilterUIView
filterSettings_Bloom = [filterContainer_Bloom viewForUIConfiguration: 
[self createOptionsDictionary] excludedKeys:[NSArray  
arrayWithObject:@inputImage]];

[filterSettingsContainerView addSubview: filterSettings_Bloom];

// binding the IKFilterUIView to the CIFilter
[filterContainer_Bloom bind:@inputRadius toObject: 
[filterSettings_Bloom filter] withKeyPath:@inputRadius options:nil];


// adding the CIFilter to the CALayer filter array
[effectsArray addObject: filterContainer_Bloom];
___

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: NSTableView Cell edit values.

2009-02-25 Thread Totte Alm


25 feb 2009 kl. 22.29 skrev Corbin Dunn:



On Feb 25, 2009, at 12:14 PM, Totte Alm wrote:


Hello,

25 feb 2009 kl. 19.58 skrev Corbin Dunn:

Make the field editor resign first responder status; if it did  
successfully do that, then the change was committed. If not, a  
validation error happened. IE:


[self.window makeFirstResponder:tableView];



I might be doing this part wrong

This is the Action method involved

// --
// doFlaggning
// --
- (IBAction) doFlaggning:(id)sender
{

// Fix focus
[mWindow makeFirstResponder:mNameList];

	[NSTimer scheduledTimerWithTimeInterval:kTestTime target:self  
selector:@selector(realDoFlagging:) userInfo:nil repeats:NO];

}

The result is this from my logs.

2009-02-25 20:14:25.266 ABolag-III[52341:813] realDoFlagging
2009-02-25 20:14:25.433 ABolag-III[52341:813] setObjectValue called


I'd suggest debugging in Xcode and figuring out what the bt is when  
your setObjectValue is called, and what is making that happen. It  
should be the resigning of the first responder for the field editor.


I found it, and it did work, when I use the correct NSWindow object  *  
blush! *.

Thanks again!


// Totte



corbin


---
Black holes are where God divided by zero.
- Steven Wright

___

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


makeKeyAndOrderFront Crashing

2009-02-25 Thread Walker Argendeli
My app has a toolbar, and I recently added a panel.  Then, I put a new  
button in the toolbar, and set its action makeKeyAndOrderFront: on the  
new panel.  Problem is, the moment I make this connection, the app  
goes haywire.  When I launch the app, both main window and new panel  
appear.  If I try to customize the toolbar (by opening the customize  
dropdown) everything works fine, until I close the new panel and try  
and customize again.  Then, the debugger launches.  I'm not sure why  
this causes the app to crash, but it does.  Anyone have ideas?


- Walker Argendeli

___

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


gui development without using xcode or interface builder

2009-02-25 Thread nukala seetaiah baba

Needed suggestions: how to develop gui application using cocoa frameworks and 
objective- c without using interface builder or xcode tools. thanks in advance 
_
For the freshest Indian Jobs Visit MSN Jobs
http://www.in.msn.com/jobs___

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


Select tablecell on creation through arrayController

2009-02-25 Thread Walker Argendeli
I have a table with one column, that's bound to an array controller.   
It calls add: on the array controller when I hit a plus button.   
Problem is, I want the textFieldCell to be selected on creation.  I  
rewired the plus button to call a method in a custom class.  The first  
thing the custom class does is call the array controller's add  
method.  This works fine.  Then, I had some custom code based off code  
I used in old (non-bindings) apps.  It doesn't work though, console  
logs *** -[NSCFArray objectAtIndex:]: index (1) beyond bounds (1)
Anyone understand what's going one, or have any code that would make  
it work?


[notebookController add:sender];
[tableView editColumn:1 row:[tableView selectedRow] withEvent:nil  
select:YES];


Thanks,
- Walker Argendeli

___

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: gui development without using xcode or interface builder

2009-02-25 Thread Nick Zitzmann


On Feb 24, 2009, at 10:40 PM, nukala seetaiah baba wrote:

Needed suggestions: how to develop gui application using cocoa  
frameworks and objective- c without using interface builder or xcode  
tools.



You must be a Windows switcher. Welcome!

I strongly recommend you do not fight the tools, unless you have a  
**really** good reason to do otherwise. Just stick to IB and the Xcode  
build system. If you do have a really good reason, then what is your  
reason?


Nick Zitzmann
http://www.chronosnet.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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Jerry Krinock
Well, now that I've convinced myself that  
NSManagedObjectContextObjectsDidChangeNotification does not give  
enough information, and that there is no way to reliably maintain a  
KVO observer of a managed object, I was going to bite the bullet and  
implement custom setters for all the properties I want to observe,  
slipping in the posting of a notification, like this:


- (void)setFoo:(NSWhatever*)value
{
[self willChangeValueForKey:@foo];
[self setPrimitiveFoo:value];
[self didChangeValueForKey:@foo];

NSDictionary* userInfo = [NSDictionary  
dictionaryWithObjectsAndKeys:

  value, @NewValue,
  @foo, @key,
  nil] ;
[[NSNotificationCenter defaultCenter]  
postNotificationName:@ModelHit

object:self
   
userInfo:userInfo] ;


}

For attributes, I believe it is guaranteed that any proper KVO- 
compliant change to a Foo will use this accessor and thus my  
notification will be posted whenever an attribute value changes.


But what about to-many relationships?  Think DepartmentAndEmployees.   
Imagine I have a OrgChart object.  My OrgChart wants to receive a  
notification, observation, or SOMETHING when the directReports of any  
Employee is changed.


How can I get this?  According to the documentation, a to-many  
relationship is ordinarily modified by mutating the mutable set  
proxy.  So there is no always-invoked accessor to override.


Certainly there must be a solution to this very basic problem.  What  
is it?


Thanks,

Jerry Krinock 
 
___


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 NSTableView Cell edit values.

2009-02-25 Thread Peter Hudson

Have you tried calling  abortEditing  on the table view.
I can't remember if it causes a write or not - but in the context  
where I previously used it I would have needed it to.


PH
___

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: -[_NSControllerObjectProxy entity]: unrecognized selector sent to instance

2009-02-25 Thread Daniel Child
Regarding the first issue (proxy object), will read the docs on  
NSProxy and all that that leads to.


Regarding the second issue (copyWithZone), I had bound the content of  
an array controller to a relationship based on the selection in  
another controller, but bindings for the value portion of the  
corresponding view was missing the model key. A million thanks for  
pointing this out.


On Feb 25, 2009, at 3:05 PM, Kyle Sluder wrote:

On Wed, Feb 25, 2009 at 2:43 PM, Daniel Child wch...@hawaii.edu  
wrote:

The object I'm adding was obtained by using
NSManagedObject *theWord = [wordList selection]
This yields a proxy object instead of an MO. (Does anyone know why?)


Read the documentation for -[NSObjectController selection].  It's
right there in black and white: A proxy object representing the
receiver’s selection. This object is fully key-value coding compliant,
but note that it is a proxy and so does not provide the full range of
functionality that might be available in the source object.

-[NSManagedObject copyWithZone:]: unrecognized selector sent to  
instance

0x1adf50


Typically this happens when you've bound a view to the selectedObjects
of a controller and not provided a keypath.  Often times views copy
their object values, but NSManagedObjectContext does not support
NSCopying.  Make sure that all your bindings are to keypaths, not just
to the objects themselves.

--Kyle Sluder


___

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


NSTableView Custom Background ...

2009-02-25 Thread Mic Pringle
Hi,

I've a subclass of NSTableView that draws a custom gradient
background. What I'd like to do now is to draw a slightly different
background when the window containing the custom NSTableView loses
focus.

Is this possible ?

If so, could someone please point me in the right direction ?

I know that in the NSTableView subclass you can use [self window] to
get the containing window, so I have tried things like [[self window]
isKeyWindow] and [[self window] isMainWindow] but this doesn't seem to
get me anywhere.

Any help will be greatly appreciated.

Thanks

-Mic
___

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: -[_NSControllerObjectProxy entity]: unrecognized selector sent to instance

2009-02-25 Thread Kyle Sluder
On Wed, Feb 25, 2009 at 3:05 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 Typically this happens when you've bound a view to the selectedObjects
 of a controller and not provided a keypath.  Often times views copy
 their object values, but NSManagedObjectContext does not support
 NSCopying.  Make sure that all your bindings are to keypaths, not just
 to the objects themselves.

And of course I meant NSManagedObject, not NSManagedObjectContext.

--Kyle Sluder
___

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


Simple text encryption

2009-02-25 Thread Erg Consultant
Are there any classes in Cocoa for simple text file or plist file encryption? I 
just need something I can point at a file on disk and do simple encryption 
without a password or key and then decode it later. Doesn't have to be fancy or 
even all that secure - just something simple and easy to use.

Thanks,

Erg



  
___

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: NSTableView Custom Background ...

2009-02-25 Thread Nick Zitzmann


On Feb 25, 2009, at 3:58 PM, Mic Pringle wrote:


I've a subclass of NSTableView that draws a custom gradient
background. What I'd like to do now is to draw a slightly different
background when the window containing the custom NSTableView loses
focus.

Is this possible ?

If so, could someone please point me in the right direction ?



You can start on this by listening to the NSWindow notifications that  
are posted when the window acquires or resigns main window status.


Nick Zitzmann
http://www.chronosnet.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: Select tablecell on creation through arrayController

2009-02-25 Thread Kyle Sluder
On Wed, Feb 25, 2009 at 5:11 PM, Walker Argendeli
heckler0...@bellsouth.net wrote:
 I have a table with one column

[...snip...]

 [tableView editColumn:1 row:[tableView selectedRow] withEvent:nil
 select:YES];

You are aware that arrays are 0-indexed, right?

--Kyle Sluder
___

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: NSTableView Custom Background ...

2009-02-25 Thread Corbin Dunn


On Feb 25, 2009, at 2:58 PM, Mic Pringle wrote:


Hi,

I've a subclass of NSTableView that draws a custom gradient
background. What I'd like to do now is to draw a slightly different
background when the window containing the custom NSTableView loses
focus.

Is this possible ?

If so, could someone please point me in the right direction ?

I know that in the NSTableView subclass you can use [self window] to
get the containing window, so I have tried things like [[self window]
isKeyWindow] and [[self window] isMainWindow] but this doesn't seem to
get me anywhere.


In addition to what Nick said, you probably aren't invalidating the  
tableview when the window looses/gains key status.


What you want to do does work, and is possible; the  
NSTableViewSourceListHighlightStyle does this automatically.


corbin


___

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: Select tablecell on creation through arrayController

2009-02-25 Thread Corbin Dunn


On Feb 25, 2009, at 2:11 PM, Walker Argendeli wrote:

I have a table with one column, that's bound to an array  
controller.  It calls add: on the array controller when I hit a plus  
button.  Problem is, I want the textFieldCell to be selected on  
creation.  I rewired the plus button to call a method in a custom  
class.  The first thing the custom class does is call the array  
controller's add method.  This works fine.  Then, I had some custom  
code based off code I used in old (non-bindings) apps.  It doesn't  
work though, console logs *** -[NSCFArray objectAtIndex:]: index (1)  
beyond bounds (1)
Anyone understand what's going one, or have any code that would make  
it work?


Anytime you have an exception raised you can generally find an easy  
answer by using breakpoints.


http://www.corbinstreehouse.com/blog/index.php/2008/08/your-most-important-breakpoint-in-cocoa/

corbin



___

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: Simple text encryption

2009-02-25 Thread Nick Zitzmann


On Feb 25, 2009, at 4:03 PM, Erg Consultant wrote:

Are there any classes in Cocoa for simple text file or plist file  
encryption?



http://www.lmgtfy.com/?q=Cocoa+encryption

Nick Zitzmann
http://www.chronosnet.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: Simple text encryption

2009-02-25 Thread Graham Cox


On 26/02/2009, at 10:03 AM, Erg Consultant wrote:

Are there any classes in Cocoa for simple text file or plist file  
encryption? I just need something I can point at a file on disk and  
do simple encryption without a password or key and then decode it  
later. Doesn't have to be fancy or even all that secure - just  
something simple and easy to use.



You could use the openssl library, which is very easy to use. For  
simple symmetric encryption it supports e.g. RC4 which will do what  
you want. You can just make up a random key.


Unlike other frameworks, you just link to it by setting the -lcrypto  
flag in the other linker flags in your target's build settings and  
then #include openssl/openssl.h in your code.


--Graham


___

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: gui development without using xcode or interface builder

2009-02-25 Thread I. Savant

On Feb 25, 2009, at 5:15 PM, Nick Zitzmann wrote:

I strongly recommend you do not fight the tools, unless you have a  
**really** good reason to do otherwise. Just stick to IB and the  
Xcode build system. If you do have a really good reason, then what  
is your reason?


  Agreed. That said, you can always build your UI in code at runtime,  
and use the command-line tools to build / link / etc.


--
I.S.




___

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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Dave Fernandes


On Feb 25, 2009, at 2:24 PM, Quincey Morris wrote:


On Feb 25, 2009, at 05:31, Jerry Krinock wrote:


On 2009 Feb 24, at 20:02, Dave Fernandes wrote:

... I'm only just getting familiar with the idiosyncrasies of  
Leopard, however, in Tiger didTurnIntoFault might be called many  
times, but awakeFromInsert or awakeFromFetch was only called once  
for the lifetime of the MOC (not the lifetime of the object).  
Thus, if you delete the object, and then undo that action, your  
observers will be removed by didTurnIntoFault and not added back  
since awakeFromFetch is not called again.



Dave's earlier comment on this contains some assumptions that are  
suspect. I don't know of any guarantee that deleting an object  
causes the object to first be faulted out and/or to receive a  
'didTurnIntoFault' message, but perhaps it's so, or perhaps it's a  
current implementation detail that can't be relied on in the future.


I haven't seen this documented either, so I assumed it might be  
implementation dependent. That is why I restricted my comment to the  
version of the OS that I have tested on. It is quite possible that  
others will observe different outcomes. I can only describe what I  
have seen in my app.


Further, I wouldn't expect 'awakeFromFetch' to be called as a  
result of undo. I might expect 'awakeFromInsert' to be called as a  
result of undoing a deletion, but, given Core Data undo's overall  
inscrutability, it's possible that it just restores the previous  
MOC state directly, without invoking the various supporting  
notification methods. (Undo does, for example, restore the values  
of transient properties, so *that* reason for needing some kind of  
'awakeFrom...' is obviated.)





___

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: Metrics for a NSTextField

2009-02-25 Thread Martin Wierschin
I'm not really familiar with the particulars of how the field editor  
is configured, so take all this with a grain of salt...


The usedRect empty. I believe the reason why is because the  
fieldEditor that the window has given me has a zero width.


Sizing the editor may not be the window's responsibility- it may  
expect the control to do so. What happens if you resize the  
NSTextView and/or NSTextContainer yourself as needed? In fact, you  
might have to call additional methods before it is properly usable,  
eg: setUpFieldEditorAttributes:


If anyone has a suggestion on how to better accomplish this task, I  
am interested.


What about just calling sizeToFit on your NSTextField and then  
drawing the border around the full frame?


~Martin

___

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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Dave Fernandes


On Feb 25, 2009, at 3:51 PM, Jerry Krinock wrote:



Dave's earlier comment on this contains some assumptions that are  
suspect. I don't know of any guarantee that deleting an object  
causes the object to first be faulted out and/or to receive a  
'didTurnIntoFault' message, but perhaps it's so, or perhaps it's a  
current implementation detail that can't be relied on in the future.


Agreed.  As I have just shown, faulting occurs with a newly- 
inserted object but not one that was fetched from the persistent  
store.


Yes, the one fetched from the persistent store may still be a fault  
if you have not tried to access any attributes yet.


Dave
___

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


NSScrollView's content view doesn't un-hide

2009-02-25 Thread Scott Hamilton
1. I have an NSScrollView created in IB which contains a custom view  
and only a vertical scroller.


2. I programmatically add subviews to the custom view's clip view  
with a block of code. The scroll view is displayed, the subviews all  
work, life is good.


3. Next, under appropriate conditions, I hide the scroll view and  
create other controls over the top of the hidden scroll view.


4. Next, under further appropriate conditions, I remove the added  
controls and recreate the scroll view with subviews with the same  
block of code in 2 above.


5. The scroll view with its vertical scroller REAPPEARS but without  
displaying the custom view and clip view containing the subviews. If  
I just click anywhere on the scroll bar, or the scroller trough, poof  
- the controls in the custom view reappear instantly.


I've tried all the mechanisms of setNeedsDisplay, displayIf...,  
setInitialFirstResponder, etc., etc. all the way from the clip view  
up through the window's content view and window but that scroll view  
content just won't reappear. It's as if the [myScrollView  
setHidden:YES] has disconnected the content view from the responder  
chain and then somehow gets reattached and displayed when clicking on  
the scroller knob but isn't when rebuilding the content view  
programmatically.


Am I missing something?

Thanks in advance...

Scott Hamilton


___

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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Jerry Krinock


On 2009 Feb 25, at 16:19, Dave Fernandes wrote:

Yes, the one fetched from the persistent store may still be a fault  
if you have not tried to access any attributes yet.


Further testing shows that it does become a fault if I change an  
attribute and then delete the Employee.  That's ^changing^ an  
attribute.  But certainly the firstName, lastName and salary were  
^accessed^ before that, because they show in the UI as soon as I open  
the document.


But let me get to the more important question, Dave.  You said in your  
first post that you are using KVO, yet you were the one who discovered  
that a managed object's observer goes away when you delete and then  
undo the delete.  Do you have a solution for this problem, or are you  
just living with it?


___

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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Dave Fernandes


On Feb 25, 2009, at 8:31 AM, Jerry Krinock wrote:

So, it looks like, for observing changes to the properties of  
managed objects ---


*  Using NSManagedObjectContextObjectsDidChangeNotification is no good
 since it doesn't give you specific information on the current  
change

 which actually caused the notification.

*  Using KVO is no good because observers must be removed before an
 object becomes a fault, and there is no mechanism to find out
 when the object un-becomes a fault, which you need to restore
 your observers.

So, my conclusion is that writing Custom Setters for any properties  
that need to be observed and posting a  notification (coalesced,  
for efficiency) within the custom setter is the only viable technique.


Does anyone have any better ideas?

Jerry


Well, as I mentioned I have stuck with KVO. I don't see why you need  
to remove observers when turning into a fault. You only need to  
remove observers before the object disappears. I have created my own  
NSManagedObject subclass as you have, and I have a
-removeSelfFromObserveredObjects method in that subclass that I call  
before deallocating the MOC. (Fetch all objects from MOC and call  
this method, if it exists.) ...it's not pretty, but it works.


Note that a fetch will not return deleted objects that might still be  
on the undo stack, so I also call removeSelfFromObserveredObjects  
from the managed object's dealloc method. (You will have to check  
that you do not call removeSelfFromObserveredObjects twice.) As I  
said, it's not pretty, but it works.


If anyone has a better way, I'd love to hear it!

Dave
___

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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Quincey Morris

On Feb 25, 2009, at 14:16, Jerry Krinock wrote:

How can I get this?  According to the documentation, a to-many  
relationship is ordinarily modified by mutating the mutable set  
proxy.  So there is no always-invoked accessor to override.


Implement the set-mutation accessor methods in your NSManagedObject  
subclass:


	http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/ 
/apple_ref/doc/uid/20002174-178830-BAJEDEFB


and scroll down to the Mutable Unordered Accessors subheading.  
Modifying the object via the mutable set proxy calls these methods  
(and Core Data has built-in implementations of them that you'll be  
overriding by writing your own:


	http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html#/ 
/apple_ref/doc/uid/TP40002154-SW9


).


___

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


renaming a file with special/reserved characters in name

2009-02-25 Thread Martin Wierschin

Hello everyone,

Forgive me if this has already been answered, but my searches through  
the archive didn't turn up anything.


The situation is that I need to allow users to rename files within my  
application. The name of the file is displayed in an NSTableView, and  
the delegate method tableView:setObjectValue:etc triggers the  
underlying file to be renamed.


A problem arises when a file contains special/reserved characters,  
eg: the dreaded backslash/colon. There's the handy -[NSFileManager  
displayNameAtPath:] which seems to convert colons in paths to  
backslashes for display, but no inverse. How am I to convert whatever  
name the user has entered to a form suitable for use with  
stringByAppendingPathComponent:?


Likewise, what about validation? I don't believe a user can use a  
colon : on an HFS file system (at least my Finder doesn't allow  
it). I would expect a method on NSFileManager like  
pathNameForDisplayName: that returns nil if the name is illegal on  
the underlying file system. I hate to hardcode any of these characters.


Thanks for any help,

~Martin

___

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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Jerry Krinock


On 2009 Feb 25, at 16:39, Dave Fernandes wrote:

Well, as I mentioned I have stuck with KVO. I don't see why you need  
to remove observers when turning into a fault. You only need to  
remove observers before the object disappears.


Ah, good point.  I was using -didTurnIntoFault since -[NSManagedObject  
dealloc] is unreliable and not recommended for overriding.


I have created my own NSManagedObject subclass as you have, and I  
have a
-removeSelfFromObserveredObjects method in that subclass that I call  
before deallocating the MOC. (Fetch all objects from MOC and call  
this method, if it exists.) ...it's not pretty, but it works.


Note that a fetch will not return deleted objects that might still  
be on the undo stack, so I also call removeSelfFromObserveredObjects  
from the managed object's dealloc method.


Oooo, dealloc is not recommended for overriding.

(You will have to check that you do not call  
removeSelfFromObserveredObjects twice.) As I said, it's not pretty,  
but it works.


Wow, that ^is^ ugly.  I'll think about it.


If anyone has a better way, I'd love to hear it!


Ditto from me.

Thanks, Dave.
___

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


NSURL behaviour at odds with documentation

2009-02-25 Thread tmowlem
Hello,



I am using NSURL to create a URL for an application using Webkit. It the 
documentation for NSURL at:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html




I am specifically calling [NSURL URLWithString].




It states The NSURL class will fail to create a new NSURL object if the path 
being passed is not well-formed—the path must comply with RFC 2396.

According to that RFC an absolute URI should be scheme : hierarchical part.




But when I test this I can create an NSURL with htp/www.ibm.com which has a 
missing colon separator. This looks incorrect.

However surely this class is used very widely by many people so if it was 
incorrect someone would
  have noticed before me.




Any feedback about whether this should be considered incorrect and whether a 
bug should be raised would be appreciated.




Thanks,




Tim









___

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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Dave Fernandes


On Feb 25, 2009, at 7:52 PM, Jerry Krinock wrote:



Note that a fetch will not return deleted objects that might still  
be on the undo stack, so I also call  
removeSelfFromObserveredObjects from the managed object's dealloc  
method.


Oooo, dealloc is not recommended for overriding.





I think that's only because it is not guaranteed to be called.

-d
___

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: Core Data Relationships

2009-02-25 Thread Walker Argendeli
With an NSPopUpButton, you can bind content to Kind.arrangedObjects,  
content values to Kind.arrangedObjects.title, and selected object to  
Item.kind.  I want the functionality of an NSComboBox, however, which  
only has content and content values.  There's no selected object.   
What could I bind to to get this working?


Thanks,
- Walker Argendeli

On Feb 24, 2009, at 7:52 PM, Walker Argendeli wrote:


I apologize beforehand for the beginner-level of this question.
I'm getting started with core data, and I've gone through several  
tutorials.
Let's say I have 2 entities: an Item, and a Kind.  Each Item has 1  
Kind, and each Kind has multiple Items.  The Item might have an  
attribute, Title, and a relationship to Kind, and Kind might have an  
attribute, Title, and a To-Many relationship to Item (inverse).
It seems that in all the examples, a NSPopUpButton is used, with  
Content, Content Values, and Selected Object being bindings.
What if I wanted to have say, an NSTextCell where you could enter a  
Kind.  I haven't decided whether you would be forced to enter a kind  
that is already in the Kinds array, or could just type anything.

Anyways, what bindings would I want to use to accomplish this.
Thanks,

- Walker Argendeli



___

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: makeKeyAndOrderFront Crashing

2009-02-25 Thread Walker Argendeli
I've now isolated it to the makeKeyAndOrderFront: method.  I tried  
just a regular button with that class, but the moment I click it, up  
opens the debugger.  The toolbar part isn't really an issue.  I'm not  
really sure what to do from this point, because I can't tell why the  
method isn't working.


- Walker Argendeli

On Feb 25, 2009, at 5:04 PM, Walker Argendeli wrote:

My app has a toolbar, and I recently added a panel.  Then, I put a  
new button in the toolbar, and set its action makeKeyAndOrderFront:  
on the new panel.  Problem is, the moment I make this connection,  
the app goes haywire.  When I launch the app, both main window and  
new panel appear.  If I try to customize the toolbar (by opening the  
customize dropdown) everything works fine, until I close the new  
panel and try and customize again.  Then, the debugger launches.   
I'm not sure why this causes the app to crash, but it does.  Anyone  
have ideas?


- Walker Argendeli



___

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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Ben Trumbull

Well, that was easy to test and indeed I found that you found a bug in
my idea.  The only way to fix it would be if we Apple had given us a -
didUnturnIntoFault method, but they did not.

So, it looks like, for observing changes to the properties of managed
objects ---

*  Using NSManagedObjectContextObjectsDidChangeNotification is no good
 since it doesn't give you specific information on the current
change
 which actually caused the notification.

*  Using KVO is no good because observers must be removed before an
 object becomes a fault, and there is no mechanism to find out
 when the object un-becomes a fault, which you need to restore
 your observers.


bug numbers ?  'cause if it's not important enough for you to even  
file an ER, it's unlikely to be as important as the bazillion other  
things we have to do, as far as the eye can see...


- Ben

___

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: do i need to create autorelease pool?

2009-02-25 Thread Peter N Lewis

At 11:44 -0500 25/2/09, Michael Ash wrote:
On Wed, Feb 25, 2009 at 12:00 AM, Peter N Lewis 
pe...@stairways.com.au wrote:

 The Application Kit creates an autorelease pool on the main thread at the
 beginning of every cycle of the event loop, and drains it at the end,
 thereby releasing any autoreleased objects generated while processing an
 event.


 This is assuming iPhone or Leopard, I believe the NSAutoreleasePool creation
 was required for older versions of Mac OS X.


The semantics haven't changed on Leopard as far as I know. The above
has been the case forever: pools are created and destroyed on
*events*, but not timers. If you simply run a timer forever and never
process events, your memory usage will grow without limit. A pool
exists, so you don't explicitly leak, but the pool is only drained
when an event arrives. If you're going to be running something in
timers or other non-event sources, you'll want to post a fake event to
the main event loop from time to time (or just after every action you
take) to force the pool to drain.

I have *no* idea how much of that, if any, applies to the iPhone. In
any case if you're processing events on a regular basis as well then
you don't have to worry about anything.


OK, I will certainly defer to Michael's deeper knowledge on this 
stuff, but I thought Leopard plugged most of the normal case holes 
for requiring an auto release pool, so I wrote up this test case:


#import AppDelegate.h

@interface BogusObject : NSObject {
}

@end

@implementation BogusObject

- (id) init;
{
  self = [super init];
  if (self != nil) {
NSLog( @BogusObject init );
  }
  return self;
}

- (void) dealloc;
{
  NSLog( @BogusObject dealloc );
  [super dealloc];
}

@end

@implementation AppDelegate

- (void) timerFired:(NSTimer*)theTimer;
{
  NSLog( @timerFired );
  [[[BogusObject alloc] init] autorelease];
}

- (void) applicationDidFinishLaunching:(NSNotification *)aNotification;
{
  NSLog( @applicationDidFinishLaunching );
  [NSTimer scheduledTimerWithTimeInterval:1 target:self 
selector:@selector(timerFired:) userInfo:nil repeats:YES];

}

@end


With the app sitting in the background doing nothing, I get the same 
results whether timerFired uses release or autorelease, ie every 
second all three messages are printed:


2009-02-26 10:38:43.440 CheckTimer[82997:10b] timerFired
2009-02-26 10:38:43.441 CheckTimer[82997:10b] BogusObject init
2009-02-26 10:38:43.441 CheckTimer[82997:10b] BogusObject dealloc

For good measure, I tried this on Tiger, and got the same results, so 
now I'm just left wondering where my confusion lies.

   Peter.

--
 Run macros from your iPhone with Keyboard Maestro Control!
   or take a break with Aragom Space War for your iPhone

Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac
Aragom Space War http://www.stairways.com/iphone/aragom Don't get killed!
http://www.stairways.com/   http://download.stairways.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: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Jerry Krinock


On 2009 Feb 25, at 17:11, Ben Trumbull wrote:


bug numbers ?


Ben, I will definitely file bug(s) after I get this sorted out.  But  
in the interim...


The problem is easily stated in terms of DepartmentAndEmployees.  I  
have views which want to know when various object properties change.   
For one example, say I want to add an OrgChart object.  My OrgChart  
wants to receive a notification or observation when the directReports  
of any Employee is changed.


There appear to be solutions to this problem and both are surprisingly  
complicated.


Solution 1.  Use KVO.  Although adding observers is systematic  
(awakeFromInsert + awakeFromFetch), removing observers must be done  
(1) when deallocating the moc and (2) in the managed object's -dealloc  
method (which is not recommended for subclassing).  The latter is to  
catch objects still on the undo stack or elsewhere.


Solution 2.  Use Custom Setters.  In each setter, post a  
notification.  This is not too bad with attributes -- only one setter  
per attribute.  But for to-many relations you need to override the  
four, or is it five, set mutator methods, and what if more are added  
in some future version of Mac OS?  This requires much code and seems  
fragile.


Which solution, or a different one, looks better to you?

Thank you,

Jerry
___

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


One IBAction, multiple results from multiple methods

2009-02-25 Thread Walker Argendeli
Lets say I have some custom code that does the same thing, with the  
exception that a few IBOutlets are different for each type.  Instead  
of having multiple methods, is there a way to use 1 IBAction, and take  
necessary action depending on where it was sent?

I originally used code like this:
- (IBAction)barDoSomething:(id)sender
{...}
- (IBAction)fooDoSomething:(id)sender
{...}
I didn't want a plethora of functions though, so I used code like  
this, with the object id's coming from IB:

- (IBAction)doSomething:(id)sender
{
if ([sender objectID] == 192])
[foo doSomething];
else if ([sender objectID == 236])
[bar doSomething];
}
There were two problems with this, though.  One, there was a lot of  
repeated code, even without the repeated methods, and 2, it didn't  
work. (anybody know why? I NSLogged the objectID's and they loged  
objectID to the console- no number)
What I'd really like is one method that uses the appropriate bar or  
foo (NSTableViews), and sends to the appropriate array controller, all  
depending on which button sent the message.  I'd have one piece of  
code, like this:

- (IBAction)doSomething
{
[correctClass doSomething];
}
And appropriate methods/controllers/tableviews/etc. would be used.   
Any techniques that could be used for this?  Maybe using sender?  I'm  
open to Obj-C++ if that's needed, just trying to find a working  
solution.  Also, what would be Obj-C convention for situations like  
this, if there is no solution, or if I was doing it the traditional  
way (code snippet 1?)


To summarize:
- What's the traditional way of handling a situation like this?
- Why aren't the objectID's working?
- What solutions are there?

Thanks,
- Walker Argendeli

___

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: One IBAction, multiple results from multiple methods

2009-02-25 Thread I. Savant

On Feb 25, 2009, at 9:36 PM, Walker Argendeli wrote:

Lets say I have some custom code that does the same thing, with the  
exception that a few IBOutlets are different for each type.  Instead  
of having multiple methods, is there a way to use 1 IBAction, and  
take necessary action depending on where it was sent?


  If I read your post correctly, you want one action, called by  
various controls, and you want to do different thing depending on the  
sender, right?


  For this, we use tags (on the controls). Let's use a concrete  
example: a media player. You might have a -seek: action method. You  
might have four buttons (seek back, seek back FAST, seek forward, seek  
forward FAST). Depending on the sending button, you need your media  
controller to do the right thing.


- (IBAction)seek:(id)sender
{
  int tag = [sender tag];  // or NSInteger tag = [sender tag];
  switch (case)
  {
case 1001: // seek back
[self seekBack];
break;

case 1002: // seek back FAST
[self seekBackFast];
break;

case 1003: // seek forward
[self seekForward];
break;

case 1004: // seek forward FAST
[self seekForwardFast];
break;

default:
NSBeep(); // don't know what to do here ...
break;

  }
}

  Don't forget to set the tags in IB for your controls.

--
I.S.



___

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: Select tablecell on creation through arrayController

2009-02-25 Thread Walker Argendeli

The code is now this, which works- kindof:

[notebookController add:sender];
[notebookTableView editColumn:0 row:[notebookTableView selectedRow]  
withEvent:nil select:YES];


Only problem is, for the second line, I actually have to kick off a  
timer...:

[NSTimer scheduledTimerWithTimeInterval:.01
 target:self
   selector:@selector(beginTextFieldCellEdit)
   userInfo:nil
repeats:NO];
...that calls the second line from the first snippet in  
beginTextFieldCellEdit.

Anybody know what's going on here?

- Walker Argendeli

On Feb 25, 2009, at 5:11 PM, Walker Argendeli wrote:

I have a table with one column, that's bound to an array  
controller.  It calls add: on the array controller when I hit a plus  
button.  Problem is, I want the textFieldCell to be selected on  
creation.  I rewired the plus button to call a method in a custom  
class.  The first thing the custom class does is call the array  
controller's add method.  This works fine.  Then, I had some custom  
code based off code I used in old (non-bindings) apps.  It doesn't  
work though, console logs *** -[NSCFArray objectAtIndex:]: index (1)  
beyond bounds (1)
Anyone understand what's going one, or have any code that would make  
it work?


[notebookController add:sender];
[tableView editColumn:1 row:[tableView selectedRow] withEvent:nil  
select:YES];


Thanks,
- Walker Argendeli



___

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: One IBAction, multiple results from multiple methods

2009-02-25 Thread Graham Cox


On 26/02/2009, at 1:36 PM, Walker Argendeli wrote:

I didn't want a plethora of functions though, so I used code like  
this, with the object id's coming from IB:



I don't think Object IDs assigned by IB are accessible to your code.  
Same for the names used in IB to label things.


Most controls and UI items support a tag which is a simple integer  
value that can be used for this purpose.


On a general note though, I'd say this is misguided. There are a few  
times when differentiating based on tags is very useful, (like setting  
the action of a whole menu to a single method, then using the tag to  
tell which item was chosen). It makes for far more maintainable, clean  
code if every distinct action has a distinct action method. It doesn't  
matter if there are hundreds of them, at least they can be wired up  
and debugged in isolation. Furthermore, by naming them descriptively,  
wiring them up in IB takes seconds, because it's obvious which  
function goes with which control. In IB3 this is easier than it was  
because you can bring up a complete table of actions for a controller  
and wire them all at once.


Also, many action methods necessarily must make assumptions about the  
type of their sender - for example if the sender is a NSColorWell your  
action method can call [sender color] without checking for the sender  
actually implementing it because it knows it is uniquely wired to a  
NSColorWell object. A one action method for all purposes ends up  
having to rigourously check that the sender responds to all sorts of  
things, or else gets into the nasty business of testing for class  
type. That way madness lies, and the amount of code is far more than  
the amount you saved by not writing separate action method in the  
first place.


I must admit when I first started with Cocoa I tried to avoid writing  
too many action methods - it seemed like a chore. Now I've a few more  
years' experience under my belt, my controllers typically have many  
action methods, usually one per distinct control. About the only time  
more than one control funnels into the same action method is when they  
genuinely do the same job, for example a slider, textfield and stepper  
all setting the same parameter as a kind of triple input interface.


Here's an example of a typical controller in my app. I have many  
hundreds of similar classes that look much the same. In IB I don't  
have to refer to the class to know how to wire up both outlets and  
actions - the names of everything tells me all I need to know.


@interface DKOTextAdornmentController : DKORasterizerController
{
IBOutlet NSTextField*   mIdentifierTextField;
IBOutlet NSComboBox*mIdentifierComboBox;
IBOutlet NSTextField*   mLabelTextField;
IBOutlet NSButton*  mFontPanelButton;
IBOutlet NSPopUpButton* mLayoutModePopUpButton;
IBOutlet NSPopUpButton* mVerticalPositionPopUpButton;
IBOutlet NSSlider*  mVerticalPositionSlider;
IBOutlet NSSlider*  mAngleSlider;
IBOutlet NSTextField*   mAngleTextField;
IBOutlet NSStepper* mAngleStepper;
IBOutlet NSButton*  mClipToPathCheckbox;
IBOutlet NSButton*  mRelativeAngleCheckbox;
IBOutlet NSButton*  mWrapLinesCheckbox;
IBOutlet NSColorWell*   mTextColourWell;
IBOutlet NSColorWell*   mTextOutlineColourWell;
IBOutlet NSButton*  mTextOutlineEnableCheckbox;
IBOutlet NSSlider*  mTextOutlineWidthSlider;
IBOutlet NSTextField*   mTextOutlineWidthTextField;
IBOutlet NSStepper* mTextOutlineWidthStepper;
IBOutlet NSSegmentedControl*mParagraphAlignmentControl;
}

- (IBAction)identifierAction:(id) sender;
- (IBAction)labelAction:(id) sender;
- (IBAction)fontPanelButtonAction:(id) sender;
- (IBAction)layoutModeAction:(id) sender;
- (IBAction)verticalPositionModeAction:(id) sender;
- (IBAction)verticalPositionAction:(id) sender;
- (IBAction)angleAction:(id) sender;
- (IBAction)relativeAngleAction:(id) sender;
- (IBAction)wrapLinesAction:(id) sender;
- (IBAction)textColourAction:(id) sender;
- (IBAction)paragraphAlignmentAction:(id) sender;
- (IBAction)textOutlineColourAction:(id) sender;
- (IBAction)textOutlineEnableAction:(id) sender;
- (IBAction)textOutlineWidthAction:(id) sender;

// other stuff

@end

___

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:

Re: Observing Managed Object Changes. Was: Strange ... behavior

2009-02-25 Thread Ben Trumbull

On 2009 Feb 25, at 17:11, Ben Trumbull wrote:


bug numbers ?


Ben, I will definitely file bug(s) after I get this sorted out.  But
in the interim...

The problem is easily stated in terms of DepartmentAndEmployees.  I
have views which want to know when various object properties change.
For one example, say I want to add an OrgChart object.  My OrgChart
wants to receive a notification or observation when the directReports
of any Employee is changed.

There appear to be solutions to this problem and both are surprisingly
complicated.

Solution 1.  Use KVO.  Although adding observers is systematic
(awakeFromInsert + awakeFromFetch), removing observers must be done
(1) when deallocating the moc and (2) in the managed object's -dealloc
method (which is not recommended for subclassing).  The latter is to
catch objects still on the undo stack or elsewhere.

Solution 2.  Use Custom Setters.  In each setter, post a
notification.  This is not too bad with attributes -- only one setter
per attribute.  But for to-many relations you need to override the
four, or is it five, set mutator methods, and what if more are added
in some future version of Mac OS?  This requires much code and seems
fragile.

Which solution, or a different one, looks better to you?


Well, they are both pretty unappealing.  I'd probably go with a case  
by case basis, and attempt to stick to the  
NSManagedObjectContextObjectsDidChangeNotification notification as  
much as possible.  You can stash extra bread crumbs in an unmodeled  
ivar.


For your specific example of directReports in Employees and  
Departments, I'd use custom setters.  This case is more complicated  
because you want to observe the contents of a specific to-many  
relationship, not the relationship itself.  I wouldn't do that  
wholesale for all kinds of properties.


- Ben

___

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: renaming a file with special/reserved characters in name

2009-02-25 Thread Michael Ash
On Wed, Feb 25, 2009 at 7:47 PM, Martin Wierschin mar...@nisus.com wrote:
 Hello everyone,

 Forgive me if this has already been answered, but my searches through the
 archive didn't turn up anything.

 The situation is that I need to allow users to rename files within my
 application. The name of the file is displayed in an NSTableView, and the
 delegate method tableView:setObjectValue:etc triggers the underlying file
 to be renamed.

 A problem arises when a file contains special/reserved characters, eg: the
 dreaded backslash/colon. There's the handy -[NSFileManager
 displayNameAtPath:] which seems to convert colons in paths to backslashes
 for display, but no inverse. How am I to convert whatever name the user has
 entered to a form suitable for use with stringByAppendingPathComponent:?

 Likewise, what about validation? I don't believe a user can use a colon :
 on an HFS file system (at least my Finder doesn't allow it). I would expect
 a method on NSFileManager like pathNameForDisplayName: that returns nil if
 the name is illegal on the underlying file system. I hate to hardcode any of
 these characters.

There are only two characters which absolutely must be avoided in any pathname.

The first is the slash (/). Note, NOT a backslash (\), that one is
fine. Slash is the path separator and thus can't exist in a filename.

The second is the NUL character, which is unichar 0. Rarely a problem,
but it will confuse the API if you have it in your strings.

That's it. Everything else works.

Except it doesn't, because each filesystem is different. The above is
true for HFS+, it is NOT true for FAT32, which has a whole bunch of
other characters which are illegal.

This is the bad news: there is NO way to tell what those characters are.

Once you've eliminated the obviously bad ones, the only thing you can
really do is try it. If it fails, you might eliminate some more bad
ones, like the list of characters that FAT32 doesn't like. But that's
not guaranteed to be enough. You could be on a different filesystem
with a different list. You could be talking to a filesystem, like NFS,
where the list isn't constant.

Your best bet, once you strip slashes, is probably just to try it and
present the user with a friendly error telling him to use a different
name if it fails. It's painful to push the task of figuring out what
characters are illegal back onto the user, but it's the only realistic
way.

Mike
___

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: do i need to create autorelease pool?

2009-02-25 Thread Michael Ash
On Wed, Feb 25, 2009 at 8:45 PM, Peter N Lewis pe...@stairways.com.au wrote:
 OK, I will certainly defer to Michael's deeper knowledge on this stuff,

Oh no, don't do that

 but
 I thought Leopard plugged most of the normal case holes for requiring an
 auto release pool, so I wrote up this test case:

 #import AppDelegate.h

 @interface BogusObject : NSObject {
 }

 @end

 @implementation BogusObject

 - (id) init;
 {
  self = [super init];
  if (self != nil) {
    NSLog( @BogusObject init );
  }
  return self;
 }

 - (void) dealloc;
 {
  NSLog( @BogusObject dealloc );
  [super dealloc];
 }

 @end

 @implementation AppDelegate

 - (void) timerFired:(NSTimer*)theTimer;
 {
  NSLog( @timerFired );
  [[[BogusObject alloc] init] autorelease];
 }

 - (void) applicationDidFinishLaunching:(NSNotification *)aNotification;
 {
  NSLog( @applicationDidFinishLaunching );
  [NSTimer scheduledTimerWithTimeInterval:1 target:self
 selector:@selector(timerFired:) userInfo:nil repeats:YES];
 }

 @end


 With the app sitting in the background doing nothing, I get the same results
 whether timerFired uses release or autorelease, ie every second all
 three messages are printed:

 2009-02-26 10:38:43.440 CheckTimer[82997:10b] timerFired
 2009-02-26 10:38:43.441 CheckTimer[82997:10b] BogusObject init
 2009-02-26 10:38:43.441 CheckTimer[82997:10b] BogusObject dealloc

 For good measure, I tried this on Tiger, and got the same results, so now
 I'm just left wondering where my confusion lies.

Well, obviously NSTimers *don't* suffer from this problem, and didn't
on Tiger either, and perhaps not ever. Clearly I was mistaken there!

You can reproduce the behavior I described if you use a CFRunLoopTimer
instead of an NSTimer. Replace your AppDelegate code with this:

static void Callback(CFRunLoopTimerRef timer, void *info)
{
NSLog( @test fired );
[[[BogusObject alloc] init] autorelease];
}

- (void) applicationDidFinishLaunching:(NSNotification *)aNotification;
{
NSLog( @applicationDidFinishLaunching );
CFRunLoopTimerRef timer = CFRunLoopTimerCreate(NULL, 0, 1, 0, 0,
Callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
CFRelease(timer);
}

As long as the app sits idle, you'll see only allocation. Once you
push an event to it, for example by clicking the mouse, all the queued
up objects get destroyed.

So it can indeed happen relatively easily as I described, but clearly
I was confused as to where it can happen, and the OP will have
absolutely no trouble with his code and doesn't need to make his own
pools.

Mike
___

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: Subclassing with more restrictive initializers

2009-02-25 Thread Ken Thomases

On Feb 25, 2009, at 1:00 PM, Paul Sanders wrote:

My solution would be to cover *all* inherited initialisers and  
assert in any

not supported by the subclass.  The idea, surely, is to catch any
programming errors as early as possible.  Not covering an  
initialiser which,
if called, would lead to unpredictable results seems to me to be  
taking an

unnecessary risk (of introducing a bug).

*Now* all we need is an implementation of assert that does something a
little more useful than SIGABRT.  But that is a detail.


Apple's recommendation when a subclass wants to disavow a method of  
its superclass is to have the subclass override invoke [self  
doesNotRecognizeSelector:_cmd].


Cheers,
Ken

___

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: NSScrollView's content view doesn't un-hide

2009-02-25 Thread John C. Randolph


On Feb 25, 2009, at 4:28 PM, Scott Hamilton wrote:


Am I missing something?


From your description, you're sending -setNeedsDispay to the the  
clipview, not to the subviews within the clipview.


-jcr

___

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: OmniObjectMeter is now free

2009-02-25 Thread John C. Randolph


On Feb 24, 2009, at 8:04 PM, Ken Case wrote:

You'll find it at http://www.omnigroup.com/developer/ 
omniobjectmeter/.


Thanks, Ken!

 We also recently posted updated versions of our open source Omni  
frameworks to github, including OmniDataObjects (our CoreData-like  
implementation which works on both Mac and iPhone).  For more  
information, see http://www.omnigroup.com/developer/.



Note to the list:  Reading the code in Omni's frameworks is highly  
recommended.   Omni's been writing Objective-C code for a long time.


-jcr

___

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: Observing Managed Object Changes

2009-02-25 Thread Jerry Krinock

Thanks for your advice, Ben.

I submitted a Bug Report.  Problem ID is: 6624874

And for the sake of the list archive audience, here's the text, which  
summarizes this whole thread...


Summary:  In many applications, auxiliary views or objects are  
interested in changes that occur to Core Data managed objects.  In  
Cocoa, such information is ordinarily obtained by notifications or key- 
value observing (KVO).  But using either technique to obtain  
information about managed objects is incomplete or difficult.


Steps to Reproduce:
Build an Core Data application such as Apple's DepartmentAndEmployees  
sample project.  Add some auxiliary views or objects which would like  
to be informed of changes to some of the managed objects.  For example,
a) An OrgChart view wants to be informed whenever the directReports of  
any Employee changes.
b) A Payroll object is interested wants to be informed whenever the  
'salary' of any Employee changes, or an Employee is added or deleted.
c) A DuplicateFirstNames object wants to be informed whenever the  
firstName of an Employee changes, or an Employee is added or deleted.


Expected Results:
There should be an easy way to register for notifications or use KVO  
to be informed of the desired changes.


Actual Results:
There appear to be three solutions available to get the desired  
information, but none of them are very practical.


Solution 1.  Use KVO.  Although adding observers can be done rather  
systematically, in awakeFromInsert and awakeFromFetch, removing  
observers must be done (1) when deallocating the moc and (2) in the  
managed object's -dealloc method (which is not recommended for  
subclassing).  The latter is to catch objects still on the undo stack  
or elsewhere, and requires checking that the observer has not already  
been removed by the former.  Removing the observers when deallocating  
the moc is also an ugly process -- you fetch all objects and send each  
one a -removeYourObservers message, if they respond.  Another  
alternative considered is to remove the observer in -didTurnIntoFault,  
but this is not acceptable because -didTurnIntoFault may be invoked  
when an object is deleted, but if delete is reversed by Undo, and  
faulted back in, there is no hook available (i.e. -didUnturnIntoFault)  
for the programmer to know that the object is back so that the  
observer can be restored as it must be.


Solution 2.  Use Custom Setters.  For each key/value in each object  
that is to be observed, implement a custom setter, and in each such  
custom setter post a notification of the value change.  This is not  
too bad with attributes, because there is only one setter per  
attribute.  But for to-many relations you need to override the four  
(or is it five) set mutator methods in order to cover all the possible  
ways in which the relationship may be changed.  What if more mutator  
methods are added in some future version of Mac OS?  This requires  
much code and seems quite fragile.


Solution 3.  Use NSManagedObjectContextObjectsDidChangeNotification.   
Interested objects can register for  
NSManagedObjectContextObjectsDidChangeNotification.  The information  
you get in the notification is adequate if objects are added or  
deleted, but not for updated objects because it does not tell you the  
key of the value which changed that caused the notification.  You can  
send -changedValues to the object, but this will return ^all^ key/ 
values that were changed since the last time the managed object  
context was saved.  So you either need to have some kind of memory to  
filter out the repititions, or process the same change multiple  
times.  The former is a kludge, and may be too expensive, and the  
latter may be unacceptable, for example, if the user is to be alerted  
when a change occurs.


Notes:
My favored solution might be to enhance  
NSManagedObjectContextObjectsDidChangeNotification so that it included  
the key/value immediately responsible for the change in Updated  
objects.  Then, only one notification needs to be registered for, and  
only one method needs to be written, the selector for this  
notification, in which the programmer would filter out whatever  
changes are relevant and forward appropriate messages to the  
interested objects or views.


___

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


need help on understanding the crashreporter traces

2009-02-25 Thread Arnab Ganguly
Hi,
Guys sorry if it is a wrong group.

I am analysing the Apple crash report.So I launched my application and tried
to forcibly (kill -11 pid) crash the application.The app crashed and even
the Apple crash report got generated.
The crash report says Thread 1 crashed, but when I go through the stack
trace of Thread 0 I see sigtramp is being received by Thread 0.Is this
correct report?

How is the thread received signal is different from the thread that got
crashed as per the report ?Any help or suggestion would be of great help.


I have given below the crash report.The highlighted line shows that signal
was received by Thread 0 but the crash was happened on Thread 1.I was
crashing the application forcibly by sending signal 11 from the command
prompt multiple times.There I am confused or may be way I am interpreting is
incorrect.

OS Version:  Mac OS X 10.5.6 (9G55)
Report Version:  6

Exception Type:  EXC_CRASH (SIGSEGV)
Exception Codes: 0x, 0x
Crashed Thread:  1

Thread 0:
0   libSystem.B.dylib   0x94fe518e wait4 + 10
1   talkback.dylib  0x00e11571
spStackTraceCollector::crawl(int, spKeyDataStream*, char*, int, char*,
unsigned long*, unsigned long*) + 593 (StackTraceC.cpp:170)
2   talkback.dylib  0x00e1197d
spStackTraceCollector::Collect(BlackBox, spKeyDataStream*,
SPIRAL_TRIGGER_CONTEXT*) + 349 (StackTraceC.cpp:253)
3   talkback.dylib  0x00e12157
spCollectionManager::Collect(spKeyDataStream*, SPIRAL_TRIGGER_CONTEXT*) +
139 (collmgr.cpp:45)
4   talkback.dylib  0x00e0a828
spSpiralNubCore::Collect(SPIRAL_TRIGGER_CONTEXT*, unsigned char, char*) +
646 (nubcore.cpp:1059)
5   talkback.dylib  0x00e0ebad
spSpiralNubCore::HandleProgramException(SPIRAL_TRIGGER_CONTEXT*) + 195
(nubcore.cpp:2362)
6   talkback.dylib  0x00e04d10 FCProcessSignal(int,
UNIX_EXCEPTION_CONTEXT*) + 132
7   talkback.dylib  0x00e10d57 SignalHandler_10_2(int,
siginfo*, ucontext*) + 579
8  * libSystem.B.dylib   0x94fe42bb _sigtramp + 43*
9   ??? 0x 0 + 4294967295
10  com.apple.CoreFoundation0x96ab70ae CFRunLoopRunSpecific +
1790
11  com.apple.CoreFoundation0x96ab7cd8 CFRunLoopRunInMode + 88
12  com.apple.HIToolbox 0x905cf2c0 RunCurrentEventLoopInMode
+ 283
13  com.apple.HIToolbox 0x905cf0d9 ReceiveNextEventCommon +
374
14  com.apple.HIToolbox 0x905cef4d
BlockUntilNextEventMatchingListInMode + 106
15  com.apple.AppKit0x94742d7d _DPSNextEvent + 657
16  com.apple.AppKit0x94742630 -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
17  com.apple.AppKit0x9473b66b -[NSApplication run] +
795
18  com.apple.AppKit0x947088a4 NSApplicationMain + 574
19  com.aol.aim.desktop 0x2f1d 0x1000 + 7965
20  com.aol.aim.desktop 0x2852 0x1000 + 6226
21  com.aol.aim.desktop 0x2779 0x1000 + 6009

*Thread 1 Crashed:*
0   libSystem.B.dylib   0x94f7f3ae __semwait_signal + 10
1   libSystem.B.dylib   0x94fa9d0d
pthread_cond_wait$UNIX2003 + 73
2   ...ple.CoreServices.CarbonCore  0x92b16ecf TSWaitOnCondition + 126
3   ...ple.CoreServices.CarbonCore  0x92af5da6
TSWaitOnConditionTimedRelative + 202
4   ...ple.CoreServices.CarbonCore  0x92b16b4c MPWaitOnQueue + 208
5   ...thesis.MacinTalkSynthesizer  0x04dbb9dd
MTBEWorker::WorkLoop(MTBEWorker*) + 209
6   ...thesis.MacinTalkSynthesizer  0x04dbbb5d MTBEWorkerStartMPTask +
17
7   ...ple.CoreServices.CarbonCore  0x92b150a3 PrivateMPEntryPoint + 56
8   libSystem.B.dylib   0x94fa9095 _pthread_start + 321
9   libSystem.B.dylib   0x94fa8f52 thread_start + 34


Thanks
Arnab
___

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


  1   2   >