Re: Best way to hook into the run loop?

2009-12-06 Thread Uli Kusterer
On 05.12.2009, at 01:36, Graham Cox wrote:
 If anyone can think of an elegant and straightforward alternative, please 
 feel free to suggest it. I've found that the obvious solution of submitting 
 an object's state at the start of a drag is actually really awkward and 
 horrible in practice, since it requires that the controller needs to know in 
 advance all of the relevant properties that will be changed, when in fact 
 that's none of its business. The data model should be free to change anything 
 it needs to in response to a higher-level command and submit its own undo 
 tasks.

 I thought that was what undo groups were for? Open a group at the start of the 
drag manually, close it at the end, and everything in between gets lumped into 
one big action at the end. It may get replayed internally, but will all be 
triggered by one Cmd-Z.

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de

___

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: Best way to hook into the run loop?

2009-12-06 Thread Graham Cox

On 06/12/2009, at 8:12 PM, Uli Kusterer wrote:

 I thought that was what undo groups were for? Open a group at the start of 
 the drag manually, close it at the end, and everything in between gets lumped 
 into one big action at the end. It may get replayed internally, but will 
 all be triggered by one Cmd-Z.


Indeed, undo groups are great. Unfortunately, NSUndoManager has a bug where if 
you open a group (on mouse down, say), do nothing (no drag), and close it again 
(on mouse up), an empty Undo task appears in the Undo menu. It's harmless, in 
that it does nothing, but it's also a nuisance, since the user doesn't expect 
this and reports it as a bug with your app. It's working around this bug that 
is horrible and surprisingly complicated (for two reasons - one, you can't peek 
at the top of the undo stack to see what's there and two, even if you could 
there's no way to tell whether the task there is empty, because the 'tasks' are 
all private classes. Therefore you have to come up with another way either to 
detect this case, or to prevent it from happening. Either way, it's a 
complicated and nasty hack). Incidentally I have reported this bug but it came 
back as a dupe. It's been there since I started with Cocoa, on 10.2.

In addition, you don't really want a group to record every intermediate step of 
a drag - theoretically that could run to any number of tasks, which on Undo 
would be 'replayed', so the drag would eventually get undone but who cares 
about all the in-between steps? You just want the object to return to the 
position at the start of the drag. This is what 'task coalescing' achieves, 
along with the potentially huge memory saving of not recording the irrelevant 
in-between steps. Unfortunately NSUndoManager doesn't support task coalescing, 
so you have to subclass it to add this. It's not a huge deal but the bogus task 
problem is.

I've now written my own undo manager from scratch. It's much more 
straightforward than NSUndoManager in that it uses Cocoa collection classes 
internally - I'm guessing that one reason for NSUndoManager's arcane 
implementation with all its weird group end and start markers and so on is so 
that it also works with Core Foundation alone. It turns out my approach is 
coincidentally very near identical to GNUStep's implementation. I was concerned 
that because it subclasses NSObject, not NSUndoManager, it would cause trouble 
when passed to NSDocument's -setUndoManager: method, but so far I can report 
that it works perfectly with no issues, supports coalescing and doesn't exhibit 
the empty group bug. It has an identical public API to NSUndoManager so my main 
concern was whether internal parts of Cocoa were using private API but that 
does not appear to be the case. I followed the documentation with respect to 
when the various notifications are sent, and that didn't quite keep 
NSDocument's dirty state properly in synch, so I did what was necessary to keep 
it happy and so now it's slightly not as documented - but I suspect the issue 
there is that the docs are subtly incorrect. There's also a suspicion among 
users who contacted me off-list that Core Data is doing something with private 
Undo API, so mine may not support a Core Data app, but for now that doesn't 
concern me.

I've still got some testing to do to really prove it's safe to use, but so far 
I'm much happier with it than NSUndoManager (and if things do go wrong I can at 
least debug it directly instead of having to guess what's going on inside the 
black box and relying on the inaccurate documentation). I'll put it out on my 
website when I'm done - not seeing those useless 'undo manager is in an invalid 
state' logs is liberating, I can tell you.

--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: passing nothing to method with CGPoint argument

2009-12-06 Thread Graham Cox

On 06/12/2009, at 1:08 PM, Chunk 1978 wrote:

  for factoring purposes i want to be able to call the same
 method from touchesEnded that will clear the output strings if there
 is no point, but CGPointZero is a point.


Can't you just define an 'impossible' point value to act as a sentinel? 
Something very negative for example.

--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: Best way to hook into the run loop?

2009-12-06 Thread Mike Abdullah

On 6 Dec 2009, at 10:53, Graham Cox wrote:

 
 On 06/12/2009, at 8:12 PM, Uli Kusterer wrote:
 
 I thought that was what undo groups were for? Open a group at the start of 
 the drag manually, close it at the end, and everything in between gets 
 lumped into one big action at the end. It may get replayed internally, but 
 will all be triggered by one Cmd-Z.
 
 
 Indeed, undo groups are great. Unfortunately, NSUndoManager has a bug where 
 if you open a group (on mouse down, say), do nothing (no drag), and close it 
 again (on mouse up), an empty Undo task appears in the Undo menu. It's 
 harmless, in that it does nothing, but it's also a nuisance, since the user 
 doesn't expect this and reports it as a bug with your app.

But why are you opening a group without registering an undo action? Why not 
just wait until the first action actually needs to be registered?

 It's working around this bug that is horrible and surprisingly complicated 
 (for two reasons - one, you can't peek at the top of the undo stack to see 
 what's there and two, even if you could there's no way to tell whether the 
 task there is empty, because the 'tasks' are all private classes. Therefore 
 you have to come up with another way either to detect this case, or to 
 prevent it from happening. Either way, it's a complicated and nasty hack). 
 Incidentally I have reported this bug but it came back as a dupe. It's been 
 there since I started with Cocoa, on 10.2.

I'm not even sure it is a bug, since the undo manager is designed to work in 
terms of groups, not individual actions.
 
 In addition, you don't really want a group to record every intermediate step 
 of a drag - theoretically that could run to any number of tasks, which on 
 Undo would be 'replayed', so the drag would eventually get undone but who 
 cares about all the in-between steps? You just want the object to return to 
 the position at the start of the drag. This is what 'task coalescing' 
 achieves, along with the potentially huge memory saving of not recording the 
 irrelevant in-between steps. Unfortunately NSUndoManager doesn't support task 
 coalescing, so you have to subclass it to add this. It's not a huge deal but 
 the bogus task problem is.

So again, why not just wait till the end of the drag and record a single action?
 
 I've now written my own undo manager from scratch. It's much more 
 straightforward than NSUndoManager in that it uses Cocoa collection classes 
 internally - I'm guessing that one reason for NSUndoManager's arcane 
 implementation with all its weird group end and start markers and so on is so 
 that it also works with Core Foundation alone. It turns out my approach is 
 coincidentally very near identical to GNUStep's implementation. I was 
 concerned that because it subclasses NSObject, not NSUndoManager, it would 
 cause trouble when passed to NSDocument's -setUndoManager: method, but so far 
 I can report that it works perfectly with no issues, supports coalescing and 
 doesn't exhibit the empty group bug. It has an identical public API to 
 NSUndoManager so my main concern was whether internal parts of Cocoa were 
 using private API but that does not appear to be the case. I followed the 
 documentation with respect to when the various notifications are sent, and 
 that didn't quite keep NSDocument's dirty state properly in synch, so I did 
 what was necessary to keep it happy and so now it's slightly not as 
 documented - but I suspect the issue there is that the docs are subtly 
 incorrect. There's also a suspicion among users who contacted me off-list 
 that Core Data is doing something with private Undo API, so mine may not 
 support a Core Data app, but for now that doesn't concern me.
 
 I've still got some testing to do to really prove it's safe to use, but so 
 far I'm much happier with it than NSUndoManager (and if things do go wrong I 
 can at least debug it directly instead of having to guess what's going on 
 inside the black box and relying on the inaccurate documentation). I'll put 
 it out on my website when I'm done - not seeing those useless 'undo manager 
 is in an invalid state' logs is liberating, I can tell you.
 
 --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/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.net

___

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 

Re: Best way to hook into the run loop?

2009-12-06 Thread Graham Cox

On 06/12/2009, at 10:57 PM, Mike Abdullah wrote:

 But why are you opening a group without registering an undo action? Why not 
 just wait until the first action actually needs to be registered?

I tried it but it doesn't work. I forget the details now as this was my first 
approach and that was a long time ago, but basically the undo manager didn't 
tolerate having groups deferred until a task was actually received. It would 
crash, but without the code, I couldn't say why.

My second approach was to wait until a mouse drag was received, then IF the 
mouse drag handler knew it was going to cause an undoable data model change, it 
would call its delegate to open a group. That worked but was very complicated - 
not every mouse drag necessarily led to an undoable change, so a lot of special 
cases were needed. It was truly ugly. (Bear in mind these mouse drag handlers 
are all individual tools in a drawing app, but some tools cause undoable 
changes, and others don't, e.g. zoom tool).

My third approach was to count the tasks received after opening a group and 
then if that value was 0 at the end of the drag, invoke -undo to remove the 
empty group. That works but I ran into a further issue that if an exception is 
thrown during the drag then cleaning up the open group could not be done (the 
group level stayed stuck at 1 and the group stayed open, leading to the undo 
manager ceasing to work). Without the code, I couldn't say why.

My fourth approach is to write my own bloody undo manager and have done with 
it. Result so far - bliss.

It's really nice and simple if you can just open a group on mouse down, and 
close it again on mouse up. If this didn't result in a bogus Undo task, it 
would work great, as my home grown implementation shows - there's no need to 
worry whether you need the group or not, because if it ends up empty it's never 
added to the Undo stack and is discarded. I believe NSUndoManager should do 
that also.


 I'm not even sure it is a bug, since the undo manager is designed to work in 
 terms of groups, not individual actions.

Internally it works in groups, but a group needs to have at least one action 
otherwise it does nothing. However, an empty group still appears as an undoable 
task in the menu, which is useless. It just causes the user to think that your 
app is broken. What purpose does an empty group serve? I suppose some apps 
might not be submitting any actual actions to the undo manager, but just 
relying on undo notifications to perform undo by some other means internally, 
which might explain why this behaviour persists - but if that is the case the 
docs are silent on that point (and a better design would be to allow that 
behaviour to be disabled).

 So again, why not just wait till the end of the drag and record a single 
 action?

Because an individual property has no way to know whether it's the last in a 
series invoked by a drag. How do you detect 'last'? You can't, because it might 
not have happened yet. If I have a basic property of an object in my data 
model, it can submit its old value to the undo manager - very simple. But it 
doesn't know who called it or whether or not it will be called again. However 
the Undo Manager does know something about a sequence of identical properties 
submitted to it because it is aware of the event cycle and the open group that 
it's adding actions to. It can accept the first (representing the initial or 
original state) and drop the remainder within that event cycle or group. 
Detecting the first is easy (and for undo, is the one that counts), detecting 
last is impossible.

It might be possible to capture the state at the start of a drag but bear in 
mind that a drag could change any number of properties of any number of 
objects. In order to capture the state in advance it would have to know what 
the drag was actually going to change. The object that handles the drag has no 
such knowledge - the data model has that information. The mouse drag is 
something that happens at the controller level (the events having been passed 
to it from a view) but the actual changes to the data model occur at the model 
level, and it is the model that knows what properties to change and thus 
submits their old values to the undo manager. In hindsight it might have been 
better to have the controller observe the changes via KVO and handle the 
coalescing and undo submission there, since it can discriminate between the 
first and last in a sequence of mouse events, but that would be a huge rewrite 
of my app at this stage. Besides, I've always thought of Undo as a model-level 
feature - it's the changes to the data model that you're actually undoing, so 
its unclear if moving the responsibility for Undo into the controller is even 
theoretically the right thing to do.

--Graham

___

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

Please do not post admin requests or moderator comments to the 

Re: Best way to hook into the run loop?

2009-12-06 Thread Andy Lee
On Dec 6, 2009, at 7:36 AM, Graham Cox wrote:
 My fourth approach is to write my own bloody undo manager and have done with 
 it. Result so far - bliss.

FWIW, Wil Shipley agrees about the bliss part:

http://wilshipley.com/blog/2007/12/transitions-and-epiphanies.html

 I was so into using CoreData's magic undo that I kept going farther and 
 farther to make it work, when I really needed to say, Ok, this doesn't work 
 in this situation, I'm doing my own undo in 40 lines of code.

I haven't worked with NSUndoManager myself, but my takeaway from this (and also 
from a friend who was also frustrated with it) is that it's great for very 
basic scenarios, but if I ever find myself getting frustrated with it I 
shouldn't hesitate to write my own.

--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: Best way to hook into the run loop?

2009-12-06 Thread Graham Cox
Ah, thanks for that little glimmer of encouragement! If it's good enough for 
WS, it's good enough for me.

I guess my problems stem from the fact that my app is heavily based on mouse 
dragging gestures, and mouse dragging is a whole series of events. The undo 
manager is maybe not so well designed to group tasks that are distributed 
across a series of events, but is mostly based on the idea that anything that's 
going to happen will happen within a single event cycle.

My own implementation is definitely designed with the mouse dragging usage in 
mind, so perhaps it's more suitable in this situation but possibly not in every 
other case. I feel a little more confident that I'm not totally barmy for 
taking this approach.

I'd still like to know where in the MVC picture undo is ideally supposed to sit 
however.

--Graham

 



On 07/12/2009, at 12:30 AM, Andy Lee wrote:

 On Dec 6, 2009, at 7:36 AM, Graham Cox wrote:
 My fourth approach is to write my own bloody undo manager and have done with 
 it. Result so far - bliss.
 
 FWIW, Wil Shipley agrees about the bliss part:
 
 http://wilshipley.com/blog/2007/12/transitions-and-epiphanies.html
 
 I was so into using CoreData's magic undo that I kept going farther and 
 farther to make it work, when I really needed to say, Ok, this doesn't work 
 in this situation, I'm doing my own undo in 40 lines of code.
 
 I haven't worked with NSUndoManager myself, but my takeaway from this (and 
 also from a friend who was also frustrated with it) is that it's great for 
 very basic scenarios, but if I ever find myself getting frustrated with it I 
 shouldn't hesitate to write my own.
 
 --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: Programatically Setting Delegate

2009-12-06 Thread Alexander Spohr
I translate you url for a better understanding for other readers:
You google:
 you forgot to allocate the object before setting it's delegate
The result:
 No results found for you forgot to allocate the object before setting it's 
 delegate.

So what are you telling us?

Maybe you should have shown code.
The error message is clearly not because you forgot an alloc. The compiler does 
not check if you pointer is pointing to a valid object or nil or garbage. How 
should it?

Or I completely misunderstood what you wanted to know. I am sorry then for 
pointing you to the obvious.

atze


Am 05.12.2009 um 20:57 schrieb Chunk 1978:

 i figured it out.  alexander, this would have been more helpful:
 http://tinyurl.com/yjpeljv
 
 On Sat, Dec 5, 2009 at 2:42 PM, Chunk 1978 chunk1...@gmail.com wrote:
 thanks for teaching me how to use google.  huge help.
 
 unfortunately, since i've imported both UIKit and my controller class
 into my custom UIImageView class, my question is wasn't what does that
 error mean, but why am i receiving it.
 
 On Sat, Dec 5, 2009 at 6:45 AM, Alexander Spohr a...@freeport.de wrote:
 http://lmgtfy.com/?q=error+request+for+member+is+something+not+a+structure+of+union
 
atze
 
 
 Am 05.12.2009 um 09:12 schrieb Chunk 1978:
 
 i have a UIViewController that i'm setting as the delegate for my
 custom UIImageView class.  from my custom UIImageView class i want the
 delegate to change it's background color (based on computations
 performed within the UIImageView class).
 
 in my UIViewController i write:
 –
 myUIImageViewClass.classDelegate = self;
 –
 
 then in my custome UIImageViewClass i synthisize the accessor method
 for the classDelegate, which is of type id. then from within the code
 i try to change the background color of it's delegate with this:
 –
 [[classDelegate view] setBackgroundColor:[UIColor greenColor]];
 –
 
 if i write it like classDelegate.view.backgroundColor = ... then i
 receive and error saying error request for member is something not a
 structure of union
 
 
 
 ___
 
 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/atze%40freeport.de
 
 This email sent to a...@freeport.de

___

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: Best way to hook into the run loop?

2009-12-06 Thread Mike Abdullah

On 6 Dec 2009, at 13:30, Andy Lee wrote:

 On Dec 6, 2009, at 7:36 AM, Graham Cox wrote:
 My fourth approach is to write my own bloody undo manager and have done with 
 it. Result so far - bliss.
 
 FWIW, Wil Shipley agrees about the bliss part:
 
 http://wilshipley.com/blog/2007/12/transitions-and-epiphanies.html
 
 I was so into using CoreData's magic undo that I kept going farther and 
 farther to make it work, when I really needed to say, Ok, this doesn't work 
 in this situation, I'm doing my own undo in 40 lines of code.
 
 I haven't worked with NSUndoManager myself, but my takeaway from this (and 
 also from a friend who was also frustrated with it) is that it's great for 
 very basic scenarios, but if I ever find myself getting frustrated with it I 
 shouldn't hesitate to write my own.

Er, Wil's post has nothing to do with Graham's problem. Wil ran into issues 
fighting Core Data's built-in undo registration and decided the best approach 
to manually record undo information himself instead. I am almost 100% certain 
Wil didn't then proceed to chuck out NSUndoManager. He just turned off Core 
Data's use 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: NSPopUpButton questions

2009-12-06 Thread Keary Suska
On Dec 5, 2009, at 6:29 PM, timm...@gmail.com wrote:

 The Apple docs for NSPopUpButtons says to avoid accessing it's NSMenu 
 directly because it may need to do housekeeping. I had to access it's NSMenu 
 directly though so that I could make a separator menu item. Is this fine for 
 this situation, or is there a better way to do this to conform to Apple's 
 recommendation?

I believe this warning is about changing the menu at certain times, such as 
when the button is about to pop up.

 Also, is there a way to set a menu item to act like it's disabled, but 
 without graying out its title and image? I'm trying to insert a Bonjour 
 section and want the Bonjour menu item and image to be unselectable, but not 
 grayed out.

No that I am aware of, and probably because is smells like a HIG violation. If 
you want a named subgroup, you should use a submenu.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Best way to hook into the run loop?

2009-12-06 Thread Andy Lee
On Dec 6, 2009, at 10:20 AM, Mike Abdullah wrote:
 On 6 Dec 2009, at 13:30, Andy Lee wrote:
 
 On Dec 6, 2009, at 7:36 AM, Graham Cox wrote:
 My fourth approach is to write my own bloody undo manager and have done 
 with it. Result so far - bliss.
 
 FWIW, Wil Shipley agrees about the bliss part:
 
 http://wilshipley.com/blog/2007/12/transitions-and-epiphanies.html
 
 I was so into using CoreData's magic undo that I kept going farther and 
 farther to make it work, when I really needed to say, Ok, this doesn't 
 work in this situation, I'm doing my own undo in 40 lines of code.
 
 I haven't worked with NSUndoManager myself, but my takeaway from this (and 
 also from a friend who was also frustrated with it) is that it's great for 
 very basic scenarios, but if I ever find myself getting frustrated with it I 
 shouldn't hesitate to write my own.
 
 Er, Wil's post has nothing to do with Graham's problem. Wil ran into issues 
 fighting Core Data's built-in undo registration and decided the best approach 
 to manually record undo information himself instead. I am almost 100% certain 
 Wil didn't then proceed to chuck out NSUndoManager. He just turned off Core 
 Data's use of it.

True, the contexts are different.  My point was that if built-in undo doesn't 
work for you for whatever reason, it's not wacky to consider writing your own.  
Usually when one starts down this road it's reasonable to wonder whether you're 
missing something and fighting the frameworks.

--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: Best way to hook into the run loop?

2009-12-06 Thread Paul Bruneau

On Dec 6, 2009, at 5:53 AM, Graham Cox wrote:

 
 On 06/12/2009, at 8:12 PM, Uli Kusterer wrote:
 
 I thought that was what undo groups were for? Open a group at the start of 
 the drag manually, close it at the end, and everything in between gets 
 lumped into one big action at the end. It may get replayed internally, but 
 will all be triggered by one Cmd-Z.
 
 
 Indeed, undo groups are great. Unfortunately, NSUndoManager has a bug where 
 if you open a group (on mouse down, say), do nothing (no drag), and close it 
 again (on mouse up), an empty Undo task appears in the Undo menu. It's 
 harmless, in that it does nothing, but it's also a nuisance, since the user 
 doesn't expect this and reports it as a bug with your app. It's working 
 around this bug that is horrible and surprisingly complicated (for two 
 reasons - one, you can't peek at the top of the undo stack to see what's 
 there and two, even if you could there's no way to tell whether the task 
 there is empty, because the 'tasks' are all private classes. Therefore you 
 have to come up with another way either to detect this case, or to prevent it 
 from happening. Either way, it's a complicated and nasty hack). Incidentally 
 I have reported this bug but it came back as a dupe. It's been there since I 
 started with Cocoa, on 10.2.

I ran into the same problem and my bug was also flagged as a duplicate. Here is 
my submission which includes my workaround:

 14-Aug-2008 09:31 AM Paul Bruneau:
 * SUMMARY
 When trying to utilize undo grouping using what seems to be the most 
 straightforward way, the undo group can be empty with no actions in it, yet 
 the system will still put this empty group into the undo stack.
 
 * STEPS TO REPRODUCE
 In my case, I am dealing with user actions in an NSView subclass. I use 
 -mouseDown, -mouseDragged, and -mouseUp.
 
 The way that seemed at first to be best is to initiate an undo group in 
 -mouseDown, create undo actions during -mouseDragged, and finally to 
 terminate the undo grouping in -mouseUp. The user clicks objects in the view 
 and drags them around. This results in many operations over the course of the 
 dragging, all of which I want to be in one undo group.
 
 But if I implement my grouping code in mouseDown and mouseUp, I have the 
 problem where if the user just clicks on one of my objects without moving it, 
 the undo group is empty, containing no actions. 
 
 
 * RESULTS
 The results of this are that the empty undo group is put on the stack, and 
 the user can Undo it, but nothing happens (because there was no action to 
 undo).
 
 What I would like to see, is if an undo group has no actions in it, it should 
 be discarded. Surely this is what Cocoa does when it is doing its normal 
 event loop based grouping. It doesn't put an empty undo group into the 
 stack with every pass of the event loop--why does it put my empty undo group 
 into the stack?
 
 Or perhaps consider this a documentation enhancement request. Maybe there is 
 an easy solution for me that I don't know about.
 
 
 * NOTES
 In my particular case, I was able to perform a workaround by implementing the 
 -beginUndoGrouping message in my -mouseDragged method. 
 
 By doing it this way, I am assured that the user is actually dragging around 
 one of the objects in my view rather that just clicking on one, or clicking a 
 blank area of the view.
 
 But it is kind of kludgy because -mouseDragged is repeatedly called while the 
 user is dragging. So I had to test to see if an undo group already exists 
 like so:
 
 - (void)mouseDragged:(NSEvent *)event
 {
   if ( dragging == YES ) 
   {   
   if ( [[myUndoManager] groupingLevel] == 0 )
   {
   //start custom undo grouping
   [[myUndoManager] setGroupsByEvent:NO];
   [[myUndoManager] beginUndoGrouping];
 
   }
 ...
 
 But I don't find this optimal. It would get a lot more complex if I did any 
 nested groups I think.

___

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: NSPopUpButton questions

2009-12-06 Thread Matt Neuburg
On Sat, 5 Dec 2009 20:29:25 -0500, timm...@gmail.com timm...@gmail.com
said:
The Apple docs for NSPopUpButtons says to avoid accessing it's NSMenu directly
because it may need to do housekeeping.

Where do the Apple docs say that? I'm thinking there might be some
misunderstanding lurking here. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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: NSPopUpButton questions

2009-12-06 Thread Andy Lee
On Dec 6, 2009, at 11:34 AM, Matt Neuburg wrote:
 On Sat, 5 Dec 2009 20:29:25 -0500, timm...@gmail.com timm...@gmail.com
 said:
 The Apple docs for NSPopUpButtons says to avoid accessing it's NSMenu 
 directly
 because it may need to do housekeeping.
 
 Where do the Apple docs say that? I'm thinking there might be some
 misunderstanding lurking here. m.

Indeed, there are a few methods where the docs specifically recommend accessing 
the menu directly, e.g.:

http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPopUpButton_Class/Reference/Reference.html#//apple_ref/occ/instm/NSPopUpButton/insertItemWithTitle:atIndex:
 Since this method searches for duplicate items, it should not be used if you 
 are adding an item to an already populated menu with more than a few hundred 
 items. Add items directly to the receiver's menu instead.

--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: Programatically Setting Delegate

2009-12-06 Thread Kyle Sluder

On Dec 6, 2009, at 7:12 AM, Alexander Spohr a...@freeport.de wrote:


So what are you telling us?


He's saying he eventually found the problem on his own.

--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: Is it possible to pass an object to a NIB

2009-12-06 Thread DeNigris Sean
I tightened up the code a bit:
#Obj-C version: - (id)initWithContentsOfURL:(NSURL *)nibFileURL
nib_file = NSNib.alloc.initWithContentsOfURL NSURL::fileURLWithPath(@@NibPath)

#Obj-C version: - 
(BOOL)instantiateNibWithOwner:(id)ownertopLevelObjects:(NSArray 
**)topLevelObjects
#The Ruby bridge puts the top level objects in the second return value because 
the 2nd param takes a pointer
# and Ruby does not have pointers
result, top_level_objects = nib_file.instantiateNibWithOwner_topLevelObjects 
NSApplication.sharedApplication

view = top_level_objects.find { |obj| obj.class == object_type }

- Sean___

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


[MEET] CocoaHeads-NYC this Thursday (*note location*)

2009-12-06 Thread Andy Lee
For our last meeting of 2009, Bob Clair will talk about blocks.



** IMPORTANT NOTE ABOUT LOCATION **

The December meeting will not be at the usual Tekserve location.  Instead, it 
will be hosted by our friends at Apress:

Apress
233 Spring Street (between 6th Avenue and Varick Street) 
6th Floor 
New York, NY 10013

Directions: 
C or E trains to Spring Street 
or #1 train to Houston Street

There is a link to a Google map at 
http://apress.com/info/contact



As usual:

(1) Please feel free to bring questions, code, and works in progress.  We have 
a projector and we like to see code and try to help.
(2) We'll go somewhere for food and beer afterwards.
(3) If there's a topic you'd like presented, let us know.
(4) If *you'd* like to give a talk, let me know.

Hope to see you there!

--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: NSPopUpButton questions

2009-12-06 Thread Paul Bruneau

On Dec 6, 2009, at 12:29 PM, Andy Lee wrote:

 On Dec 6, 2009, at 11:34 AM, Matt Neuburg wrote:
 On Sat, 5 Dec 2009 20:29:25 -0500, timm...@gmail.com timm...@gmail.com
 said:
 The Apple docs for NSPopUpButtons says to avoid accessing it's NSMenu 
 directly
 because it may need to do housekeeping.
 
 Where do the Apple docs say that? I'm thinking there might be some
 misunderstanding lurking here. m.
 
 Indeed, there are a few methods where the docs specifically recommend 
 accessing the menu directly, e.g.:
 
 http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPopUpButton_Class/Reference/Reference.html#//apple_ref/occ/instm/NSPopUpButton/insertItemWithTitle:atIndex:
 Since this method searches for duplicate items, it should not be used if you 
 are adding an item to an already populated menu with more than a few hundred 
 items. Add items directly to the receiver's menu instead.

Yeah, but the OP is right, the Application Menu and Pop-up List Programming 
Topics for Cocoa says this:

 To implement its menu, the button cell contains an NSMenu object, which in 
 turn contains several NSMenuItem objects, one for each item in the menu. 
 Avoid invoking methods on the NSMenu object directly, but instead invoke 
 methods on theNSPopUpButton instance, which may need to do some housekeeping 
 before invoking the appropriate methods on the menu. However, you can 
 retrieve the menu with the NSPopUpButton method menu. The NSPopUpButton 
 methods you use most often are the methods that tell you which item is 
 selected.

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MenuList/Articles/HowMenusWork.html

I have to say this has never stopped me from molesting the menu directly. But I 
disagree with the HIG on popup menus so I'm often on the wrong side of the law 
regarding this topic.___

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: Best way to hook into the run loop?

2009-12-06 Thread Quincey Morris
On Dec 6, 2009, at 04:36, Graham Cox wrote:

 On 06/12/2009, at 10:57 PM, Mike Abdullah wrote:
 
 But why are you opening a group without registering an undo action? Why not 
 just wait until the first action actually needs to be registered?
 
 I tried it but it doesn't work. I forget the details now as this was my first 
 approach and that was a long time ago, but basically the undo manager didn't 
 tolerate having groups deferred until a task was actually received. It would 
 crash, but without the code, I couldn't say why .

I'm not sure I understand this point. Are you talking about a situation with 
'setGroupsByEvent:YES' or 'setGroupsByEvent:NO'? Either way, an explicit call 
to 'beginUndoGrouping:' is *by definition* deferred, since it obviously can't 
happen the instant an event is dequeued. The length of time between dequeuing 
an event and invoking an undo manager method seems irrelevant. But I ask mainly 
out of curiosity because ...

 My fourth approach is to write my own bloody undo manager and have done with 
 it. Result so far - bliss.

I think that's a perfectly reasonably thing to have done. The functionality 
described by the NSUndoManager docs certainly doesn't *seem* difficult to 
re-implement. I haven't tried it, but now you have, and you've pretty much 
verified that fact.

It's also interesting that the documentation:


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/UndoArchitecture/Articles/UndoManager.html#//apple_ref/doc/uid/2205-CJBDJCCJ

has this statement (in the overview):

 An undo manager collects all undo operations that occur within a single cycle 
 of the run loop, so that performing an undo reverts all changes that occurred 
 during the cycle.

Taken literally, that would seem to say that NSUndoManager's API contract 
doesn't support undo actions that span events. FWIW.


___

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: NSPopUpButton questions

2009-12-06 Thread Andy Lee
On Dec 6, 2009, at 2:11 PM, Paul Bruneau wrote:
 On Dec 6, 2009, at 12:29 PM, Andy Lee wrote:
 Indeed, there are a few methods where the docs specifically recommend 
 accessing the menu directly, e.g.:
 
 http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPopUpButton_Class/Reference/Reference.html#//apple_ref/occ/instm/NSPopUpButton/insertItemWithTitle:atIndex:
 Since this method searches for duplicate items, it should not be used if 
 you are adding an item to an already populated menu with more than a few 
 hundred items. Add items directly to the receiver's menu instead.
 
 Yeah, but the OP is right, the Application Menu and Pop-up List Programming 
 Topics for Cocoa says this:
 
 To implement its menu, the button cell contains an NSMenu object, which in 
 turn contains several NSMenuItem objects, one for each item in the menu. 
 Avoid invoking methods on the NSMenu object directly, but instead invoke 
 methods on theNSPopUpButton instance, which may need to do some housekeeping 
 before invoking the appropriate methods on the menu. However, you can 
 retrieve the menu with the NSPopUpButton method menu. The NSPopUpButton 
 methods you use most often are the methods that tell you which item is 
 selected.
 
 http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MenuList/Articles/HowMenusWork.html

Come to think of it, I could have searched for NSPopUpButton housekeeping.  
In any case, might be worth filing a documentation request for clarification.

--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


Heap and memory zone queries

2009-12-06 Thread jonat...@mugginsoft.com
I have been using heap(1) to examine my apps heap. Small section for the 
auto_zone is shown. Queries follow.

Zone auto_zone_0x2f6000: 70460 nodes (53237600 bytes) 

COUNT BYTES   AVG   CLASS_NAME  
 TYPEBINARY
= =   ===   ==  
 ==
21999  413223041878.4   non-object  
   
13643   9837536 721.1   NSCFString  
 ObjCCoreFoundation
 4928236544  48.0   NSCFDictionary  
 ObjCFoundation
 4846 77536  16.0   NSCFNumber  
 ObjCFoundation
 4455161344  36.2   NSCFArray   
 ObjCFoundation
 1684242496 144.0   CTRun   
 CFType  CoreText  
  828169072 204.2   NSCFData
 ObjCFoundation
  681 43584  64.0   NSBitmapImageRep
 ObjCAppKit
  595 57120  96.0   NSConcretePointerArray  
 ObjCFoundation
  593132832 224.0   _NSViewAuxiliary
 ObjCAppKit
  584 37376  64.0   NSKeyValueObservance
 ObjCFoundation
  548 17536  32.0   NSCFSet 
 ObjCFoundation
  421 20208  48.0   _NSImageAuxiliary   
 ObjCAppKit
  421 13472  32.0   NSImage 
 ObjCAppKit
  406 19488  48.0   NSCellAuxiliary 
 ObjCAppKit
  351 11232  32.0   NSCalibratedRGBColor
 ObjCAppKit  

My app loads up some text and displays it in a couple of NSTextViews.
The text occupies about 6MB.
Loading the text increase real memory usage by about 50MB.

1. GC is on. Does that mean that all allocations invocation by NS*/CF* will be 
in the auto_zone?
2. Are the allocations accomplished using NSZoneMalloc and CFAllocatorAllocate?
3. grepping the heap(1) output shows little data allocated to NSText* 
instances. Is some of the 40MB of non-object data allocated by the NSText 
system? for glyph storage?
4. If 3 is not utterly incorrect - why isn't the memory utilised by  the NSText 
system flagged as being allocated by NSText*.

I thought that looking at the source for CFAllocatorAllocate() might be 
illuminating but it's not part of the open source CFLite release.

Regards

Jonathan Mitchell

Developer
http://www.mugginsoft.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: Best way to hook into the run loop?

2009-12-06 Thread Graham Cox
It's not just me running into undo problems - ironically just got this from 
Xcode (requiring quit and relaunch to recover) while trying to build after 
tweaking my undo manager source:

Internal error occurred while creating dependency graph: _registerUndoObject:: 
NSUndoManager 0x3befcb10 is in invalid state, must begin a group before 
registering undo.

(Why it needs to register with Undo while building the dependency graph is 
another question - it's not as if you can undo that or would want to).

On 07/12/2009, at 7:00 AM, Quincey Morris wrote:

 I tried it but it doesn't work. I forget the details now as this was my 
 first approach and that was a long time ago, but basically the undo manager 
 didn't tolerate having groups deferred until a task was actually received. 
 It would crash, but without the code, I couldn't say why .
 
 I'm not sure I understand this point. Are you talking about a situation with 
 'setGroupsByEvent:YES' or 'setGroupsByEvent:NO'? Either way, an explicit call 
 to 'beginUndoGrouping:' is *by definition* deferred, since it obviously can't 
 happen the instant an event is dequeued. The length of time between dequeuing 
 an event and invoking an undo manager method seems irrelevant. But I ask 
 mainly out of curiosity because ...


I think my understanding of how groups by event works was shaky at the time, so 
it's possible that I did something silly. Quite likely in fact. The deferrment 
was in a subclass of course, and it was in the situation where groupsByEvent 
was NO, and I wanted to group a bunch of drags. I set a flag on 
-beginUndoGrouping but did not call super. Then when a task was received from a 
drag change, if the flag was set I called super's -beginUndoGrouping just in 
time. That's when it crashed if I recall correctly.

 An undo manager collects all undo operations that occur within a single 
 cycle of the run loop, so that performing an undo reverts all changes that 
 occurred during the cycle.
 
 Taken literally, that would seem to say that NSUndoManager's API contract 
 doesn't support undo actions that span events. FWIW.

Yes, which does make me wonder how others have implemented undo of drags in 
general. Is there a simple solution staring me in the face and I just can't see 
it?

I think I'm in a drag-induced stupor, but if I can get this to work elegantly 
perhaps I could be a drag artist ;-)

--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: Best way to hook into the run loop?

2009-12-06 Thread Markus Spoettl
On Dec 7, 2009, at 12:12 AM, Graham Cox wrote:
 Yes, which does make me wonder how others have implemented undo of drags in 
 general. Is there a simple solution staring me in the face and I just can't 
 see it?


I believe the problems with multi-event undoing stem from the fact the you 
implemented the undo as a feature of the model when it could in fact be a 
controller feature - or another controller's whole purpose. 

While the model can't know why a certain key changed its value unless you give 
it more information than it really should have, a controller - let's say 
overseeing mouse handling - would know what is going on and could act 
accordingly. I'm not saying that things would be easier generally, but it 
doesn't necessarily have to be the model that cares about undo.

In my app it is the model that handle undo, btw. :)

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

unrecognized selector error when calling -stringValue on NSNumber

2009-12-06 Thread Mazen M. Abdel-Rahman
Hi all,

I am getting a very confusing error when I try to send a -stringValue message 
to an NSNumber object.  Here is my code:

NSNumber * primaryLanguageNumber = [self primaryLanguageID];
NSString * primaryLanguageString = [primaryLanguageNumber stringValue];

primaryLanguageID is of type NSNumber.  When I am stepping through the debugger 
I can see the variable primaryLanguageNumber being set correctly.  However, 
once I try to call stringValue on it I get the following error:

2009-12-06 16:51:24.525 Averroes[21013:a0f] -[NSCFString stringValue]: 
unrecognized selector sent to instance 0x1001d8a70

Doesn't that mean that it thinks primaryLanguageNumber is a string?  And why 
would it see it as a string?

Thanks for your help!
Mazen Abdel-Rahman
___

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: NSTextView Horizontal Scrollbar bug

2009-12-06 Thread Ross Carter
On Dec 5, 2009, at 9:14 AM, Eric Gorr wrote:

 On Dec 4, 2009, at 12:30 PM, Ross Carter wrote:
 
 On Dec 4, 2009, at 9:29 AM, Eric Gorr wrote:
 
 I've got a sample application at 
 http://ericgorr.net/cocoadev/TextViewNoWrap.zip which demonstrates the 
 problem I am seeing.
 
 Basically, there is just a text view on a window with a horizontal 
 scrollbar which appears only when needed.
 
 I have set this text view up based on the instructions found in the Text 
 System User Interface Layer Programming Guide for Cocoa (page 18 - Setting 
 Up a Horizontal Scroll Bar).
 
 After ~77 characters or so, the horizontal scrollbar stops scrolling and I 
 can't make any of the text beyond that visible in my view. 
 
 This looks like a bug to me and one that is likely already known.
 
 Are there any known or suggested workarounds?
 
 In IB you have set the maximum width of the text view to 478, so that is the 
 limit you are running up against.
 
 What is the suggested or common solution?
 
 I noticed, for example, the the height of the text view is set to 1,000,000 
 pixels and that if I set it to 478 a similar problem occurs.
 
 So, this implies one solution would be to simply set the width of the view to 
 the arbitrarily large value of 1,000,000 pixels as well.
 
 So, the question becomes, why not just set it to FLT_MAX (or should it be 
 CGFloat_Max?) - the same size as the text container?
 
 At this size, the scrollbars continue to work as one would expect. What I 
 don't know is if there would be unexpected side effects or problems using 
 FLT_MAX.
 
 By using FLT_MAX, and the same is likely true of 1,000,000 pixels, there 
 would not seem to be a practical reason to worry about calculating how wide 
 the text view needs to be to be able to scroll to all of the text. I can just 
 set it once and forget about it. Would you agree?

It's hard to say what is best in general, but IMHO there ought to be a 
practical limit to the width. I cannot imagine why anyone would want to keep 
scrolling and scrolling to the right to read all of one line of text, and then 
go back all the way to the left and start scrolling again to read the next 
line. The requirements of the particular application might call for a very wide 
text view, but at some point it is going to become too difficult to scroll 
without annoyance.

For height, FLT_MAX is convenient because the vertical scroll is determined by 
the size of the text content, and the text system will use only as much height 
as necessary. For width, FLT_MAX is not so convenient, because width is 
determined by the longest line, and if a few lines are significantly longer 
than others, then most of the scrollview area will be empty white space. OTOH, 
if all lines are same width (e.g., monospaced font showing results of a SQL 
query), then it might make sense to set the width to a large value. It just 
depends on what text you are presenting and how the user will want to view it.

-Ross
___

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: unrecognized selector error when calling -stringValue on NSNumber

2009-12-06 Thread Dave Carrigan

On Dec 6, 2009, at 3:58 PM, Mazen M. Abdel-Rahman wrote:

 
 NSNumber * primaryLanguageNumber = [self primaryLanguageID];
 NSString * primaryLanguageString = [primaryLanguageNumber stringValue];
 
 primaryLanguageID is of type NSNumber.  When I am stepping through the 
 debugger I can see the variable primaryLanguageNumber being set correctly.  
 However, once I try to call stringValue on it I get the following error:

We would need to see the source code for -primaryLanguageID

It's most likely returning a NSString, not a NSNumber.

-- 
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA

___

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: unrecognized selector error when calling -stringValue on NSNumber

2009-12-06 Thread Joar Wingfors

On 6 dec 2009, at 15.58, Mazen M. Abdel-Rahman wrote:

 2009-12-06 16:51:24.525 Averroes[21013:a0f] -[NSCFString stringValue]: 
 unrecognized selector sent to instance 0x1001d8a70
 
 Doesn't that mean that it thinks primaryLanguageNumber is a string?  And why 
 would it see it as a string?


It doesn't think it is a string, it is a string. The most likely cause for this 
type of problem is a memory management error in your -primaryLanguageID method, 
where the object you returned has been deallocated, and a new object (here a 
string) has taken its place in memory. The second most likely cause is that 
you're simply returning the wrong type of object.

j o a r


___

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: Heap and memory zone queries

2009-12-06 Thread Andrew Farmer
On 6 Dec 2009, at 13:57, jonat...@mugginsoft.com wrote:
 1. GC is on. Does that mean that all allocations invocation by NS*/CF* will 
 be in the auto_zone?

Not necessarily. AppKit and CoreFoundation objects are still capable of 
allocating unmanaged memory (via malloc(), for instance) for their use under 
garbage collection, so long as they clean it up when they're done with it.

 2. Are the allocations accomplished using NSZoneMalloc and 
 CFAllocatorAllocate?

Not sure on this one - I'll defer to someone more knowledgable.

 3. grepping the heap(1) output shows little data allocated to NSText* 
 instances. Is some of the 40MB of non-object data allocated by the NSText 
 system? for glyph storage?`
 4. If 3 is not utterly incorrect - why isn't the memory utilised by  the 
 NSText system flagged as being allocated by NSText*.

All that #3 means is that the NSText objects themselves are small. heap(1) is 
relatively simplistic - it can't determine that one allocated object belongs 
to another. If a NSText object allocates a bunch of CTRun objects (for 
instance), those allocation will be billed against CTRun, not 
NSText.___

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: unrecognized selector error when calling -stringValue on NSNumber

2009-12-06 Thread Mazen M. Abdel-Rahman
Thanks!  I found the problem - it is being assigned from a ComboBox - and the 
datasource for the ComboBox was returning a string  - so I just had to change 
it to return a number.

Bad mistake on my part.

Thanks,
Mazen

On Dec 6, 2009, at 5:31 PM, Joar Wingfors wrote:

 
 On 6 dec 2009, at 15.58, Mazen M. Abdel-Rahman wrote:
 
 2009-12-06 16:51:24.525 Averroes[21013:a0f] -[NSCFString stringValue]: 
 unrecognized selector sent to instance 0x1001d8a70
 
 Doesn't that mean that it thinks primaryLanguageNumber is a string?  And why 
 would it see it as a string?
 
 
 It doesn't think it is a string, it is a string. The most likely cause for 
 this type of problem is a memory management error in your -primaryLanguageID 
 method, where the object you returned has been deallocated, and a new object 
 (here a string) has taken its place in memory. The second most likely cause 
 is that you're simply returning the wrong type of object.
 
 j o a r
 
 

___

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: unrecognized selector error when calling -stringValue on NSNumber

2009-12-06 Thread Quincey Morris
On Dec 6, 2009, at 15:58, Mazen M. Abdel-Rahman wrote:

 NSNumber * primaryLanguageNumber = [self primaryLanguageID];
 NSString * primaryLanguageString = [primaryLanguageNumber stringValue];
 
 primaryLanguageID is of type NSNumber.  When I am stepping through the 
 debugger I can see the variable primaryLanguageNumber being set correctly. 
 However, once I try to call stringValue on it I get the following error:
 
 2009-12-06 16:51:24.525 Averroes[21013:a0f] -[NSCFString stringValue]: 
 unrecognized selector sent to instance 0x1001d8a70
 
 Doesn't that mean that it thinks primaryLanguageNumber is a string?  And why 
 would it see it as a string?

It's seeing it as a string because it *is* a string. That is precisely what the 
error message is telling you -- that the class of the receiver is NSCFString 
instead of whatever you intended it to be.

There's one fairly obvious scenario that causes this to happen. If you have a 
text field that modifies the primaryLanguageID property via a binding, and you 
edit the text field, then the new value will be a NSString regardless of 
whether the original value was a NSNumber (or anything else). If you  want the 
modified property to be kept as a NSNumber, you must put a numeric formatter on 
the text field. (Or, if it's part of a table view, then you must put a numeric 
formatter on the column's text field cell.) (Or, write a setter for the 
primaryLanguageID property that takes a NSString parameter but stores a 
NSNumber in the instance variable.)


___

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


Draw rounded NSImage

2009-12-06 Thread John Wright
I am trying to create a NSImage or NSImageCell with rounded corners
inside a NSTableView. I can't get anything to work. Here is the best I
have so far inside my custom NSCell:

- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView {
  if (thumbnailLink) {
        NSURL *url = [NSURL URLWithString:thumbnailLink];
        if (url) {
                NSRect imageFrame = [self _imageFrameForInteriorFrame:frame];
                NSImage *image = [[NSImage alloc] initWithContentsOfURL:url];
                [image setScalesWhenResized:YES];
                [image setSize:NSMakeSize(IMAGE_HEIGHT, IMAGE_WIDTH)];

                [NSGraphicsContext saveGraphicsState];
                imageFrame = NSInsetRect(imageFrame, 1, 1);
                NSBezierPath *clipPath = [NSBezierPath
bezierPathWithRoundedRect:imageFrame cornerRadius:5.0];
                [clipPath setWindingRule:NSEvenOddWindingRule];
                [clipPath addClip];
                [NSGraphicsContext restoreGraphicsState];
                [image drawInRect:imageFrame fromRect:NSMakeRect(0, 0,
0, 0) operation:NSCompositeSourceIn fraction:1.0];
                [image release];
        }
}
...

Any ideas on how to do this?.

Thanks,

John
___

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


Problem setting to-one relationship on NSManagedObject

2009-12-06 Thread Jim Majure
I'm using the following code to create a new Core Data entity and  
populate a to-one relationship. Everything seems to be working okay  
except the setValue:forKey: to establish the to-one relationship.  
I've included the error messages below. Any ideas what I might be  
doing wrong?


Thanks,
Jim

NSManagedObject *newTimeEntry = [NSEntityDescription
insertNewObjectForEntityForName:@TimeEntry
		inManagedObjectContext:[selectProjectController  
managedObjectContext]];

NSManagedObject *project = [selectProjectController selection];

[newTimeEntry setValue:project forKey:@project];



2009-12-04 17:32:58.833 Checkbook[1270:a0f] -[_NSControllerObjectProxy  
managedObjectContext]: unrecognized selector sent to instance 0x101efa0
2009-12-04 17:32:58.834 Checkbook[1270:a0f] -[_NSControllerObjectProxy  
managedObjectContext]: unrecognized selector sent to instance 0x101efa0


___

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 reloadData works just on init.

2009-12-06 Thread Alberto Piu

Hi all,

I'm writing on this mailing list because I can't get an NSTableView to  
display data.
I have a NSTableView in my xib, connected to a NSObject controller.  
dataSource is my controller, and the IBOutlet is correctly connected  
to the NSTableView.


This is my header


//
//  ShortcutsTableController.h
//

#import Cocoa/Cocoa.h


@interface ShortcutsTableController : NSObject  
NSTableViewDataSource {

IBOutlet NSTableView *shortcutsTable;
NSMutableArray *shortcutsList;
}

@property (assign) IBOutlet NSTableView *shortcutsTable;

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn: 
(NSTableColumn *)tableColumn row:(int)row;
- (void)addItem:(NSString *)name :(NSString *)shortcut :(NSString *) 
action;

- (void)reloadData;
@end



And this is my implementation file.


//
//  ShortcutsTableController.m
//

#import ShortcutsTableController.h

@implementation ShortcutsTableController

@synthesize shortcutsTable;

- (id)init
{
self = [super init];
if (self != nil) {
shortcutsList = [[NSMutableArray alloc] init];
shortcutsTable = [[NSTableView alloc] init];
[shortcutsTable setDataSource:self];

[self reloadData];
}
return self;
}

- (void)addItem:(NSString *)name :(NSString *)shortcut :(NSString *) 
action {


NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
   name, @nameColumn,
   shortcut, @shortcutColumn,
   action, @actionColumn, nil];

[shortcutsList addObject:dict];

NSLog(@%@, shortcutsTable);
NSLog(@%@, shortcutsList);
[self reloadData];
}

- (void)reloadData {
[shortcutsTable reloadData];
}

-(NSInteger) numberOfRowsInTableView: (NSTableView *) tableView {
return [shortcutsList count];
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn: 
(NSTableColumn *)tableColumn row:(int)row {

if (row != -1)
return [[shortcutsList objectAtIndex:row] objectForKey: 
[tableColumn identifier]];


return nil;
}

@end



I can't display data in this TableView using addItem method. If I call  
addItem from the init method all goes as expected, otherwise the  
tableView is not updated. I don't know what's my mistake.

You know what's going wrong?
If yes, please help me. Your help would be very appreciated.

Sweet day,
—Albé___

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


MacBook with USB GPS dongle and Core Location

2009-12-06 Thread Jeff Heard
I have a little GPS dongle that I have attached to my MacBook.  Obviously I can 
access it via the serial port and read the NMEA strings directly from there, 
but I was wondering if it was possible to tie it into the Core Location API for 
a cleaner and more Apple-like way to get at the data?  

-- Jeff___

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


SSH in my application

2009-12-06 Thread Timofey Danshin
Hi. I've been hoping to write a number of applications that would be GUIs
for some command line tools on a remote FreeBSD machine. The only problem is
that i can't connect to it via SSH.
I have googled this issue, and found some scenarios for username/password
authorization, but I use RSA authorization, and they don't work for me.
I am still contemplating using libssh, but it seems quite complex for me, so
if there are any other alternatives, i'd be grateful.

Thank you in advance.

-- 
Best Regards,
Timofey Danshin.
___

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


Localizing Xibs using bindings

2009-12-06 Thread Rossi Matteo
I find it very annoying to localize Xibs by keeping a copy for each  
translation. It's both tedious and error-prone.
I've found that by simply binding each button's title (or wharever  
other control you need) to the appropriate key of a NSDictionary  
object I can easily localize each item.
No need to create tons of outlets for each control. Indeed I have no  
outlet at all. It works smoothly and I can send only .strings files to  
my translators.
Since I haven't found no article on this solution, I was wondering if  
it's wrong or which problems may arise.
Obvously I take care to keep control sizes large enough to host each  
translation.

___

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: Draw rounded NSImage

2009-12-06 Thread Gideon King
Your code restores the graphics state, which will remove your rounded rect 
clipping path, before you draw the image.

If you draw the image before restoring the graphics state, you should be OK.

Also you should not need to explicitly set the winding rule.

HTH

Gideon

On 05/12/2009, at 7:22 AM, John Wright wrote:

 I am trying to create a NSImage or NSImageCell with rounded corners
 inside a NSTableView. I can't get anything to work. Here is the best I
 have so far inside my custom NSCell:
 
 - (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView {
   if (thumbnailLink) {
 NSURL *url = [NSURL URLWithString:thumbnailLink];
 if (url) {
 NSRect imageFrame = [self _imageFrameForInteriorFrame:frame];
 NSImage *image = [[NSImage alloc] initWithContentsOfURL:url];
 [image setScalesWhenResized:YES];
 [image setSize:NSMakeSize(IMAGE_HEIGHT, IMAGE_WIDTH)];
 
 [NSGraphicsContext saveGraphicsState];
 imageFrame = NSInsetRect(imageFrame, 1, 1);
 NSBezierPath *clipPath = [NSBezierPath
 bezierPathWithRoundedRect:imageFrame cornerRadius:5.0];
 [clipPath setWindingRule:NSEvenOddWindingRule];
 [clipPath addClip];
 [NSGraphicsContext restoreGraphicsState];
 [image drawInRect:imageFrame fromRect:NSMakeRect(0, 0,
 0, 0) operation:NSCompositeSourceIn fraction:1.0];
 [image release];
 }
 }
 ...
 
 Any ideas on how to do this?.

___

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: Draw rounded NSImage

2009-12-06 Thread Matt Neuburg
On or about 12/6/09 8:11 PM, thus spake cocoa-dev-requ...@lists.apple.com
cocoa-dev-requ...@lists.apple.com:

 Date: Fri, 4 Dec 2009 14:22:04 -0700
 From: John Wright mrjjwri...@gmail.com
 Subject: Draw rounded NSImage
 
 I am trying to create a NSImage or NSImageCell with rounded corners
 inside a NSTableView. I can't get anything to work. Here is the best I
 have so far inside my custom NSCell:
 
 - (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView {
   if (thumbnailLink) {
         NSURL *url = [NSURL URLWithString:thumbnailLink];
         if (url) {
                 NSRect imageFrame = [self _imageFrameForInteriorFrame:frame];
                 NSImage *image = [[NSImage alloc] initWithContentsOfURL:url];
                 [image setScalesWhenResized:YES];
                 [image setSize:NSMakeSize(IMAGE_HEIGHT, IMAGE_WIDTH)];
 
                 [NSGraphicsContext saveGraphicsState];
                 imageFrame = NSInsetRect(imageFrame, 1, 1);
                 NSBezierPath *clipPath = [NSBezierPath
 bezierPathWithRoundedRect:imageFrame cornerRadius:5.0];
                 [clipPath setWindingRule:NSEvenOddWindingRule];
                 [clipPath addClip];
                 [NSGraphicsContext restoreGraphicsState];
                 [image drawInRect:imageFrame fromRect:NSMakeRect(0, 0,
 0, 0) operation:NSCompositeSourceIn fraction:1.0];
                 [image release];
         }
 }

You're clipping in a different graphics context from the one you draw the
image in, so the clipping doesn't affect the image. Look at the clipping
example on this page:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaD
rawingGuide/GraphicsContexts/GraphicsContexts.html

Notice how the isolation of the graphics context surrounds both the clipping
and the image drawing.

In your example, though, since the clipping and the image are all the
drawing you're doing, there's no need to isolate a graphics context in any
case.

m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring  Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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: Carbon menus in Cocoa app

2009-12-06 Thread Vikram Sethi
I had some offline discussion with Eric around this. The problem was that I
had stopped calling RunApplicationEventLoop() function, which installs an
event handler that calls MenuSelect() in response to clicks on the menu bar.
When I switched to Cocoa, MenuSelect() was not getting called. As a
solution, I need to call MenuSelect() explicitly when the menu bar is
clicked. This solves the problem.

Thanks for all the help.

Regards,
Vikram Sethi

On Wed, Dec 2, 2009 at 12:08 AM, Eric Schlegel eri...@apple.com wrote:


 On Nov 30, 2009, at 5:03 AM, Vikram Sethi wrote:

  Though the menu bar appears and the individual menu items get created and
  get added to the hierarchy (verified it while debugging), the menus do
 not
  open when I click on the menu bar. The menus are also Carbon based. They
 are
  defined as a ‘MBAR’ resource and the menu bar gets created using the
  GetNewMBar() API. This API has been marked ‘Not recommended’ though it is
  not deprecated. Documentation says use NIB files instead.
 
  I tried similar changes in another Carbon based app. This app opened fine
  and I was able to access the menus also. Unlike my app, this ref app
 defines
  the menus in a NIB file and creates the menu bar using the NIB file.

 I would not actually expect that there would be any difference in the
 behavior of the two applications based solely on how the menus are created.
 Regardless of whether you create your menus from an 'MBAR' or from a nib,
 once the menus are created, they should behave the same at runtime. It
 sounds to me that there is some other difference in the event-handling
 process of the two applications, which probably could be fixed in your real
 application without needing to move to nib files.

 Can you send me copies of both the working and non-working applications and
 I'll see what the difference is?

 -eric




-- 
Ξ √ί...@m Ŝεth! Ξ
___

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 reloadData works just on init.

2009-12-06 Thread Nick Zitzmann

On Dec 5, 2009, at 5:22 AM, Alberto Piu wrote:

shortcutsTable = [[NSTableView alloc] init];

There are several problems here:

1. The designated initializer of views is -initWithFrame:, not -init.

2. Even if you got that right, it would still not work, because you are 
resetting the pointer to the table view object to a brand new object. The table 
view object you probably want to address is freeze-dried in the nib, and will 
be connected once the nib is loaded, and so you shouldn't overwrite the pointer 
with something else unless you want to programmatically get rid of it and 
create a new one (if you're working on a dynamic interface, for instance).

3. Even if you corrected that, you can't send messages to objects connected by 
IB outlet in -init, because it's most likely that the nib has not been loaded 
yet unless you explicitly loaded it there. If you need to initialize things in 
the UI, then you should do that in -awakeFromNib instead.

HTH...

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


Services Menu Heading

2009-12-06 Thread Gerriet M. Denkmann
I have an app which offers an NSService.
Works fine so far.

But: 
I want this service to appear in the Services Menu under the Searching 
Header, together with Look Up in Dictionary and Search With Google.
(Currently it appears under Text)

So I checked the Info.plist of both Dictionary.app and Safari.app but could not 
find anything under NSServices which is different from my Info.plist.

I also tried the + button in System Preferences → Keyboard → Keyboard 
Shortcuts → Services; a sheet is displayed, I can enter all relevant data, but 
the Add button remains disabled.

What magic incantations do I have to perform to make my service appear under 
it's appropiate heading ?

10.6.2


Kind regards,

Gerriet.

___

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: Services Menu Heading

2009-12-06 Thread Kyle Sluder
On Sun, Dec 6, 2009 at 8:38 PM, Gerriet M. Denkmann
gerr...@mdenkmann.de wrote:
 What magic incantations do I have to perform to make my service appear under 
 it's appropiate heading ?

The heading is determined by what UITs your service accepts.  There
are certain hardcoded exceptions to this rule.  This is an area in
which Apple has acknowledged needs improvement; file an enhancement
request about what you'd like to see.

--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: SSH in my application

2009-12-06 Thread Kyle Sluder
On Sat, Dec 5, 2009 at 8:57 AM, Timofey Danshin
rus.mcdevelo...@gmail.com wrote:
 Hi. I've been hoping to write a number of applications that would be GUIs
 for some command line tools on a remote FreeBSD machine. The only problem is
 that i can't connect to it via SSH.

This statement is virtually meaningless. What are you doing, what
happens, and what have you tried?

 I have googled this issue, and found some scenarios for username/password
 authorization, but I use RSA authorization, and they don't work for me.

Are you shelling out to ssh(1) or something?  You need to provide
detail, and that includes posting your source code.

 I am still contemplating using libssh, but it seems quite complex for me, so
 if there are any other alternatives, i'd be grateful.

I always hate hacking things on top of SSH.  Perhaps you can go with a
raw TLS connection instead?  Hook up netcat on the receiving end to
pipe into the program(s) you wish to control, that way you don't
involve a shell.

--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: Services Menu Heading

2009-12-06 Thread Nick Zitzmann

On Dec 6, 2009, at 9:38 PM, Gerriet M. Denkmann wrote:

 What magic incantations do I have to perform to make my service appear under 
 it's appropiate heading ?

You need to set the undocumented key NSServiceCategory in the 
NSRequiredContext dictionary if the Keyboard preference pane misinterprets your 
service's function. See 
http://github.com/nickzman/symboliclinker/blob/master/SymbolicLinkerService-Info.plist
 for an example of how I did this in SymbolicLinker; I seem to recall that the 
preference pane threw the service into the Other category until I added that 
key-value...

Yes, I have a bug open on this (#7213062)...

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: Services Menu Heading

2009-12-06 Thread Kyle Sluder
It's good list etiquette to keep replies on-list.

On Sun, Dec 6, 2009 at 9:55 PM, Gerriet M. Denkmann
gerr...@mdenkmann.de wrote:
 Yes, but Dictionary and Safari just have NSSendTypes = NSStringPboardType (no 
 UTIs at all) and appear under the correct heading.

Like I said, there are hardcoded exceptions.

 Any ideas what UTI I micht have to add?

I don't think there are any UTIs you can add for the Searching category.

--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: Problem setting to-one relationship on NSManagedObject

2009-12-06 Thread Kyle Sluder
On Fri, Dec 4, 2009 at 3:37 PM, Jim Majure jim.maj...@mac.com wrote:
        NSManagedObject *project = [selectProjectController selection];
        [newTimeEntry setValue:project forKey:@project];

As per the documentation, -selection returns a KVC-compliant proxy
object.  You can't turn around and hand that off to Core Data as if it
were a full-fledged instance.  Use -selectedObjects instead.

--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: Services Menu Heading

2009-12-06 Thread Gerriet M. Denkmann

On 7 Dec 2009, at 12:54, Nick Zitzmann wrote:

 
 On Dec 6, 2009, at 9:38 PM, Gerriet M. Denkmann wrote:
 
 What magic incantations do I have to perform to make my service appear under 
 it's appropiate heading ?
 
 You need to set the undocumented key NSServiceCategory in the 
 NSRequiredContext dictionary if the Keyboard preference pane misinterprets 
 your service's function. See 
 http://github.com/nickzman/symboliclinker/blob/master/SymbolicLinkerService-Info.plist
  for an example of how I did this in SymbolicLinker; I seem to recall that 
 the preference pane threw the service into the Other category until I added 
 that key-value...


Following your example I added an NSRequiredContext  with NSServiceCategory = 
public.item and now my service appears under  Files and Folders. Which proves:
1. NSRequiredContext has some effect and:
2. public.item  ist NOT the right thing so use. But what is? 
string.to.look.up.in.some.dictionary sounds not quite right.

Any ideas?


Kind regards,

Gerriet.

___

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: Services Menu Heading

2009-12-06 Thread Nick Zitzmann

On Dec 6, 2009, at 11:10 PM, Gerriet M. Denkmann wrote:

 2. public.item  ist NOT the right thing so use. But what is? 
 string.to.look.up.in.some.dictionary sounds not quite right.

IIRC I asked about this before, and the reply I got said that there isn't a UTI 
or old-school pasteboard type for searching, and maybe one or two other 
categories. So Kyle is most likely correct that the items you see are 
hard-coded...

You should probably file a bug and choose an alternate category. If your 
concern is the Very Serious Users will not take your software Very Seriously 
because there is a better category, then I would advise you not to worry about 
this...

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: Services Menu Heading

2009-12-06 Thread Gerriet M. Denkmann

On 7 Dec 2009, at 13:15, Nick Zitzmann wrote:

 
 On Dec 6, 2009, at 11:10 PM, Gerriet M. Denkmann wrote:
 
 2. public.item  ist NOT the right thing so use. But what is? 
 string.to.look.up.in.some.dictionary sounds not quite right.
 
 IIRC I asked about this before, and the reply I got said that there isn't a 
 UTI or old-school pasteboard type for searching, and maybe one or two other 
 categories. So Kyle is most likely correct that the items you see are 
 hard-coded...


Well, after some desperate trial  error I came up with:
NSServiceCategary = Searching, which seems to work. Kind of obvious once found. 
Some documentation would have been even better (and would have saved me some 
time).

Thanks to you and Kyle for your help.


Kind regards,

Gerriet.

___

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: Services Menu Heading

2009-12-06 Thread Kyle Sluder
On Sun, Dec 6, 2009 at 10:24 PM, Gerriet M. Denkmann
gerr...@mdenkmann.de wrote:
 NSServiceCategary = Searching, which seems to work. Kind of obvious once 
 found. Some documentation would have been even better (and would have saved 
 me some time).

Apple obviously hasn't nailed down the Services stuff yet, as
evidenced by the disappearing of the app icons in the Services menu
(and their replacement with vastly inferior, ugly text strings).  So
don't be surprised if they take this functionality away.  I imagine it
is undocumented partly because Apple doesn't want a proliferation of
categories, making them useless.

File bugs anyway, since this is still in flux we should strike while
the iron is hot!

--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


breakout game - openGL or quartz?

2009-12-06 Thread Patrick J. Collins
Hi everyone,

I wrote a breakout style game for actionscript3:
http://collinatorstudios.com/dev/super_collins_breakout

and it's been on my mind to make a version for the iPhone..  But before I do
that, I thought it would be good to just make a version for plain old OS X...
So before I do this, I wanted to ask the opinions of every one here--  Should I
use OpenGL or quartz/core animation for my graphics drawing?  I am thinking
that I want to use OpenGL-- even though the game is 2D, I still would like to
be able to do gradients and shading and glowing, etc..  Which I am assuming
isn't going to be as easy to accomplish with quartz/core animation.

Also if anyone recommends any particular books or online tutorials for learning
how to draw simple rectangles and spheres, and make them glow, etc, that would
be great.

Thanks!

Patrick J. Collins
http://collinatorstudios.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: breakout game - openGL or quartz?

2009-12-06 Thread Seth Willits
On Dec 6, 2009, at 10:48 PM, Patrick J. Collins wrote:

 So before I do this, I wanted to ask the opinions of every one here--  Should 
 I
 use OpenGL or quartz/core animation for my graphics drawing?

OpenGL. Come join the party:
http://www.idevgames.com/forum/


--
Seth Willits



___

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: breakout game - openGL or quartz?

2009-12-06 Thread Nick Zitzmann

On Dec 6, 2009, at 11:48 PM, Patrick J. Collins wrote:

 and it's been on my mind to make a version for the iPhone..  But before I do
 that, I thought it would be good to just make a version for plain old OS X...
 So before I do this, I wanted to ask the opinions of every one here--  Should 
 I
 use OpenGL or quartz/core animation for my graphics drawing?

This thread is probably going to go OT, but I'd recommend OpenGL. There are 
plenty of examples of great 2D games that were implemented using a 3D API of 
some sort; World of Goo immediately comes to mind.

 Also if anyone recommends any particular books or online tutorials for 
 learning
 how to draw simple rectangles and spheres, and make them glow, etc, that would
 be great.

http://nehe.gamedev.net/

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: breakout game - openGL or quartz?

2009-12-06 Thread Chunk 1978
cool game, patrick.  i especially liked your sound.

On Mon, Dec 7, 2009 at 2:05 AM, Nick Zitzmann n...@chronosnet.com wrote:

 On Dec 6, 2009, at 11:48 PM, Patrick J. Collins wrote:

 and it's been on my mind to make a version for the iPhone..  But before I do
 that, I thought it would be good to just make a version for plain old OS X...
 So before I do this, I wanted to ask the opinions of every one here--  
 Should I
 use OpenGL or quartz/core animation for my graphics drawing?

 This thread is probably going to go OT, but I'd recommend OpenGL. There are 
 plenty of examples of great 2D games that were implemented using a 3D API of 
 some sort; World of Goo immediately comes to mind.

 Also if anyone recommends any particular books or online tutorials for 
 learning
 how to draw simple rectangles and spheres, and make them glow, etc, that 
 would
 be great.

 http://nehe.gamedev.net/

 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/chunk1978%40gmail.com

 This email sent to chunk1...@gmail.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