How to get all directories and folders in Tree format

2009-03-11 Thread haresh vavdiya
Hi All,

In my application, i have to display all the directories and folders
of these directory on left side and user can reach their particular folder
and he can get all content of that folder. Like, we want to open Examples
folder and then we will select Developer and then example from list..

 Does anyone how can i develop this tings.

Thanks,
Haresh.
___

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


most suitable framework for network app communication?

2009-03-11 Thread Darren Minifie
Hi Everyone

I'm working on a music application for the Mac.  Eventually I wan to provide
an interface to it on an Iphone that is on the same local network.  It would
be similar to the Remote application Apple created for iTunes.  I'm
comfortable with socket programming in C, but I was hoping there would be an
easier way.  Being new to the Cocoa frameworks I was hoping somebody could
point me at a framework that could help with this communication?  Would
Bonjour be an option for this?  Thank you for your suggestions.

-- 
Darren Minifie
Graduate Studies: Computer Science
www.myavalon.ca
www.ohsnapmusic.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: most suitable framework for network app communication?

2009-03-11 Thread Scott Anguish

Bonjour would be an excellent way to find clients and servers, yes.

Have a look at NSStream, CFStream, and CFNetwork, NSNetServices,  
CFNetServices. They are all things you may want to consider using.


NSNetServices and CFNetServices Programming Guide
Bonjour Overview
Stream Programming Guide for Cocoa

Those guides will also get you started.


On 11-Mar-09, at 3:15 AM, Darren Minifie wrote:


Hi Everyone

I'm working on a music application for the Mac.  Eventually I wan to  
provide
an interface to it on an Iphone that is on the same local network.   
It would

be similar to the Remote application Apple created for iTunes.  I'm
comfortable with socket programming in C, but I was hoping there  
would be an
easier way.  Being new to the Cocoa frameworks I was hoping somebody  
could
point me at a framework that could help with this communication?   
Would

Bonjour be an option for this?  Thank you for your suggestions.


___

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

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

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

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


Is it possible to make the height of an NSSegmentedControl taller?

2009-03-11 Thread Stuart Malin
I am using an NSSegmentedControl in a toolbar to hold some mutually  
exclusive selections. I invoke -setImage:forSegment: to set an image  
for each, but the images are taller than the height of the segments.   
I don't seem to have any control over that height with the NSRect I  
use to init the segmented control.   I have set the segmentStyle to  
NSSegmentCapsuleStyle, which provides a bit more height.  I have tried  
scaling the images to fit (using -setImageScaling:forSegment) but then  
the images are too small. Is it possible to override something  
somewhere to affect the cells that are used?

___

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: KVO & Bindings: Proxy object & change notifications

2009-03-11 Thread Dave Keck
Hey Ken, thanks for your reply.

> Are you sure that PrefCtrl is returning the same proxy each time?

Yes. The proxy object is setup in PrefCtrl's -init, and is never changed.

> Also, at the time that you invoke -willChangeValueForKey: have you already
> changed your internal state such that invoking [theProxy
> valueForKey:@"someFeature"] returns the "after" value?  It should still
> return the "before" value at that point.  It must not return the "after"
> value until after the -willChangeValueForKey: call completes.

I'm changing the value of the 'someFeature' key after willChange, and
before didChange. That is, from the context of PrefCtrl:

// #1: value for 'someFeature' is nil at this point
[self willChangeValueForKey: @"values"];
// #2: value for 'someFeature' is still nil at this point
[valuesDictionary setValue: someFeature forKey: @"someFeature"];
// #3 value for 'someFeature' is NOT nil at this point
[self didChangeValueForKey: @"values"];
// #4 value for 'someFeature' is the same as point #3 (still not nil)

(Note that valuesDictionary is PrefCtrl's underlying backing store for
all the prefs.)

> That's what it's complaining about.  It's saying that [theProxy
> valueForKey:@"someFeature"] isn't the same object it was when the
> observation was established, so KVO can't unhook itself from the object it
> had earlier hooked into.  Note that it's attempting this unwinding during
> -willChangeValueForKey:.  Of course, that object won't be the same _after_
> -willChangeValueForKey: -- you are, after all, changing it -- but it needs
> it to be the same _at_ -willChangeValueForKey: for KVO's housekeeping to
> work.

I'm not sure if it's relevant, but does it matter that someFeature is
originally nil - I'm assuming it couldn't possibly have an observer
before I change the value to something non-nil...?

> Also, since KVO was watching the "someFeature" property of the proxy, and
> that property is different than it was, but KVO never noticed that it
> changed, it's reporting that the property changed in a non-KVO-compliant
> fashion.  Since you are using a proxy to front for your PrefCtrl, are you
> also making sure that all changes of PrefCtrl's properties cause change
> notifications for the proxy's virtual properties?  That is, are you
> forwarding all -will/didChange... invocations on your PrefCtrl object to
> your proxy, at least for keys other than "values"?

That's precisely my issue - because the prefs can be changed from
other processes, the app doesn't know which specific properties
changed - all it knows is that there was a change. Of course I could
find out what specific changes occurred by comparing the new prefs
with the old prefs, but I find it far more convenient just to issue a
blanket willChange/didChange: @"values". To emulate this situation, in
my example project I use the code above, which modifies PrefCtrl's
'valuesDictionary' backing store directly, surrounded by the
willChange/didChange: @"values". I've tried sending individual
willChange/didChange for every key that's in PrefCtrl - and it works -
I just don't understand why just sending willChange/didChange:
@"values doesn't (at least for a 3+ segment key path.) Again, the
example project that exhibits this issue is here:
http://www.docdave.com/kvo_project.zip

> You may be able to eliminate the proxy altogether, by the way.  Have you
> tried having the "values" property of the PrefCtrl object just return "self"
> -- the PrefCtrl object itself?  That would avoid the need to forward things
> in either direction, but still give you the ability to will/didChange... the
> "values" property to provoke a wholesale updating of all observers of any
> properties.  At least, I think that should work.

I decided to go the proxy route simply because PrefCtrl has some of
its own properties that I didn't want to get confused with actual
preferences... to me, it just seems cleaner.

Thanks!

David
___

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: KVO & Bindings: Proxy object & change notifications

2009-03-11 Thread Ken Thomases

On Mar 11, 2009, at 2:09 AM, Dave Keck wrote:

Also, at the time that you invoke -willChangeValueForKey: have you  
already

changed your internal state such that invoking [theProxy
valueForKey:@"someFeature"] returns the "after" value?  It should  
still
return the "before" value at that point.  It must not return the  
"after"

value until after the -willChangeValueForKey: call completes.


I'm changing the value of the 'someFeature' key after willChange, and
before didChange. That is, from the context of PrefCtrl:

   // #1: value for 'someFeature' is nil at this point
[self willChangeValueForKey: @"values"];
   // #2: value for 'someFeature' is still nil at this point
[valuesDictionary setValue: someFeature forKey: @"someFeature"];
   // #3 value for 'someFeature' is NOT nil at this point
[self didChangeValueForKey: @"values"];
   // #4 value for 'someFeature' is the same as point #3 (still not  
nil)


(Note that valuesDictionary is PrefCtrl's underlying backing store for
all the prefs.)


OK, so I poked at your example project some.  First, it seems I was  
wrong.  KVO doesn't unwind its observation bookkeeping during - 
willChange...; it apparently does it during -didChange


The problem is this.  You're telling KVO that the "values" property  
has changed.  So, during -didChange... it's trying to unwind its  
observation of the key sub-path "someFeature.isEnabled" from the old  
"values" value and then set up observation of that sub-path on the new  
"values".  The problem is that the old "values" is actually the new  
"values" so when KVO asks the old "values" for  
valueForKey:@"someFeature" it is not getting nil, it's getting the new  
object.  It then goes to cease observing "isEnabled" on that object  
and finds that it never was observing that object.


The problem is that old "values" and new "values" are really the same  
thing, while KVO wants to work with the old and new side by side  
simultaneously.  I'm guessing that It has saved the old "values"  
during the -willChange... call and then references it during the - 
didChange... call, expecting it to still be old.


This all makes sense if "values" were a more normal property.  There  
would be two different objects.  In your example, there's no good  
reason that the dictionary could not actually serve as the value of  
"values", although I gather that that doesn't serve your real  
application's needs.  Still, if it were done that way, then a change  
of the "values" property would mean replacing that dictionary with a  
different one, in which case KVO could continue to reference the old  
one during -didChange... (presuming it retained it during - 
willChange...).


Am I right that just using a dictionary for the "values" property  
doesn't meet your needs?  It would be a mutable dictionary and in many  
cases you'd change its member objects.  However, when there was an  
external change of the preferences, you might just load a new  
dictionary and replace the old one (using a normal, KVO-compliant  
setter).  That ought to work with KVO.


The problem with using dictionaries like this is that it violates  
encapsulation -- changes are made to the dictionary's contents without  
necessarily going through methods that you wrote.  So, you don't have  
an opportunity to respond to the change.  You can work around that by  
creating a simple wrapper class around a dictionary.  It would have  
roughly the same interface as NSMutableDictionary, and forward each  
call to the dictionary it uses as its backing store, but you would  
have the opportunity to intervene in each method if necessary.




I'm not sure if it's relevant, but does it matter that someFeature is
originally nil - I'm assuming it couldn't possibly have an observer
before I change the value to something non-nil...?


No, I don't think that's the issue you're currently seeing.  However,  
the AppKit release notes for 10.5 discussed a fix for a bug in 10.4  
about observing through a relationship that was originally nil.  If  
you plan to deploy to 10.4, you should check those notes.




Since you are using a proxy to front for your PrefCtrl, are you
also making sure that all changes of PrefCtrl's properties cause  
change

notifications for the proxy's virtual properties?  That is, are you
forwarding all -will/didChange... invocations on your PrefCtrl  
object to

your proxy, at least for keys other than "values"?


That's precisely my issue - because the prefs can be changed from
other processes, the app doesn't know which specific properties
changed - all it knows is that there was a change.


My point was about for the other cases.  Surely, there are some cases  
when the properties of PrefCtrl are changed internally, too, right?   
If so, then any change of one of those properties needs to appear to  
KVO as a change of a property of the proxy, so you would need to  
forward the -will/didChange... calls.


Regards,
Ken

___

Converting unicode strings to its values

2009-03-11 Thread Christian Netthöfel

Hi Everyone,

I'm quite new to Cocoa-development and have a question regarding the  
conversion of unicode-representations. I have a string containing the  
unicode values for umlauts or other special characters as strings.  
What I want to do  is to convert them to their real unicode value so  
that the characters are displayed.


Example:

"\u00d6" should become "ö"

Note that "\u00d6" is not the same as \u00d6, I hope you understand  
what I want do say :)


TIA
Christian___

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 make the height of an NSSegmentedControl taller?

2009-03-11 Thread Dave Keck
On Tue, Mar 10, 2009 at 10:04 PM, Stuart Malin  wrote:
> I am using an NSSegmentedControl in a toolbar to hold some mutually
> exclusive selections. I invoke -setImage:forSegment: to set an image for
> each, but the images are taller than the height of the segments.  I don't
> seem to have any control over that height with the NSRect I use to init the
> segmented control.   I have set the segmentStyle to NSSegmentCapsuleStyle,
> which provides a bit more height.  I have tried scaling the images to fit
> (using -setImageScaling:forSegment) but then the images are too small. Is it
> possible to override something somewhere to affect the cells that are used?

Try making your images smaller by using NSImage's setSize: method, or
the million other ways to scale images on OS X. Once you have an image
that's the right size, call -setImage:forSegment: with the scaled
image.

As far as resizing the NSSegmentedControl's height, there's no direct
way to do it (as far as I can see). I've never seen an
NSSegmentedControl that's a different height than stock anyway, so I
wouldn't recommend doing it simply 'cause it'll look weird :)

If you _really_ need a taller one, you could create your own custom
control. It wouldn't be too hard, but I recommend making your images
smaller to fit the stock control.

Dave
___

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

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

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

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


Re: Converting unicode strings to its values

2009-03-11 Thread Ken Thomases

On Mar 11, 2009, at 3:23 AM, Christian Netthöfel wrote:

I'm quite new to Cocoa-development and have a question regarding the  
conversion of unicode-representations. I have a string containing  
the unicode values for umlauts or other special characters as  
strings. What I want to do  is to convert them to their real unicode  
value so that the characters are displayed.


Example:

"\u00d6" should become "ö"


If a string literal in your source code actually contains the \u  
escape sequence, then that will be translated by the compiler.  The  
proper Unicode will end up in your binary.  (This wasn't true with  
earlier versions of gcc, but is true of the gcc that comes with Xcode  
3.x.)  I suspect you know that.


If you actually get a string which contains the backslash, lowercase  
'u', and hex digits, then you're going to have to parse that somewhat  
manually.  NSScanner will probably be helpful.  Once you get an  
integer from the hex digits, you can use NSString's character-based  
methods like + stringWithCharacters:length: or - 
initWithCharacters:length:.  Sadly, I don't see a method on  
NSMutableString for inserting or appending individual character codes  
into a string.


Be mindful that not every UTF-16 code point is valid Unicode in  
isolation.  Combining characters and surrogate pairs complicate  
things.  I don't know if the character-based methods validate the  
character sequence you provide to them.  They might.  So, you might  
need to convert an entire string at once, rather than attempting to  
just create an NSString from a single unichar derived from a \u  
escape sequence.  That single unichar may only be valid in combination  
with the other characters around it.


Do you know the encoding of the rest of the string you're dealing  
with?  Is it guaranteed to be ASCII?  Might it be UTF-8 which also  
includes some escaped Unicode characters for some reason?


Regards,
Ken

___

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

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

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

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


Re: Converting unicode strings to its values

2009-03-11 Thread Michael Vannorsdel
I could be remembering wrong but I think you can append unichars to  
mutable strings with [mstr appendFormat:@"%C", theunichar].  Or use %S  
for a null terminated array of unichars.



On Mar 11, 2009, at 4:00 AM, Ken Thomases wrote:

If a string literal in your source code actually contains the \u  
escape sequence, then that will be translated by the compiler.  The  
proper Unicode will end up in your binary.  (This wasn't true with  
earlier versions of gcc, but is true of the gcc that comes with  
Xcode 3.x.)  I suspect you know that.


If you actually get a string which contains the backslash, lowercase  
'u', and hex digits, then you're going to have to parse that  
somewhat manually.  NSScanner will probably be helpful.  Once you  
get an integer from the hex digits, you can use NSString's character- 
based methods like + stringWithCharacters:length: or - 
initWithCharacters:length:.  Sadly, I don't see a method on  
NSMutableString for inserting or appending individual character  
codes into a string.


Be mindful that not every UTF-16 code point is valid Unicode in  
isolation.  Combining characters and surrogate pairs complicate  
things.  I don't know if the character-based methods validate the  
character sequence you provide to them.  They might.  So, you might  
need to convert an entire string at once, rather than attempting to  
just create an NSString from a single unichar derived from a \u  
escape sequence.  That single unichar may only be valid in  
combination with the other characters around it.


Do you know the encoding of the rest of the string you're dealing  
with?  Is it guaranteed to be ASCII?  Might it be UTF-8 which also  
includes some escaped Unicode characters for some reason?


___

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 make the height of an NSSegmentedControl taller?

2009-03-11 Thread Paul Sanders
> If you _really_ need a taller one, you could create your own 
> custom
> control. It wouldn't be too hard, but I recommend making your 
> images
> smaller to fit the stock control.

Or perhaps use a tab metaphor (which you would have to code 
yourself, of course).  Maybe this is against the Human Interface 
Guidelines but it's common enough on websites so why not? 

___

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


Synthesized instance variables

2009-03-11 Thread Andreas Känner

Hi there,

does anybody know if there is an efficient way to directly access  
instance variables which have been synthesized for the 64bit runtime?  
Using object_getInstanceVariable is 10 times slower than the code the  
compiler generates for the synthesized getter.


Cheers

Andreas


___

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: Synthesized instance variables

2009-03-11 Thread Jean-Daniel Dupas

Le 11 mars 09 à 13:10, Andreas Känner a écrit :


Hi there,

does anybody know if there is an efficient way to directly access  
instance variables which have been synthesized for the 64bit  
runtime? Using object_getInstanceVariable is 10 times slower than  
the code the compiler generates for the synthesized getter.


What prevent you to use the synthesized getter ?

___

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: Synthesized instance variables

2009-03-11 Thread Paul Sanders
> does anybody know if there is an efficient way to directly 
> access
> instance variables which have been synthesized for the 64bit 
> runtime?
> Using object_getInstanceVariable is 10 times slower than the 
> code the
> compiler generates for the synthesized getter.

Try object->instance_var, rather than object.instance_var 

___

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: Background Process?

2009-03-11 Thread A.M.


On Mar 11, 2009, at 2:42 AM, Ken Thomases wrote:
All irrelevant, as there's no need for any signaling of any run loop  
input sources to allow timers to fire.


And the best source is the source:

http://www.opensource.apple.com/darwinsource/10.5.6/CF-476.17/CFRunLoop.c

static void __CFRunLoopTimerSchedule(CFRunLoopTimerRef rlt,  
CFRunLoopRef rl, CFRunLoopModeRef rlm) {

#if DEPLOYMENT_TARGET_MACOSX
__CFRunLoopTimerLock(rlt);
if (0 == rlt->_rlCount) {
rlt->_runLoop = rl;
if (MACH_PORT_NULL == rlt->_port) {
rlt->_port = mk_timer_create();
}
__CFRunLoopTimerPortMapLock();
if (NULL == __CFRLTPortMap) {
	__CFRLTPortMap =  
CFDictionaryCreateMutable(kCFAllocatorSystemDefault, 0, NULL, NULL);

}
	CFDictionarySetValue(__CFRLTPortMap, (void *)(uintptr_t)rlt->_port,  
rlt);

__CFRunLoopTimerPortMapUnlock();
}
rlt->_rlCount++;
mach_port_insert_member(mach_task_self(), rlt->_port, rlm- 
>_portSet);

mk_timer_arm(rlt->_port, __CFUInt64ToAbsoluteTime(rlt->_fireTSR));
__CFRunLoopTimerUnlock(rlt);
#endif
}
mach timers are blocked for in the subsequent CFRunLoopRun:

/* In that sleep of death what nightmares may come ... */
try_receive:
msg->msgh_bits = 0;
msg->msgh_local_port = waitSet;
msg->msgh_remote_port = MACH_PORT_NULL;
msg->msgh_id = 0;
	ret = mach_msg(msg, MACH_RCV_MSG|MACH_RCV_LARGE|(poll ?  
MACH_RCV_TIMEOUT : 0)|MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0)| 
MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT), 0, msg->msgh_size,  
waitSet, 0, MACH_PORT_NULL);



Cheers,
M
___

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: NSSlider changed notification

2009-03-11 Thread Steve Christensen
As previous replies have mentioned, if you're looking for continuous  
change, you need to make sure that "continuous" is set to YES, either  
by checking "continuously send action while sliding" in IB or by  
calling [mySlider setContinuous:YES].


You could keep track of changes to the slider value by either binding  
the slider's value to a property in your controller (which also means  
that the slider will stay in synch if the value is changed  
elsewhere), or adding a method to the controller of the form


- (void)mySliderChanged:(id)sender;

and then connecting the slider's target/action to that method in your  
controller by dragging a connection between the slider and controller  
in IB.



On Mar 10, 2009, at 11:03 AM, David Alter wrote:

I'm sure this is something basic that I'm just missing. For some  
reason I
can not find how to get a notification when my slider changes  
value. I want

to be able to subscribe to receive a notification if the slider value
changes. Is there a delegate method for this? What is the best way  
to get

this?

I guess one option would be to use KVO, but I suspect there is
a simpler solution.


___

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: Background Process?

2009-03-11 Thread Kyle Sluder
On Wed, Mar 11, 2009 at 2:42 AM, Ken Thomases  wrote:
> There is, in fact, no need for a dummy input source.  A timer is sufficient
> to keep a run loop "running", which is to say blocked.  I was one of the
> incorrect folks who propagated this myth, unfortunately, but was corrected.
>  Either a dummy input source such as a port _or_ a timer is enough to keep a
> run loop -run... method from immediately exiting.

And taken in context with the rest of the statements about how timers
aren't input sources, this didn't make sense to me.

> Although these details should not be relied upon, under the hood a run loop
> is implemented in terms of Mach message ports.  A run loop blocks by calling
> mach_msg() to receive a Mach message on any of a set of ports.  If there are
> timers in the run loop mode, then the time interval until the next needs to
> fire is passed as a timeout to the mach_msg() call.  This is how a run loop
> can block waiting for any source or timer.  (If sources or timers are added
> from another thread, which is legal with CFRunLoop but not NSRunLoop, then
> the other thread needs to wake the run loop, probably by sending a message
> on a Mach port set aside for that specific purpose.  That port will be in
> the set being waited on in mach_msg(), thus unblocking it.)

And there we have it.  Thank you very much for clearing up this rather
significant confusion on my part.  Sorry to everyone else for wasting
your time.

--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: Synthesized instance variables

2009-03-11 Thread Jean-Daniel Dupas


Le 11 mars 09 à 16:03, Andreas Känner a écrit :


Hi,

Am 11.03.2009 um 13:27 schrieb Jean-Daniel Dupas:


Le 11 mars 09 à 13:10, Andreas Känner a écrit :


Hi there,

does anybody know if there is an efficient way to directly access  
instance variables which have been synthesized for the 64bit  
runtime? Using object_getInstanceVariable is 10 times slower than  
the code the compiler generates for the synthesized getter.


What prevent you to use the synthesized getter ?



I want to override the synthesized getter to create a value on demand.

Regards,
Andreas


Good reason.
And what prevent you to simply declare the ivar in the interface  
instead of letting the compiler generating 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


Compile Problems

2009-03-11 Thread Barry Fawthrop
Greetings All

I'm trying to build a kerberos based application for the iPhone 2.2.1

I'm getting errors like this
...
...
Compiling /Users//Desktop//Classes/crypto/enc_provider/des.mm (1 errors)
   error: 'krb5int_c_mit_des_zeroblock' was not declared in this scope
Compiling /Users//Desktop//Classes/crypto/enc_provider/des3.mm (2 
errors)
   error: 'krb5int_c_mit_des_zeroblock' was not declared in this scope
   error: 'krb5int_c_mit_des_zeroblock' was not declared in this scope

The des.mm error comes from the line
mit_des_cbc_encrypt((const mit_des_cblock *)input->data,
(mit_des_cblock *) output->data, input->length,
schedule, (ivec ? (unsigned char *)ivec->data :
(unsigned char *)mit_des_zeroblock), enc);


des.mm has at the beginning
#import 
#import "krb5.h"
#import "enc_provider.h"
#import "des_int.h"


des_int.h  has

typedef des_cblock  mit_des_cblock;
typedef mit_des_cblock  mit_des3_cblock[3];
...
...
...
extern const mit_des_cblock  mit_des_zeroblock;
#define mit_des_zeroblock  krb5int_c_mit_des_zeroblock


Any assistance gratefully appriecated

Thanks
Barry
___

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


Handling WebView DOM events in Cocoa

2009-03-11 Thread Dave Carrigan

All,

I've been the WebKit docs, but haven't been able to find an answer to  
a pretty basic (to my mind) question.


I want to have an obc-c method get called when a DOM event (click,  
mouseover, etc.) happens inside the WebView. I was looking for some  
kind of DomEventDelegate kind of thing, but there doesn't seem to be  
one.


Can somebody point me in the right direction?

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



PGP.sig
Description: This is a digitally signed message part
___

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: Examples or Documentation for Non-document-based Multi-window App

2009-03-11 Thread Michael Ash
On Tue, Mar 10, 2009 at 6:09 PM, Grant Erickson  wrote:
> Suppose I were writing an application, perhaps similar to the example at
> http://en.wikibooks.org/wiki/Programming_Mac_OS_X_with_Cocoa_for_beginners/B
> uilding_a_GUI (or many of the examples in /Developer/Examples/...) that had
> no file-based interaction whatsoever but for which I wanted to allow the
> user to open up and interact with up to N windows.
>
> Using the example above, each newly-opened window perhaps displays something
> from quote of the day (QOTD) or some other singular random data source
> rather than "Hello World".
>
> It seems the document-based architecture is ill-suited to such an
> application because there is effectively no need to open, save, revert,
> print, etc. anything.

IMO this is a bit backwards. The framework providing stuff you don't
need isn't a hurdle at all. If you don't need it, just don't use it.
The real question is, does it provide stuff you *do* need.

I think this could work well as an NSDocument application. Write your
documents to grab the random quote when an untitled document is
created, disable or don't implement all the functionality you don't
need, and off you go.

Mike
___

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

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

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

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


Re: iPhone book recommendations

2009-03-11 Thread Barry Fawthrop
Donald Hall wrote:
> I'm not sure if this is the most appropriate list for this question, but
> here goes:
> 
> Can anyone recommend a good book to get started on iPhone programming?
> I've been using Cocoa for several years now, so I don't need a really
> basic starter book. I've looked at several books at amazon.com. Has
> anyone tried the new one by Maher Ali? Too new for any customer reviews
> yet, but it looks like it might be the right level for me.
> 
> TIA,
> 
> Don
XCode 3 Unleashed  By Fritz Anderson  is a great book and can be bought
at Amazon or Alibris

Barry

___

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: Compile Problems

2009-03-11 Thread I. Savant
On Wed, Mar 11, 2009 at 12:18 PM, Barry Fawthrop  wrote:

> ...
> I'm getting errors like this
> ...
> Compiling /Users//Desktop//Classes/crypto/enc_provider/des.mm (1 
> errors)
>   error: 'krb5int_c_mit_des_zeroblock' was not declared in this scope
> Compiling /Users//Desktop//Classes/crypto/enc_provider/des3.mm (2 
> errors)
>   error: 'krb5int_c_mit_des_zeroblock' was not declared in this scope
>   error: 'krb5int_c_mit_des_zeroblock' was not declared in this scope

  Did you add libcrypto to your linker flags?

--
I.S.
___

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

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

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

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


Re: Compile Problems

2009-03-11 Thread Barry Fawthrop
I. Savant wrote:
> On Wed, Mar 11, 2009 at 12:18 PM, Barry Fawthrop  wrote:
> 
>> ...
>> I'm getting errors like this
>> ...
>> Compiling /Users//Desktop//Classes/crypto/enc_provider/des.mm (1 
>> errors)
>>   error: 'krb5int_c_mit_des_zeroblock' was not declared in this scope
>> Compiling /Users//Desktop//Classes/crypto/enc_provider/des3.mm (2 
>> errors)
>>   error: 'krb5int_c_mit_des_zeroblock' was not declared in this scope
>>   error: 'krb5int_c_mit_des_zeroblock' was not declared in this scope
> 
>   Did you add libcrypto to your linker flags?
> 
> --
> I.S.
Thanks for your reply
No I have not added any linker flags
I have copied the src code from kerberos (MIT's web site)
and trying to get it to compile

I'll try the libcrypto  (I have seen that in 
Developers\Platforms\iPhoneSimulator.platform\SDKS\iPhoneSimulator2.2.1.sdk\usr\include\
there is a krb5 directory and krb5.h file  I'm wondering if this means iPhone 
2.2.1 has the kerberos 5 libraries ?

Thanks again
Barry
___

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

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

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

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


Re: EXC_BAD_ACCESS on NSImageView::setImage

2009-03-11 Thread Scott Ribe
Does your setImage method retain the image?

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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: Background Process?

2009-03-11 Thread Shawn Erickson
#import 

@interface Foo : NSObject
- (void)run;
- (void)fire:(NSTimer*)time;
@end

@implementation Foo

- (void) run
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

[NSTimer scheduledTimerWithTimeInterval:5.0 target:self
selector:@selector(fire:) userInfo:nil repeats:YES];

[[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]];

[pool release];
}

- (void)fire:(NSTimer*)timer
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

NSLog(@"FIRED");

[pool release];
}

@end

int main (int argc, const char * argv[]) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

Foo* foo = [[[Foo alloc] init] autorelease];
[NSThread detachNewThreadSelector:@selector(run) toTarget:foo
withObject:nil];

sleep(4 * 60);

[pool release];

return 0;
}

[0:525] > time ./TimerTest& sample TimerTest
[1] 66952
Sampling process 66954 for 10 seconds with 1 millisecond of run time
between samples
2009-03-11 09:56:55.454 TimerTest[66954:1003] FIRED
2009-03-11 09:57:00.454 TimerTest[66954:1003] FIRED
Sampling completed, processing symbols...
Sample analysis of process 66954 written to file
/tmp/TimerTest_66954.AXF9SU.sample.txt



Analysis of sampling TimerTest (pid 66954) every 1 millisecond
Call graph:
8492 Thread_2907
  8492 start
8492 main
  8492 sleep$UNIX2003
8492 __semwait_signal
  8492 __semwait_signal
8492 Thread_2a03
  8492 thread_start
8492 _pthread_start
  8492 __NSThread__main__
8492 -[NSThread main]
  8492 -[Foo run]
8492 -[NSRunLoop(NSRunLoop) runUntilDate:]
  8492 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
8492 CFRunLoopRunInMode
  8492 CFRunLoopRunSpecific
8489 mach_msg
  8489 mach_msg_trap
8489 mach_msg_trap
3 __NSFireTimer
  3 -[Foo fire:]
3 NSLog
  3 NSLogv
3 _CFLogvEx
  3 __CFLogCString
1 CFCalendarCreateWithIdentifier
  1 CFTimeZoneCopyDefault
1 CFTimeZoneCopySystem
  1 CFTimeZoneCreateWithName
1 open$UNIX2003
  1 open$UNIX2003
1 asl_close
  1 notify_cancel
1 _notify_server_cancel
  1 mach_msg
1 mach_msg_trap
  1 mach_msg_trap
1 asl_free
  1 asl_free

Total number in stack (recursive counted multiple, when >=5):

Sort by top of stack, same collapsed (when >= 5):
__semwait_signal8492
mach_msg_trap8490
___

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: Garbage collected and non-garbage collected

2009-03-11 Thread Robert Mullen
As I have waded into the code a little more I see that this entire  
struct is allocated using calloc() in an init and freed with free().  
How does that work with GC? I have tried __strong and some CFRetain  
and CFRelease to no avail but want to try rearranging things a little  
bit there. I think the struct itself may be the problem but would like  
some corroboration.


On Mar 10, 2009, at 3:46 PM, Bill Bumgarner wrote:


On Mar 10, 2009, at 1:17 PM, Robert Mullen wrote:
The framework is open source. It is the SM2DGraphView Framework. I  
have posted on the Snowmint forum but not getting anything. I think  
that is understandable as the original author built this for his  
own purpose and released it to the world out of generosity. I have  
made some minor mods to the code base already and don't mind making  
others but not sure what the quality of the changes will be given  
my inexperience. If this were .NET I would have no hesitation as I  
am fluent and experienced. I simply don't have that confidence yet  
with Cocoa and Objective-C. In the debugging I am doing right now I  
have noticed that there is a struct with "private" data the  
framework uses and one element of this struct is an  
NSMutableDictionary of text attributes. This is definitely one  
source of problems as reading from this element causes bad access.  
I insert some logging to look at this element and it has so far  
contained , , and  
 but not an NSMutableDictionary. Pretty  
clearly I am not getting the memory that is expected but my first  
glance at the code exposes no holes that are obvious to me. This  
was addressed once before on the Snowmint forum with that poster  
exhibiting the same crash symptoms but the thread went silent after  
the framework author asked specific questions about what is not  
working. Any pointers (bad pun intended) would be appreciated. I  
wouldn't mind debugging this myself with the help of a few more  
experienced coders. I do understand the basic tenets of memory  
management but am also not greatly experienced there.


Sounds like the collector has reaped the location in the struct a  
wee-tad earlier than the code would like.


Try declaring the NSMutableDictionary * as __strong

{

__strong NSMutableDictionary *bob;

}

If that doesn't work, you can call CFRetain() / CFRelease() on the  
dictionary reference as it goes in/out of the struct [instead of - 
retain/-release].


Also -- look through the -dealloc methods in the framework.   You'll  
want to create a -finalize for any that do anything beyond -release  
of objects/[super dealloc] (Though you don't need to unregister  
notification observers).


- free()s & CFRelease()s can be copied directly to -finalize

- close() and other resource management *may* be copied, but you  
need to be careful about scarce resource management in -finalize as  
that can be problematic


Anything else?   Depends... be careful about order dependencies.   
And you really want to avoid allocating or retaining anything in  
your finalizer.   Avoid mucking with the object graph.


All very vague, I know, but that is in the hopes that you won't have  
to dive deep.  If you do, post some details and we'll see what we  
can do.


b.bum



___

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: Background Process?

2009-03-11 Thread Shawn Erickson
On Tue, Mar 10, 2009 at 11:02 PM, Kyle Sluder  wrote:
> On Wed, Mar 11, 2009 at 1:53 AM, Roland King  wrote:
>> So you just add the timer to the runloop, run it, it sleeps until the timer
>> fires, does its thing and then goes back to sleep again. What am I missing?
>
> Well, there is a sentence directly below that list that says the following:
>
> "Because timers and other periodic events are delivered when you run
> the run loop, circumventing that loop disrupts the delivery of those
> events."
>
> That sentence implies that the run loop must be run, either manually
> or as the result of input coming in on an input source (which timers
> are not), in order for the timer to fire.

"run" basically means the thread is INSIDE a call to one of the "run"
methods of a runloop (-[NSRunLoop runUntilDate:], etc.) not that the
runloop is actively doing something (aka burning CPU). The runloop
cannot pickup timer fires, event source fires, etc. if the thread of
execution is outside of the runloop itself... that is all that
statement is saying.

-Shawn
___

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


Cocoaheads Lake Forest (92630) meeting 3/11/2009 (tonight!) at 7 pm on "Modeling a Game with the Cocoa Frameworks"

2009-03-11 Thread Scott Ellsworth
Meeting tonight!

CocoaHeads Lake Forest will be meeting on the second Wednesday of the
month.  We will be meeting at our usual location, Orange County Public
Library (El Toro) community room, 24672 Raymond Way, Lake Forest, CA
92630

Please join us from 7pm to 9pm on Wednesday, 3/11.

Joe Sickel will continue his discussion about modeling a game with the
Cocoa frameworks.

Bring your comments, your books, and your bugs, and we will leap right in.

As always, details can be found on the cocoaheads web site at
www.cocoaheads.org.

Thanks go to O'Reilly Media for providing us one of their books as a door prize.
___

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: Garbage collected and non-garbage collected

2009-03-11 Thread Joar Wingfors


On Mar 11, 2009, at 10:03 AM, Robert Mullen wrote:

As I have waded into the code a little more I see that this entire  
struct is allocated using calloc() in an init and freed with free().  
How does that work with GC?



The GC only manages memory that's allocated from the managed heap, and  
this is separate from the standard malloc zone. If you're using  
regular malloc, you're on the hook for managing that memory completely  
manually. Note though, that you can also allocate raw buffers of data  
from the managed heap using NSAllocateCollectable.


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: Background Process?

2009-03-11 Thread Kyle Sluder
On Wed, Mar 11, 2009 at 12:59 PM, Shawn Erickson  wrote:
> #import 

I did the exact same thing and was actively running it under
Instruments when Ken's message came in last night.  At first I thought
it was repeatedly calling -runInMode:untilDate: but Instruments told
me otherwise.

--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: setFrame: not working in custom event loop

2009-03-11 Thread Mike Manzano
Nope that didn't do it. Same symptoms. Any other ideas before I throw  
in the gauntlet and rewrite it?


On Mar 10, 2009, at 5:41 PM, Jesper Storm Bache wrote:

When you modify a window it registers itself as needing redrawing in  
the current run loop.

If you are performing active tracking, you may have to do so yourself.
Try calling [window flushWindowIfNeeded] on your window at the end  
of your loop (inside the loop).


What is the reason for your explicit tracking?
You should be able to simply listen for mouseDragged, mouseDown, and  
mouseUp on your split view (if this is a custom sub-class).

Jesper Storm Bache

On Mar 10, 2009, at 2:51 PM, Mike Manzano wrote:


Hi,

I am tracking the mouse pointer to dynamically resize a splitter as a
separate drag handle is dragged. This is done in mouseDown: of the
drag handle with a custom event loop. The loop looks like this:

   while (keepOn)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   theEvent = [[self window] nextEventMatchingMask:
NSAnyEventMask] ;// NSLeftMouseUpMask | NSLeftMouseDraggedMask];

   switch ([theEvent type])
{
case NSLeftMouseUp:
keepOn = NO;
break;

case NSLeftMouseDragged:
[nc  
postNotificationName:NSSplitViewWillResizeSubviewsNotification

object:splitView];
firstFrame = [[[splitView subviews] 
objectAtIndex:0] frame];
firstFrame.size.width = (isLeftResizer ?

 MAX(0,roundf(([splitViewconvertPoint:[theEvent
locationInWindow] fromView:nil].x + offset) - firstFrame.origin.x)) :

 MAX(0,roundf([splitViewconvertPoint:[theEvent
locationInWindow] fromView:nil].x - [splitViewdividerThickness] -
offset)));

firstFrame.size.width = 
MIN(MAX(firstFrame.size.width,min),max);

NSLog( @"SetFrame: %@" , 
NSStringFromRect(firstFrame) ) ;
[[[splitView subviews] objectAtIndex:0] 
setFrame:firstFrame];
NSLog( @"\tIs Now: %@" , 
NSStringFromRect([[[splitView subviews]
objectAtIndex:0] frame]) ) ;

[splitView adjustSubviews];
[nc 
postNotificationName:NSSplitViewDidResizeSubviewsNotification
object:splitView];
break;
default:
break;
}
[pool release] ;
}

NSLog( @"Finally: %@" , NSStringFromRect([[[splitView subviews]
objectAtIndex:0] frame]) ) ;


(you might recognize this is as the Scrivener custom split view code
available on the web)

Anyway, the visual updates to the screen seem to start lagging the
further right I drag the handle. You can see the NSLog()s I have in
the code; here is the output as I drag:

[...]
2009-03-10 14:37:42.428 SkootUI[8830:10b] SetFrame: {{0, 0}, {718,  
604}}
2009-03-10 14:37:42.444 SkootUI[8830:10b] 	Is Now: {{0, 0}, {718,  
604}}
2009-03-10 14:37:42.511 SkootUI[8830:10b] SetFrame: {{0, 0}, {721,  
604}}
2009-03-10 14:37:42.539 SkootUI[8830:10b] 	Is Now: {{0, 0}, {721,  
604}}
2009-03-10 14:37:42.596 SkootUI[8830:10b] SetFrame: {{0, 0}, {723,  
604}}
2009-03-10 14:37:42.600 SkootUI[8830:10b] 	Is Now: {{0, 0}, {723,  
604}}
2009-03-10 14:37:44.101 SkootUI[8830:10b] Finally: {{0, 0}, {684,  
604}}


As you can see, as far as the view being resized is concerned, it is
being set to what I set it to as I drag the handle; i.e., the
"SetFrame:" dimensions match the "Is Now:" dimensions. During this
time, however, I can see the view sizing visually lag. When the drag
finishes and the "Finally" block prints out, querying the view for  
its

frame displays what I believe to be the actual lagged dimensions.

Can anyone tell me what's going on?

Thanks,

Mike
___

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

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

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

This email sent to jsba...@adobe.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: setFrame: not working in custom event loop

2009-03-11 Thread Mike Manzano
Well, I just rewrote it, and it's doing exactly the same thing. You  
can see this from the debug output:


2009-03-11 11:15:50.092 SkootUI[13145:10b] Will Set To: {{0, 0}, {743,  
604}}

2009-03-11 11:15:50.097 SkootUI[13145:10b]  After: {{0, 0}, {743, 604}}
2009-03-11 11:15:50.179 SkootUI[13145:10b] Will Set To: {{0, 0}, {744,  
604}}

2009-03-11 11:15:50.186 SkootUI[13145:10b]  After: {{0, 0}, {744, 604}}
2009-03-11 11:15:51.221 SkootUI[13145:10b] *** Finally: {{0, 0}, {689,  
604}}


Here's the new code:

- (void)mouseUp:(NSEvent *)theEvent
{
	NSLog( @"*** Finally: %@" , NSStringFromRect( [[[splitView subviews]  
objectAtIndex:0] frame] )) ;

}

- (void)mouseDragged:(NSEvent *)theEvent
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter] ;
	[nc postNotificationName:NSSplitViewWillResizeSubviewsNotification  
object:splitView];

NSRect firstFrame = [[[splitView subviews] objectAtIndex:0] frame];
firstFrame.size.width = (_isLeftResizer ?
		 MAX(0,roundf(([splitViewconvertPoint:[theEvent locationInWindow]  
fromView:nil].x + _offset) - firstFrame.origin.x)) :
		 MAX(0,roundf([splitViewconvertPoint:[theEvent locationInWindow]  
fromView:nil].x - [splitViewdividerThickness] - _offset)));


firstFrame.size.width = MIN(MAX(firstFrame.size.width,_min),_max);
NSLog( @"Will Set To: %@" , NSStringFromRect(firstFrame) ) ;
[[[splitView subviews] objectAtIndex:0] setFrame:firstFrame];
	NSLog( @"\tAfter: %@" , NSStringFromRect( [[[splitView subviews]  
objectAtIndex:0] frame] )) ;

[splitView adjustSubviews];
	[nc postNotificationName:NSSplitViewDidResizeSubviewsNotification  
object:splitView];

[[splitView window] flushWindowIfNeeded] ;
}

- (void)mouseDown:(NSEvent *)theEvent
{
	// Get min and max sizes of the first sub view from the split view  
delegate if there is one...

_min = 0.0 ;
_max = [splitView frame].size.width - [splitView dividerThickness];
	if ([[splitView delegate]  
respondsToSelector 
:@selector(splitView:constrainMinCoordinate:ofSubviewAt:)])
		_min = [[splitView delegate] splitView:splitView  
constrainMinCoordinate:_min ofSubviewAt:0];
	if ([[splitView delegate]  
respondsToSelector 
:@selector(splitView:constrainMaxCoordinate:ofSubviewAt:)])
		_max = [[splitView delegate] splitView:splitView  
constrainMaxCoordinate:_max ofSubviewAt:0];


	_isLeftResizer = [self isDescendantOf:[[splitView subviews]  
objectAtIndex:0]];


_offset = _isLeftResizer ?
		[self frame].size.width - [self convertPoint:[theEvent  
locationInWindow] fromView:nil].x		:

[self convertPoint:[theEvent locationInWindow] fromView:nil].x ;
}

On Mar 11, 2009, at 10:52 AM, Mike Manzano wrote:

Nope that didn't do it. Same symptoms. Any other ideas before I  
throw in the gauntlet and rewrite it?


On Mar 10, 2009, at 5:41 PM, Jesper Storm Bache wrote:

When you modify a window it registers itself as needing redrawing  
in the current run loop.
If you are performing active tracking, you may have to do so  
yourself.
Try calling [window flushWindowIfNeeded] on your window at the end  
of your loop (inside the loop).


What is the reason for your explicit tracking?
You should be able to simply listen for mouseDragged, mouseDown,  
and mouseUp on your split view (if this is a custom sub-class).

Jesper Storm Bache

On Mar 10, 2009, at 2:51 PM, Mike Manzano wrote:


Hi,

I am tracking the mouse pointer to dynamically resize a splitter  
as a

separate drag handle is dragged. This is done in mouseDown: of the
drag handle with a custom event loop. The loop looks like this:

  while (keepOn)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  theEvent = [[self window] nextEventMatchingMask:
NSAnyEventMask] ;// NSLeftMouseUpMask | NSLeftMouseDraggedMask];

  switch ([theEvent type])
{
case NSLeftMouseUp:
keepOn = NO;
break;

case NSLeftMouseDragged:
[nc  
postNotificationName:NSSplitViewWillResizeSubviewsNotification

object:splitView];
firstFrame = [[[splitView subviews] 
objectAtIndex:0] frame];
firstFrame.size.width = (isLeftResizer ?

 MAX(0,roundf(([splitViewconvertPoint:[theEvent
locationInWindow] fromView:nil].x + offset) -  
firstFrame.origin.x)) :


 MAX(0,roundf([splitViewconvertPoint:[theEvent
locationInWindow] fromView:nil].x - [splitViewdividerThickness] -
offset)));

firstFrame.size.width = 
MIN(MAX(firstFrame.size.width,min),max);

NSLog( @"

problems with NSTextField destroying background

2009-03-11 Thread Memo Akten

Hi All, I am creating everything programatically:
one custom NSWindow -> one NSView (my root view), that has multiple  
custom NSViews attached, in each one is an NSBox and NSTextField.


My problem is, I want the NSTextField to be transparent (and show the  
NSBox behind), but instead it's making a hole in the NSBox to show the  
desktop, what am I missing?


window and root view code:

-(id) initWithContentRect:(NSRect)windowRect {
NSLog(@"TransparentWindow::initWithContentRect");
	if(self = [super initWithContentRect:windowRect  
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered  
defer:NO]) {

[self setOpaque:NO];
[self setBackgroundColor:[NSColor clearColor]];
[self setMovableByWindowBackground:NO];
[self makeKeyAndOrderFront:nil];

NSView *rootView = [[NSView alloc] initWithFrame:windowRect];
[self setContentView:rootView];
[rootView release];

controller = [[Controller alloc] initWithView:rootView];
}
NSLog(@"/TransparentWindow::initWithContentRect");
return self;
}   

Controller is just a custom NSObject which managers my data, and it  
creates a bunch of CustomViews:


- (id)initWithFrame:(NSRect)frame andData:(Data*)c {
NSLog(@"CustomView::initWithFrame");
self = [super initWithFrame:frame];
if (self) {
data = c;
		NSRect myRect = NSMakeRect(0.0, 0.0, frame.size.width,  
frame.size.height);


NSBox *bgView = [[[NSBox alloc] initWithFrame:myRect] 
autorelease];
[bgView setBoxType:NSBoxCustom];
[bgView setBorderType:NSLineBorder];
[bgView setTitlePosition:NSNoTitle];
[bgView setFillColor:[NSColor grayColor]];
[self addSubview:bgView];

		NSTextField *label = [[[NSTextField alloc]  
initWithFrame:NSMakeRect(0.0, frame.size.height/2, frame.size.width,  
TITLE_SIZE * 2)] autorelease];

[label setEnabled:NO];
[label setSelectable:NO];
[label setBackgroundColor:[NSColor clearColor]];
		[label setTextColor:[NSColor colorWithDeviceRed:TITLE_COLOR  
green:TITLE_COLOR blue:TITLE_COLOR alpha:1]];

[label setTitleWithMnemonic:@"testing"];
[label setAlignment:NSCenterTextAlignment];
[label setFont:[NSFont fontWithName:@"Myriad Set" 
size:TITLE_SIZE]];
[label setBordered:NO];
[self addSubview:label];
}
NSLog(@"/CustomView::initWithFrame");
return self;
}


___

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: Garbage collected and non-garbage collected

2009-03-11 Thread Greg Parker

On Mar 11, 2009, at 10:03 AM, Robert Mullen wrote:
As I have waded into the code a little more I see that this entire  
struct is allocated using calloc() in an init and freed with free().  
How does that work with GC? I have tried __strong and some CFRetain  
and CFRelease to no avail but want to try rearranging things a  
little bit there. I think the struct itself may be the problem but  
would like some corroboration.


Yes, the struct itself is a problem. When the garbage collector looks  
for pointers, it doesn't look inside ordinary malloc-allocated memory.  
If the only pointer to your object is inside this malloc'ed struct,  
the collector won't see it and may throw your object away.


You have three options:

1. Turn the struct into an Objective-C object. You can mark all of the  
ivars @public to make it more struct-like, instead of adding accessor  
methods everywhere. Of course, you now need to make sure the pointers  
to the former struct are GC-compatible (for example, not inside other  
malloc'ed structs).


2. Allocate the struct with NSAllocateCollectable(NSScannedOption| 
NSCollectorDisabledOption) AND mark the object fields in the struct  
with __strong. NSScannedOption tells the collector to look inside the  
struct for other GC pointers. NSCollectorDisabledOption tells the  
collector that you'll call free() yourself. __strong tells the  
compiler to use the GC write barriers when assigning to the struct's  
fields.


3. CFRetain() pointers before storing them in the struct, and CFRelease 
() them afterwards. This can be easy if the struct's fields are  
wrapped in accessor functions, but otherwise may be a large code  
change. Beware of uncollectable cycles.



--
Greg Parker gpar...@apple.com Runtime Wrangler


___

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: setFrame: not working in custom event loop

2009-03-11 Thread Andy Lee
I'm guessing the problem is that you are only calling setFrame: on  
subview 0, thereby increasing the total width of the subviews.  You  
are assuming subview 1 will adjust by the same amount as you added/ 
subtracted from subview 0.  But actually, adjustSubviews scales both  
subviews down so their total width is what it was before.  You can see  
this by doing an NSLog *after* the call to adjustSubviews.


What you need to do is adjust the width of *both* subviews -- add from  
one, subtract from the other -- maintaining constant total width.


--Andy

On Mar 11, 2009, at 2:17 PM, Mike Manzano wrote:

Well, I just rewrote it, and it's doing exactly the same thing. You  
can see this from the debug output:


2009-03-11 11:15:50.092 SkootUI[13145:10b] Will Set To: {{0, 0},  
{743, 604}}
2009-03-11 11:15:50.097 SkootUI[13145:10b] 	After: {{0, 0}, {743,  
604}}
2009-03-11 11:15:50.179 SkootUI[13145:10b] Will Set To: {{0, 0},  
{744, 604}}
2009-03-11 11:15:50.186 SkootUI[13145:10b] 	After: {{0, 0}, {744,  
604}}
2009-03-11 11:15:51.221 SkootUI[13145:10b] *** Finally: {{0, 0},  
{689, 604}}


Here's the new code:

- (void)mouseUp:(NSEvent *)theEvent
{
	NSLog( @"*** Finally: %@" , NSStringFromRect( [[[splitView  
subviews] objectAtIndex:0] frame] )) ;

}

- (void)mouseDragged:(NSEvent *)theEvent
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter] ;
	[nc postNotificationName:NSSplitViewWillResizeSubviewsNotification  
object:splitView];

NSRect firstFrame = [[[splitView subviews] objectAtIndex:0] frame];
firstFrame.size.width = (_isLeftResizer ?
		 MAX(0,roundf(([splitViewconvertPoint:[theEvent locationInWindow]  
fromView:nil].x + _offset) - firstFrame.origin.x)) :
		 MAX(0,roundf([splitViewconvertPoint:[theEvent locationInWindow]  
fromView:nil].x - [splitViewdividerThickness] - _offset)));


firstFrame.size.width = MIN(MAX(firstFrame.size.width,_min),_max);
NSLog( @"Will Set To: %@" , NSStringFromRect(firstFrame) ) ;
[[[splitView subviews] objectAtIndex:0] setFrame:firstFrame];
	NSLog( @"\tAfter: %@" , NSStringFromRect( [[[splitView subviews]  
objectAtIndex:0] frame] )) ;

[splitView adjustSubviews];
	[nc postNotificationName:NSSplitViewDidResizeSubviewsNotification  
object:splitView];

[[splitView window] flushWindowIfNeeded] ;
}

- (void)mouseDown:(NSEvent *)theEvent
{
	// Get min and max sizes of the first sub view from the split view  
delegate if there is one...

_min = 0.0 ;
_max = [splitView frame].size.width - [splitView dividerThickness];
	if ([[splitView delegate]  
respondsToSelector 
:@selector(splitView:constrainMinCoordinate:ofSubviewAt:)])
		_min = [[splitView delegate] splitView:splitView  
constrainMinCoordinate:_min ofSubviewAt:0];
	if ([[splitView delegate]  
respondsToSelector 
:@selector(splitView:constrainMaxCoordinate:ofSubviewAt:)])
		_max = [[splitView delegate] splitView:splitView  
constrainMaxCoordinate:_max ofSubviewAt:0];


	_isLeftResizer = [self isDescendantOf:[[splitView subviews]  
objectAtIndex:0]];


_offset = _isLeftResizer ?
		[self frame].size.width - [self convertPoint:[theEvent  
locationInWindow] fromView:nil].x		:

[self convertPoint:[theEvent locationInWindow] fromView:nil].x ;
}

On Mar 11, 2009, at 10:52 AM, Mike Manzano wrote:

Nope that didn't do it. Same symptoms. Any other ideas before I  
throw in the gauntlet and rewrite it?


On Mar 10, 2009, at 5:41 PM, Jesper Storm Bache wrote:

When you modify a window it registers itself as needing redrawing  
in the current run loop.
If you are performing active tracking, you may have to do so  
yourself.
Try calling [window flushWindowIfNeeded] on your window at the end  
of your loop (inside the loop).


What is the reason for your explicit tracking?
You should be able to simply listen for mouseDragged, mouseDown,  
and mouseUp on your split view (if this is a custom sub-class).

Jesper Storm Bache

On Mar 10, 2009, at 2:51 PM, Mike Manzano wrote:


Hi,

I am tracking the mouse pointer to dynamically resize a splitter  
as a

separate drag handle is dragged. This is done in mouseDown: of the
drag handle with a custom event loop. The loop looks like this:

 while (keepOn)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 theEvent = [[self window] nextEventMatchingMask:
NSAnyEventMask] ;// NSLeftMouseUpMask | NSLeftMouseDraggedMask];

 switch ([theEvent type])
{
case NSLeftMouseUp:
keepOn = NO;
break;

case NSLeftMouseDragged:
[nc  
postNotificationName:NSSplitViewWillResizeSubviewsNotification

object:splitView];
firstFrame = [[[splitView subviews] 
objectAtIndex:0] frame];
  

Re: State of performing tasks with elevated privileges

2009-03-11 Thread Sidney San Martín
All right, those are fair points. But I forgot to mention that what  
also worries me about that method is this paragraph from the  
Authorization Services Programming Guide:


"You may be tempted to use the function  
AuthorizationExecuteWithPrivileges to perform privileged operations  
rather than creating and calling your own setuid tool. Although this  
might seem like an easy solution, using the  
AuthorizationExecuteWithPrivileges function without the rest of the  
Authorization Services functions produces a severe security hole  
because the function indiscriminately runs any tool as the root user.  
Setuid tools also have security risks, but they are far less severe  
than using the function AuthorizationExecuteWithPrivileges for  
purposes other than those described in this document. Read “Factored  
Applications” for instructions on creating your own helper tool."


I don't completely follow that warning. If I have a factored helper  
tool, is it important for it to be setuid root? What, even, is the  
advantage of using the complex libraries contained in MoreSecurity and  
BetterAuthorizationSample. Do people not use them in the real world?


On Tue, Mar 10, 2009 at 1:45 PM, Nick Zitzmann   
wrote:


On Mar 10, 2009, at 10:39 AM, Sidney San Martín wrote:


I can make a helper tool that I call with
AuthorizationExecuteWithPrivileges. I already have this working, but
it's vulnerable to attack (if the helper binary is replaced)


Yes, but the chances of that happening are very, very low unless the  
same

user who installed the application also installed some malware that
intentionally targeted your app. If that's a concern to you, then  
you could
check a checksum or some other signature before invoking AEWP(). But  
keep in
mind that (1) malware of any kind on Mac OS X is very rare to  
nonexistent,
and (2) you cannot stop a very determined attacker; you can make it  
more

difficult to discourage the less determined, but not impossible.


and
apparently has poorly-documented caveats (needing to reap the process
when it's done executing, for one, which is something else I've never
done).



Well, you don't _need_ to reap the zombies if you don't want to.  
It'll just
look strange in Activity Monitor, and will waste a little RAM until  
the

parent task exits.

Nick Zitzmann







___

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


[SOLVED] Re: setFrame: not working in custom event loop

2009-03-11 Thread Mike Manzano

That was exactly it. Thank you very much!

Mike


On Mar 11, 2009, at 11:48 AM, Andy Lee wrote:

I'm guessing the problem is that you are only calling setFrame: on  
subview 0, thereby increasing the total width of the subviews.  You  
are assuming subview 1 will adjust by the same amount as you added/ 
subtracted from subview 0.  But actually, adjustSubviews scales both  
subviews down so their total width is what it was before.  You can  
see this by doing an NSLog *after* the call to adjustSubviews.


What you need to do is adjust the width of *both* subviews -- add  
from one, subtract from the other -- maintaining constant total width.


--Andy

On Mar 11, 2009, at 2:17 PM, Mike Manzano wrote:

Well, I just rewrote it, and it's doing exactly the same thing. You  
can see this from the debug output:


2009-03-11 11:15:50.092 SkootUI[13145:10b] Will Set To: {{0, 0},  
{743, 604}}
2009-03-11 11:15:50.097 SkootUI[13145:10b] 	After: {{0, 0}, {743,  
604}}
2009-03-11 11:15:50.179 SkootUI[13145:10b] Will Set To: {{0, 0},  
{744, 604}}
2009-03-11 11:15:50.186 SkootUI[13145:10b] 	After: {{0, 0}, {744,  
604}}
2009-03-11 11:15:51.221 SkootUI[13145:10b] *** Finally: {{0, 0},  
{689, 604}}


Here's the new code:

- (void)mouseUp:(NSEvent *)theEvent
{
	NSLog( @"*** Finally: %@" , NSStringFromRect( [[[splitView  
subviews] objectAtIndex:0] frame] )) ;

}

- (void)mouseDragged:(NSEvent *)theEvent
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter] ;
	[nc postNotificationName:NSSplitViewWillResizeSubviewsNotification  
object:splitView];

NSRect firstFrame = [[[splitView subviews] objectAtIndex:0] frame];
firstFrame.size.width = (_isLeftResizer ?
		 MAX(0,roundf(([splitViewconvertPoint:[theEvent locationInWindow]  
fromView:nil].x + _offset) - firstFrame.origin.x)) :
		 MAX(0,roundf([splitViewconvertPoint:[theEvent locationInWindow]  
fromView:nil].x - [splitViewdividerThickness] - _offset)));


firstFrame.size.width = MIN(MAX(firstFrame.size.width,_min),_max);
NSLog( @"Will Set To: %@" , NSStringFromRect(firstFrame) ) ;
[[[splitView subviews] objectAtIndex:0] setFrame:firstFrame];
	NSLog( @"\tAfter: %@" , NSStringFromRect( [[[splitView subviews]  
objectAtIndex:0] frame] )) ;

[splitView adjustSubviews];
	[nc postNotificationName:NSSplitViewDidResizeSubviewsNotification  
object:splitView];

[[splitView window] flushWindowIfNeeded] ;
}

- (void)mouseDown:(NSEvent *)theEvent
{
	// Get min and max sizes of the first sub view from the split view  
delegate if there is one...

_min = 0.0 ;
_max = [splitView frame].size.width - [splitView dividerThickness];
	if ([[splitView delegate]  
respondsToSelector 
:@selector(splitView:constrainMinCoordinate:ofSubviewAt:)])
		_min = [[splitView delegate] splitView:splitView  
constrainMinCoordinate:_min ofSubviewAt:0];
	if ([[splitView delegate]  
respondsToSelector 
:@selector(splitView:constrainMaxCoordinate:ofSubviewAt:)])
		_max = [[splitView delegate] splitView:splitView  
constrainMaxCoordinate:_max ofSubviewAt:0];


	_isLeftResizer = [self isDescendantOf:[[splitView subviews]  
objectAtIndex:0]];


_offset = _isLeftResizer ?
		[self frame].size.width - [self convertPoint:[theEvent  
locationInWindow] fromView:nil].x		:

[self convertPoint:[theEvent locationInWindow] fromView:nil].x ;
}

On Mar 11, 2009, at 10:52 AM, Mike Manzano wrote:

Nope that didn't do it. Same symptoms. Any other ideas before I  
throw in the gauntlet and rewrite it?


On Mar 10, 2009, at 5:41 PM, Jesper Storm Bache wrote:

When you modify a window it registers itself as needing redrawing  
in the current run loop.
If you are performing active tracking, you may have to do so  
yourself.
Try calling [window flushWindowIfNeeded] on your window at the  
end of your loop (inside the loop).


What is the reason for your explicit tracking?
You should be able to simply listen for mouseDragged, mouseDown,  
and mouseUp on your split view (if this is a custom sub-class).

Jesper Storm Bache

On Mar 10, 2009, at 2:51 PM, Mike Manzano wrote:


Hi,

I am tracking the mouse pointer to dynamically resize a splitter  
as a

separate drag handle is dragged. This is done in mouseDown: of the
drag handle with a custom event loop. The loop looks like this:

while (keepOn)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
theEvent = [[self window] nextEventMatchingMask:
NSAnyEventMask] ;// NSLeftMouseUpMask | NSLeftMouseDraggedMask];

switch ([theEvent type])
{
case NSLeftMouseUp:
keepOn = NO;
break;

case NSLeftMouseDragged:
[nc  
postNotificationName:NSSplitViewWillResizeSubviewsNotification

object:splitView];
 

Re: problems with NSTextField destroying background

2009-03-11 Thread Benjamin Stiglitz
> My problem is, I want the NSTextField to be transparent (and show the  
> NSBox behind), but instead it's making a hole in the NSBox to show the  
> desktop, what am I missing?

For historical reasons the NSTextField fills its content with
NSRectFill, which uses the NSCompositeCopy compositing operation instead
of NSCompositeSourceOver. This will blow out your window content. Please
do file a Radar if you’d like to see this fixed.

Can you show us a picture of what your UI looks like? We may be able to
suggest an alternate solution.

-Ben
___

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

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

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

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


Time Zone Names

2009-03-11 Thread Rick Mann
According to the docs, acceptable time zone names include names like  
"US/Pacific". What are the other names that can be used? Central,  
Mountain, Atlantic? What's Hawaii's in this style?


I can't find "US/*" names in the list supplied by [NSTimeZone  
knownTimeZoneNames], or in online sources.


Thanks!

--
Rick

___

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: State of performing tasks with elevated privileges

2009-03-11 Thread Nick Zitzmann


On Mar 11, 2009, at 12:52 PM, Sidney San Martín wrote:

"You may be tempted to use the function  
AuthorizationExecuteWithPrivileges to perform privileged operations  
rather than creating and calling your own setuid tool. Although this  
might seem like an easy solution, using the  
AuthorizationExecuteWithPrivileges function without the rest of the  
Authorization Services functions produces a severe security hole  
because the function indiscriminately runs any tool as the root  
user. Setuid tools also have security risks, but they are far less  
severe than using the function AuthorizationExecuteWithPrivileges  
for purposes other than those described in this document. Read  
“Factored Applications” for instructions on creating your own helper  
tool."


I don't completely follow that warning. If I have a factored helper  
tool, is it important for it to be setuid root?


What it's saying is AEWP() will run pretty much anything you tell it  
to run. That is not always a good thing, because the secure tool can  
be swapped by some malware, which would cause AEWP() to run the wrong  
tool. This is one of the few cases where running a tool as setuid root  
actually makes sense, since the tool can't be swiped without  
permission. There used to be problems with this, but they were  
resolved a long time ago.


Of course, that requires someone to write malware that intentionally  
targets your app. And in the eight year history of Mac OS X (nine  
years if you count Rhapsody), no one has written a single virus, and  
trojan and rootkit attacks have been extremely rare. So the chances of  
this happening in the first place are very, very low, unless something  
stupendous happens (e.g. Apple picks up your app for OEM distribution).


Of course, if you're just going to use AEWP() to run something once  
in /usr/bin or some other place that has strict write permissions,  
then this doesn't matter.


What, even, is the advantage of using the complex libraries  
contained in MoreSecurity and BetterAuthorizationSample. Do people  
not use them in the real world?



In the real world, people care about feeling secure, but no one cares  
about actually being secure until they get compromised, because actual  
security means sacrificing convenience. Mac OS 8 had a CD auto-play  
feature (ripped from Windows) that ended up being taken out of the OS  
after the only software that used it was a worm.


Nick Zitzmann




___

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: Time Zone Names

2009-03-11 Thread A.M.


On Mar 11, 2009, at 3:15 PM, Rick Mann wrote:

According to the docs, acceptable time zone names include names like  
"US/Pacific". What are the other names that can be used? Central,  
Mountain, Atlantic? What's Hawaii's in this style?


I can't find "US/*" names in the list supplied by [NSTimeZone  
knownTimeZoneNames], or in online sources.



Look here:

ls /usr/share/zoneinfo/

from

http://www.twinsun.com/tz/tz-link.htm

Cheers,
M
___

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: problems with NSTextField destroying background

2009-03-11 Thread Joel Norvell

Hi Memo,

Try doing

setDrawsBackground:NO

when you initialize your NSTextFields.

HTH,
Joel




  
___

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: Time Zone Names

2009-03-11 Thread Nick Zitzmann


On Mar 11, 2009, at 1:15 PM, Rick Mann wrote:

According to the docs, acceptable time zone names include names like  
"US/Pacific". What are the other names that can be used? Central,  
Mountain, Atlantic? What's Hawaii's in this style?


If you'd like to know, then take a look at the contents of the  
directory /usr/share/zoneinfo.


I can't find "US/*" names in the list supplied by [NSTimeZone  
knownTimeZoneNames], or in online sources.



That's because they were taken out in Leopard. Several other  
countries' were as well.


Nick Zitzmann




___

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: Odd interaction of NSTrackingArea behaviour with drag and drop [BUG?]

2009-03-11 Thread Luke Evans
Well, further playing strongly suggests this is a bug to me (and I'll  
log it as such).


The stuttering ...mouseEntered-mouseExited...mouseEntered- 
mouseExited... events as you drag within a single tracking area happen  
even in the simplest NSView:

http://idisk.mac.com/luke_e-Public/TrackingTesterDragDrop2.zip
(58KB)

The frequency at which the paired events arrive, for essentially a  
constant velocity of mouse movement seems to vary.  Sometimes, you get  
very regular events tracking the mouse left-to-right, and only very  
occasional events tracking right-to-left, sometimes its 'smooth' (but  
still paired out-in) in both directions, or very sketchy in any  
direction.  This is pure conjecture, but it's almost as if you  
intersect with some other event stream generated periodically  
internally (like the thing that generates "draggingUpdated" events  
every 50/60 ms or so, and where the generation of mouse events occur  
with relation to this determines whether you'll get mouseExit- 
mouseEntered emitted, and whether they have a constant period (perhaps  
when you happen to get 'in between' the periodic drag events) or not.   
It certainly looks like there are some kinds of timing boundaries that  
are interacting.


There are no mouseDragged events sent while you drag over the tracking  
area (though the window for them arriving is minimal as the tracking  
stuff ends each pair with "mouseExited").


It looks like I'm going to have to code a parallel hit-testing  
mechanism for when the user is dragging items in from another app.   
Unless there's some magic here, the NSTrackingArea stuff that handles  
this in all other situations is simply gaga in this case.


-- lwe



On 10-Mar-09, at 8:43 PM, Luke Evans wrote:


For the curious, the test app is available at:
http://idisk.mac.com/luke_e-Public/TrackingTesterDragDrop.zip
(61.2 KB)

On 10-Mar-09, at 7:41 PM, Luke Evans wrote:
I have a test app that recreates the problem in what I consider a  
reasonably sterile environment..




___

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: Time Zone Names

2009-03-11 Thread Rick Mann


On Mar 11, 2009, at 12:25:49, Nick Zitzmann wrote:



On Mar 11, 2009, at 1:15 PM, Rick Mann wrote:

According to the docs, acceptable time zone names include names  
like "US/Pacific". What are the other names that can be used?  
Central, Mountain, Atlantic? What's Hawaii's in this style?


If you'd like to know, then take a look at the contents of the  
directory /usr/share/zoneinfo.


I can't find "US/*" names in the list supplied by [NSTimeZone  
knownTimeZoneNames], or in online sources.



That's because they were taken out in Leopard. Several other  
countries' were as well.


Huh. They seem to exist in /usr/share/zoneinfo:

$ pwd
/usr/share/zoneinfo/US
$ ls
Alaska		Aleutian	Arizona		Central		East-Indiana	Eastern		Hawaii		 
Indiana-Starke	Michigan	Mountain	Pacific		Samoa



I'm actually running code in the iPhone simulator right now. Should  
these lists be the same across SDKs on Mac OS X 10.5+?



--
Rick

___

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: Time Zone Names

2009-03-11 Thread Rick Mann


On Mar 11, 2009, at 12:29:05, Philip Ershler wrote:

From the Date & Time control panel Hawaii seems to be HST (ST  
denoting standard time I believe. Central is currently CDT (for  
daylight savings). Mountain is MDT, Eastern is EDT and Atlantic is  
ADT.


Thanks. The problem I'm facing is that I want to specify time zones in  
a way that allows automatic adjustment for DST. Specifying "EDT" or  
"EST" or event "GMT+05:00" locks me in to one or the other, regardless  
of what's currently in effect in the time zone.


--
Rick

___

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: Time Zone Names

2009-03-11 Thread Nick Zitzmann


On Mar 11, 2009, at 2:14 PM, Rick Mann wrote:

I can't find "US/*" names in the list supplied by [NSTimeZone  
knownTimeZoneNames], or in online sources.


That's because they were taken out in Leopard. Several other  
countries' were as well.


Huh. They seem to exist in /usr/share/zoneinfo



What I meant was, they still exist in /usr/share/zoneinfo, but they  
are no longer returned by +knownTimeZoneNames as of Leopard. They were  
in Tiger and earlier.


Nick Zitzmann




___

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: Time Zone Names

2009-03-11 Thread Rick Mann


On Mar 11, 2009, at 13:16:33, Nick Zitzmann wrote:



On Mar 11, 2009, at 2:14 PM, Rick Mann wrote:

I can't find "US/*" names in the list supplied by [NSTimeZone  
knownTimeZoneNames], or in online sources.


That's because they were taken out in Leopard. Several other  
countries' were as well.


Huh. They seem to exist in /usr/share/zoneinfo



What I meant was, they still exist in /usr/share/zoneinfo, but they  
are no longer returned by +knownTimeZoneNames as of Leopard. They  
were in Tiger and earlier.


I see. Do you know why that was done?

--
Rick

___

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: Time Zone Names

2009-03-11 Thread Nick Zitzmann


On Mar 11, 2009, at 2:18 PM, Rick Mann wrote:


I see. Do you know why that was done?



No. I can only guess that they were redundant...

Nick Zitzmann




___

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

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

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

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


subclassing UIScrollView

2009-03-11 Thread David Cake
	I've sub-classed UI Scroll view. Ultimately, what I am trying 
to do is allow scrolling in only certain directions. Just using a 
delegate, I can determine which direction scrolling is taking place 
it, but there doesn't seem to be any way I can do anything about it 
until it is over.


My subclass of UIScrollView is loaded - but my versions of
- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent 
*)event inContentView:(UIView *)view;

and
- (BOOL)touchesShouldCancelInContentView:(UIView *)view;
don't seem to ever be called. I've tried various settings of 
delaysContentTouches and CanCancelContentTouches.

Any advice  appreciated.
Regards
David
___

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


NSMenuItem Binding Problem

2009-03-11 Thread Adil Saleem
Hi,
 
I am having a little difficulty with bindings of NSMenuItem. I am binding 
it's value with an integer variable (as it says in the documentation online). 
The value 1 is supposed to set it's state ON and 0 to OFF and -1 to mixed 
state. 
 
However, the problem is that the actual state of the menu is not getting 
changed with change in the variable value. I have verified, the connection is 
properly created. The state of MenuItem gets changed if the value of variable 
is changed inside an IBAction. But if value is changed in some other normal 
function (non-IBAction), the state does not change. 
 
Please guide. 
 
Thank You



___

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

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

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

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


Re: subclassing UIScrollView

2009-03-11 Thread David Duncan

On Mar 11, 2009, at 2:39 PM, David Cake wrote:

	I've sub-classed UI Scroll view. Ultimately, what I am trying to do  
is allow scrolling in only certain directions. Just using a  
delegate, I can determine which direction scrolling is taking place  
it, but there doesn't seem to be any way I can do anything about it  
until it is over.



The UIScrollView automatically enables horizontal or vertical  
scrolling depending on the contentSize, and can disable horizontal or  
vertical scrolling when the user scrolls along the other axis by  
enabling directional lock. If you could explain what kinds of  
scrolling you want to enable/prohibit it would be easier to advise you.

--
David Duncan
Apple DTS Animation and Printing

___

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


Is cascading Nib Loading from -awakeFromNib permissible?

2009-03-11 Thread Stuart Malin
In my MainMenu Nib I have a controller object. The code for that  
controller object has an -awakeFromNib method. That method invokes  
NSBundle's -loadNibNamed: method to load yet another Nib. Doing this  
leads to repeating invocations of the -awakeFromNib method of the  
initial controller (it is the same object, not new ones).


Now, that leads me to think: just add an ivar flag that is set before  
invoking -loadNibNamed: so that a subsequent invocation of the  
controller's -awakeFromNib can ignore the secondary call. So I do  
this... and everything *appears* to work. But... I am concerned this  
may not be safe. Perhaps Nib loading is not re-entrant,  even in the  
same thread.  Question: Is what I am doing safe, dangerous, or does  
that not matter and my architecture/approach is not a good practice?

___

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 cascading Nib Loading from -awakeFromNib permissible?

2009-03-11 Thread Stuart Malin


On Mar 11, 2009, at 12:37 PM, Dave Keck wrote:


It looks like this is your answer:

http://lists.apple.com/archives/cocoa-dev/2008/Apr/msg02276.html

It sounds like the object is the file's owner of the nibs that you're
loading using loadNibNamed:. Is this correct?

Also check out:
http://www.google.com/search?client=safari&rls=en-us&q=awakefromnib+called+twice&ie=UTF-8&oe=UTF-8

David


Appreciate the links Dave, but these don't shed light on my situation  
(and, I had found these and others in queries before I posted to the  
list). I am getting infinite calls, not double calls. Further, the  
second Nib I am loading has no references back to the controller,  
except as File's Owner. I know this because to shed light on the  
situation, I am loading a Nib that I created in IB but added nothing  
to it nor changed any of its attributes or properties.



___

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


Karaoke like algorithm

2009-03-11 Thread Ariel Rodriguez
I'm working on a Karaoke-like application. I need to print out to the  
screen text lines at a given time, and then, paint each word at a  
given time. I keep thinking on an elegant way to do such that, and, i  
hace to tell, i am afraid, i have not get it right :(.

Here's what i am doing (in pseudocode to keep things simple)
First, i store the time the line is supposed to show on the screen,  
the time it is supposed to disappear from the screen, and an array  
with the words and the time each word is supposed to be painted. All  
times are stored as seconds.
When the application boot, i set and NSTimer to the amount of time i  
need to wait for the first line to appear on screen. When time  
elapsed, NStimer calls a function where i build UILabels for each  
word, insert them in the main UIView. Once the UIView is packed with  
all the UILabels, i fire a new loop to walk the UILabels array and  
paint the words when needed.
Specifically, i am wondering if there is a better way to write words  
to a UIView (and keep a handle to paint them at a given time). Does  
anyone get a better algorithm?

best regards
___

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 cascading Nib Loading from -awakeFromNib permissible?

2009-03-11 Thread Ken Thomases

On Mar 11, 2009, at 5:49 PM, Stuart Malin wrote:


I am getting infinite calls, not double calls.


It sounds to me like you're getting double calls and you're turning  
them into infinite calls.  If you load a nib inside of -awakeFromNib,  
and you don't guard against being called again, you'll load the nib  
again, get -awakeFromNib again, load the nib again, ... infinitely.


Further, the second Nib I am loading has no references back to the  
controller, except as File's Owner.


And that's enough to get awakeFromNib'd.

From the documentation for the awakeFromNib method:

"It is recommended that you maintain a one-to-one correspondence  
between your File’s Owner objects and their associated nib files.  
Loading two nib files with the same File’s Owner object causes that  
object’s awakeFromNib method being called twice, which could cause  
some data structures to be reinitialized in undesired ways. It is also  
recommended that you avoid loading other nib files from your  
awakeFromNib method implementation."


So, you're going against Apple's recommendation in two ways.

Regards,
Ken

___

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

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

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

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


Re: Is cascading Nib Loading from -awakeFromNib permissible?

2009-03-11 Thread Stuart Malin


On Mar 11, 2009, at 1:03 PM, Ken Thomases wrote:


On Mar 11, 2009, at 5:49 PM, Stuart Malin wrote:


I am getting infinite calls, not double calls.


It sounds to me like you're getting double calls and you're turning  
them into infinite calls.  If you load a nib inside of - 
awakeFromNib, and you don't guard against being called again, you'll  
load the nib again, get -awakeFromNib again, load the nib again, ...  
infinitely.


Ah, sure enough, because that re-invocation of my -awakeFromNib then  
invoked -loadNibNamed: which gets a circular mess in motion.


My apologies to you, Dave, for not realizing this "double" call was in  
fact the issue.




Further, the second Nib I am loading has no references back to the  
controller, except as File's Owner.


And that's enough to get awakeFromNib'd.

From the documentation for the awakeFromNib method:


"It is recommended that you maintain a one-to-one correspondence  
between your File’s Owner objects and their associated nib files.  
Loading two nib files with the same File’s Owner object causes that  
object’s awakeFromNib method being called twice, which could cause  
some data structures to be reinitialized in undesired ways. It is  
also recommended that you avoid loading other nib files from your  
awakeFromNib method implementation."


http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSNibAwaking_Protocol/Reference/Reference.html


So, you're going against Apple's recommendation in two ways.


Sseems so.

In regard to the first recommendation I am going against (one-to-one  
correspondence):


Interesting -- there must be some further distinctions here. I have  
another controller, not instantiated by being included in a Nib file,  
but by alloc & init. This controller manages an ensemble of entities  
that are each loaded from (distinct) Nib files. This controller  
receives no calls to an -awakeFromNib method (I didn't have one there,  
but just put one there to see if it would receive calls for each Nib  
loaded). So, this scenario of receiving -awakeFromNib calls as a  
consequence of being some loaded nib's File's Owner seems to depend on  
just how the object invoking -loadNibNamed: was itslef invoked.


btw: I know that the IBOutlets in the controller associated with  
File's Owner that are linked in IB to objects there get over-written  
on loading of each Nib file. After loading each Nib, I copy the outlet  
values that I need, storing them in collection objects (happen to be  
using dictionaries). This controller works just fine,  and handling  
the architecture this way allows me to have distinct Nibs rather than  
one rather cluttered Nib, (as each of the distinct Nibs has views and  
controllers of its own), yet all are managed by one in the same  
controller.


In regards to the second recommendation I am going against (avoid  
loading nib files from awakeFromNib)):


This is worded as a "recommendation" so, I'm presuming that if  
properly handled to avoid recursion and multiple initializations, then  
this is otherwise safe.


I'm going to continue down this path as architecturally it works for  
me. I appreciate the quick replies, and the comments made do alert me  
to the effects I need to design around. Thanks again.



___

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

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

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

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


Re: How to get all directories and folders in Tree format

2009-03-11 Thread Graham Cox


On 11/03/2009, at 5:58 PM, haresh vavdiya wrote:


Hi All,

   In my application, i have to display all the directories and  
folders
of these directory on left side and user can reach their particular  
folder
and he can get all content of that folder. Like, we want to open  
Examples

folder and then we will select Developer and then example from list..

Does anyone how can i develop this tings.



here's one way:

http://apptree.net/gcfolderbrowser.htm

enjoy!

--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: Garbage collected and non-garbage collected

2009-03-11 Thread Greg Parker


On Mar 11, 2009, at 4:31 PM, Robert Mullen wrote:

Approach 2 seems appealing but my initial go at it went less than  
sterling. All access to the struct appears to be incorrect and  
whereas most of the data contained before seemed to have integrity  
now it almost immediately bombs with either EXC_BAD_ACCESS or it  
gets an object other than what it was expecting. Which it gets is  
pretty well random to my eyes making debugging a bit of an  
adventure. What I did was to mark all the pointer types in the  
struct with __strong so where it used to look like:


[...]

Good.



I then changed the calloc()s to use NSAllocateCollectable:

_SM2DGraphView_Private = calloc( 1, sizeof(SM2DPrivateData) );

becomes

_SM2DGraphView_Private = NSAllocateCollectable(sizeof 
(SM2DPrivateData), NSScannedOption);


The collector treats this struct as a garbage-collected block, which  
won't work unless you find all pointers to this struct and make the  
same __strong / NSAllocateCollectable changes to them. If you add  
NSCollectorDisabledOption, then this struct works more like ordinary  
memory that you have to free() by hand.


In particular, the code I found on the Internet has  
_SM2DGraphView_Private as a void* ivar. The collector does not look  
for GC pointers inside void* ivars, so without  
NSCollectorDisabledOption it'll throw the object away. Either add  
NSCollectorDisabledOption() and free() the struct later; or make  
_SM2DGraphView_Private a `__strong void *` and don't free it; or make  
SM2DPrivateData a real Objective-C class and _SM2DGraphView_Private an  
`SM2DPrivateData *`.



(Should this be _SM2DGraphView_Private = (SM2DPrivateData *) 
NSAllocateCollectable(sizeof(SM2DPrivateData), NSScannedOption);  
instead?)


Doesn't matter for GC purposes.



and assignment to the struct members is done like this:

myPrivateData->borderColor = [ [ NSColor blackColor ] retain ];

Do I need to remove the copy and retain semantics from each of these  
as well? I was under the impression that the GC would just ignore  
these since it was using its own cleaning mechanism and that they  
could be left as is.


You're correct. -retain is ignored when GC is on. (CFRetain is not  
ignored. If there are any CFRetain or CFRelease calls in the code, or  
any CFCreate or CFCopy calls, then you may need more work to make  
retain counts balance. CFRetain and -retain are not toll-free under GC.)



I am not sure where to go from here. I beat my head against it a  
fair bit today and am learning more about GC and non-GC code but am  
struggling to get over the hump. I am going to crack open the  
Hillegass book again tomorrow and reread the GC chapter in hope that  
a light bulb will go off. From what I read today though I would have  
thought the above would have worked.


Interfacing GC code with ordinary C code is hard. There are lots of  
holes to fall into, and it's hard to tell where they are until you  
crash.



--
Greg Parker gpar...@apple.com Runtime Wrangler


___

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


Weak Linking Crash

2009-03-11 Thread Simone Manganelli
So I'm trying to weak link the SDL_mixer framework (svn source  
avaliable here: http://svn.libsdl.org/trunk/SDL_mixer ) to a Cocoa  
project, the Mac OS X port of Descent 2 (svn source available here: https://d2x-xl.svn.sourceforge.net/svnroot/d2x-xl 
 ).


I've followed the instructions on Apple's website about weak linking  
(see http://developer.apple.com/DOCUMENTATION/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html 
 ).  Specifically, I've added "-weak_framework SDL_mixer" in my Other  
Linker Flags build setting.


Here's the problem: weak linking works well under *unoptimized*  
builds, but fails in *optimized* builds.  The program launches  
correctly both with and without SDL_mixer present when unoptimized.   
However, as soon as I turn on optimization, the program crashes when  
the SDL_mixer framework is not present.  The optimized build continues  
to work fine when the SDL_mixer framework *is* present.


Since I'm shipping an optimized version, weak linking in this case is  
useless, because it provides no benefit over not weak linking.  The  
program simply crashes if SDL_mixer is not present, no matter if it  
has been weak linked or not.


The crash seems to occur *before* any code in my application; it  
crashes when trying to send an appDidFinishLaunching notification.   
Here is a partial stack trace:



Thread 0 Crashed:
0   ??? 00 0 + 0
1   de.descent2.d2x-xl  0x0008bda3 0x1000 + 568739
2   de.descent2.d2x-xl  0x0008f7ed 0x1000 + 583661
3   de.descent2.d2x-xl  0x0008fb9c 0x1000 + 584604
4   de.descent2.d2x-xl  0x00057fc3 0x1000 + 356291
5   com.apple.Foundation0x90b53f1c _nsnote_callback + 364
6   com.apple.CoreFoundation  	0x93ea38da __CFXNotificationPost  
+ 362
7   com.apple.CoreFoundation  	0x93ea3bb3  
_CFXNotificationPostNotification + 179
8   com.apple.Foundation  	0x90b51080 -[NSNotificationCenter  
postNotificationName:object:userInfo:] + 128
9   com.apple.Foundation  	0x90b5a8c8 -[NSNotificationCenter  
postNotificationName:object:] + 56
10  com.apple.AppKit  	0x91c8f49a -[NSApplication  
_postDidFinishNotification] + 125
11  com.apple.AppKit  	0x91c8f3a9 -[NSApplication  
_sendFinishLaunchingNotification] + 77
12  com.apple.AppKit  	0x91c08ec3 - 
[NSApplication(NSAppleEventHandling) _handleAEOpen:] + 284
13  com.apple.AppKit  	0x91c086bc - 
[NSApplication(NSAppleEventHandling)  
_handleCoreEvent:withReplyEvent:] + 98
14  com.apple.Foundation  	0x90b7943f -[NSAppleEventManager  
dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 655
15  com.apple.Foundation  	0x90b7914f  
_NSAppleEventManagerGenericHandler + 223
16  com.apple.AE  	0x916b1648  
aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned  
char*) + 144
17  com.apple.AE  	0x916b157e  
dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 44


The whole crash report can be found here: http://homepage.mac.com/simx/weak_linking_crash_log.txt 
 .


Anybody know what's going on here and how to solve it?  The intarwebs  
and the Googles don't seem to be providing anything relevant.


Thanks in advance for any assistance.

-- Simone
___

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: Weak Linking Crash

2009-03-11 Thread Greg Parker

On Mar 11, 2009, at 5:47 PM, Simone Manganelli wrote:
So I'm trying to weak link the SDL_mixer framework (svn source  
avaliable here: http://svn.libsdl.org/trunk/SDL_mixer ) to a Cocoa  
project, the Mac OS X port of Descent 2 (svn source available here: https://d2x-xl.svn.sourceforge.net/svnroot/d2x-xl 
 ).


I've followed the instructions on Apple's website about weak linking  
(see http://developer.apple.com/DOCUMENTATION/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html 
 ).  Specifically, I've added "-weak_framework SDL_mixer" in my  
Other Linker Flags build setting.


Here's the problem: weak linking works well under *unoptimized*  
builds, but fails in *optimized* builds.  The program launches  
correctly both with and without SDL_mixer present when unoptimized.   
However, as soon as I turn on optimization, the program crashes when  
the SDL_mixer framework is not present.  The optimized build  
continues to work fine when the SDL_mixer framework *is* present.


Since I'm shipping an optimized version, weak linking in this case  
is useless, because it provides no benefit over not weak linking.   
The program simply crashes if SDL_mixer is not present, no matter if  
it has been weak linked or not.


The crash seems to occur *before* any code in my application; it  
crashes when trying to send an appDidFinishLaunching notification.   
Here is a partial stack trace:



Thread 0 Crashed:
0   ??? 00 0 + 0
1   de.descent2.d2x-xl  0x0008bda3 0x1000 + 568739
2   de.descent2.d2x-xl  0x0008f7ed 0x1000 + 583661
3   de.descent2.d2x-xl  0x0008fb9c 0x1000 + 584604
4   de.descent2.d2x-xl  0x00057fc3 0x1000 + 356291
5   com.apple.Foundation0x90b53f1c _nsnote_callback + 364
6   com.apple.CoreFoundation  	0x93ea38da __CFXNotificationPost  
+ 362
7   com.apple.CoreFoundation  	0x93ea3bb3  
_CFXNotificationPostNotification + 179
8   com.apple.Foundation  	0x90b51080 - 
[NSNotificationCenter postNotificationName:object:userInfo:] + 128


Those top few frames sure look like they're in your code  
("de.descent2.d2x-xl"). Try running an unstripped Release build to get  
a better backtrace.


It looks like it crashed because it called a NULL function pointer,  
because the PC is zero. That's consistent with either "you called a  
weak-linked function without checking for NULL first" or "compiler  
optimized away your NULL check". The fact that an unoptimized build  
works suggests the latter, but you should find the bad call and check  
for sure.


-weak_framework often doesn't work by itself. If the function  
declaration isn't marked weak_import in the header file, then the  
compiler may optimize out your `function != NULL` check and call the  
weak-linked function anyway.


This workaround might help defeat the optimizer:

// was: if (&function != NULL) function();
void * volatile function_p = &function;
if (function_p != NULL) function();


--
Greg Parker gpar...@apple.com Runtime Wrangler


___

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: State of performing tasks with elevated privileges

2009-03-11 Thread Michael Ash
On Wed, Mar 11, 2009 at 3:22 PM, Nick Zitzmann  wrote:
> What it's saying is AEWP() will run pretty much anything you tell it to run.
> That is not always a good thing, because the secure tool can be swapped by
> some malware, which would cause AEWP() to run the wrong tool. This is one of
> the few cases where running a tool as setuid root actually makes sense,
> since the tool can't be swiped without permission. There used to be problems
> with this, but they were resolved a long time ago.

Of course, you still have to call AEWP to make it suid root, and
things can be taken over at that time. Using a suid root tool reduces
your exposure to AEWP, but doesn't eliminate it.

Overall, the way I see it, trying to use AEWP safely is like
installing triple locks on the door to a house with no walls. There
are *so* many ways a piece of evil software can gain root privileges
without exploiting a race condition in some other program's use of
AEWP. Not to mention, root is overrated anyway: all root does is allow
the evil process to fiddle with system files that nobody really cares
about. Deleting the user's documents and swiping their credit card
numbers can be done without any elevated privileges at all.

Mike
___

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

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

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

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


Re: Poof! Recently-saved Core Data document suddenly gets dirty

2009-03-11 Thread Dave Fernandes
I recently had this problem when opening existing documents in Tiger.  
No problem in Leopard. It helped me figure out what was changing by  
overriding willChangeValueForKey in my NSManagedObject subclass. (You  
are never supposed to do this in shipping code.)


#ifdef DEBUG_MANAGED_OBJECT_CHANGES
// Override to debug.
- (void)willChangeValueForKey:(NSString*)key
{
BOOL isUndoing = [[[self managedObjectContext] undoManager] isUndoing];
NSLog(@"%...@%@ willChangeValueForKey: %@", isUndoing ? @"undo " : @"",
[[self entity] name], key);
[super willChangeValueForKey:key];
}
#endif

In the end, my kludge was to fetch the contents of the  
NSObjectController bound to the spontaneously changing object in  
windowDidLoadNib. It's harmless enough, and it fixed the problem,  
though I'd still like to know why.


Dave

On Jan 24, 2009, at 1:44 AM, Jerry Krinock wrote:

In my Core Data Document-Based application, I have a menu item  
which imports settings from a legacy application.  For each setting  
found, it programatically creates a new document, saves it, and  
leaves the new document window open.  When all done, the user gets  
a modal dialog showing a list of what was imported.


This works fine, except when importing some setting datasets,  
sometimes, after the modal dialog has been displayed, often 2  
seconds later -- poof -- the created document receives an  
updateChangeCount: message, and in its window, the 'close' button  
becomes dirty.  During other program runs with the same data, this  
does not happen until after I dismisses the modal dialog.  Very  
weird.  In either case, my observer of  
NSManagedObjectContextObjectsDidChangeNotification does ^not^  
receive any notification when the document gets dirtied.  What  
could dirty the document without triggering this notification?


To investigate, I saved the dirty document with a new name,  
thinking that whatever changed would be different between the two  
xml files.  One of my entities has an attribute which is a  
transformable ("encodable") dictionary of a few short strings.  The  
only significant difference I see between the two files is that,  
for one of my objects, the base64 representation of these  
dictionaries is different.  Re-reading both documents into my app  
with some extra logging however, they both decode to exactly the  
same key/value pairs.


Examining the xml more closely with BBEdit, in one test I found the  
two encoded dictionaries to be just slightly different, both  
containing exactly 621 base64 characters, but there were two blocks  
of four characters that occur in different locations, and, near the  
end, four characters were different. In another test, the  
differences were more substantial -- character counts were 525 vs  
641, and maybe half of the characters were different.


Apparently, encoding of these dictionaries is non-deterministic, so  
I modified my "supersetters" (methods that set key/value pairs  
within these dictionaries) to make sure that the actual dictionary  
setter is only invoked if there is a genuine difference between the  
new and old values.  [1]  But that did not help, and indeed an  
NSLog placed in an "else" branch of this condition, indicating an  
attempt to re-set a key to the same value, never runs.


I over-rode updateChangeCount: and put a breakpoint in there.  The  
call stack is shown below [2].  Are there any clues in there as to  
what is triggering this extraneous updateChangeCount:?


During the import, some transient properties are set and gotten,  
but this is all complete before the document is saved.


I realize I could probably paper over this problem by disabling  
undo registration during the import, or by sending - 
updateChangeCount:NSChangeCleared when I dismiss my dialog.  But  
I'm worried about not knowing the cause of the weird behavior  
before I ship this thing.


Thanks for reading,

Jerry Krinock

[1]  At any rate, this might cause extraneous undo registrations.   
I've noticed more than once when using others' Core Data apps that  
I sometimes need to click "Undo" seven or eight times times before  
anything happens  :|


[2]  Call Stack for the extraneous updateChangeCount:.  In #0,  
Bookshelf is my NSPersistentDocument subclass.  All the other  
functions are Apple's except for #53, #54 and #55.


#0  0x0003dfdc in -[Bookshelf updateChangeCount:] at Bookshelf.m:1344
#1  0x91fd8e1a in _nsnote_callback
#2  0x9702f8da in __CFXNotificationPost
#3  0x9702fbb3 in _CFXNotificationPostNotification
#4	0x91fd6080 in -[NSNotificationCenter  
postNotificationName:object:userInfo:]

#5  0x91fdf8c8 in -[NSNotificationCenter postNotificationName:object:]
#6  0x9203fc58 in -[NSUndoManager endUndoGrouping]
#7  0x970d6a4c in -[NSSet makeObjectsPerformSelector:withObject:]
#8	0x9201e390 in +[NSUndoManager(NSUndoManagerPrivate)  
_endTopLevelGroupings]

#9  0x90eecefb in NSMenuItemCarbonE

Re: subclassing UIScrollView

2009-03-11 Thread David Cake

At 2:47 PM -0700 11/3/09, David Duncan wrote:

On Mar 11, 2009, at 2:39 PM, David Cake wrote:

	I've sub-classed UI Scroll view. Ultimately, what I am trying 
to do is allow scrolling in only certain directions. Just using a 
delegate, I can determine which direction scrolling is taking place 
it, but there doesn't seem to be any way I can do anything about it 
until it is over.



The UIScrollView automatically enables horizontal or vertical 
scrolling depending on the contentSize, and can disable horizontal 
or vertical scrolling when the user scrolls along the other axis by 
enabling directional lock. If you could explain what kinds of 
scrolling you want to enable/prohibit it would be easier to advise 
you.


	Arbitrary scrolling. Such as 'in this situation, you can 
scroll left, but not right'.

Regards
David
___

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: Weak Linking Crash

2009-03-11 Thread Simone Manganelli

Il giorno Mar 11, 2009, alle ore 6:22 PM, Greg Parker ha scritto:

-weak_framework often doesn't work by itself. If the function  
declaration isn't marked weak_import in the header file, then the  
compiler may optimize out your `function != NULL` check and call the  
weak-linked function anyway.


This workaround might help defeat the optimizer:

  // was: if (&function != NULL) function();
  void * volatile function_p = &function;
  if (function_p != NULL) function();


OK, this seems to be the case.  I found that the code that Apple  
suggests in its Weak Linking documentation to just not work.  Even  
when *un*optimized, the compiler seems to always think the comparison  
in the if statement of the following code is true.


   int result = 0;

   if (MyWeakLinkedFunction != NULL)
   {
   result = MyWeakLinkedFunction();
   }

I have been using the following syntax:

   int result = 0;

   uintptr_t address = (uintptr_t)(MyWeakLinkedFunction);
   if (address != 0u)
   {
   result = MyWeakLinkedFunction();
   }

The compiler likes this when *un*optimized, but it looks like the  
compiler is optimizing this out, too.  I found that when using your  
code, however, that I needed to explicitly cast the function as a  
void* before the compiler would build without errors:


   void * volatile function_p = (void *)&(MyWeakLinkedFunction);
   if (function_p == NULL) {
   result = MyWeakLinkedFunction();
   }

Thanks for your help!  That solved the problem!

-- Simone
___

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: Time Zone Names

2009-03-11 Thread Andrew Thompson
These are called Olsen names. One typically uses a city style. e.g.  
America/New_York, Europe/London.


Which is a bit arbitrary but captures the DST thing well. In theory,  
the timezone ET captures EST and EDT but the 2 letter names are even  
more ambiguous than the 3 letter names, and I am not sure that one  
even exists in the zoneinfo database.


On Mar 11, 2009, at 4:15 PM, Rick Mann wrote:



On Mar 11, 2009, at 12:29:05, Philip Ershler wrote:

From the Date & Time control panel Hawaii seems to be HST (ST  
denoting standard time I believe. Central is currently CDT (for  
daylight savings). Mountain is MDT, Eastern is EDT and Atlantic is  
ADT.


Thanks. The problem I'm facing is that I want to specify time zones  
in a way that allows automatic adjustment for DST. Specifying "EDT"  
or "EST" or event "GMT+05:00" locks me in to one or the other,  
regardless of what's currently in effect in the time zone.





AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside

(see you later space cowboy, you can't take the sky from me)


___

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