Select NSTextField mouse event

2010-02-03 Thread padmakumar

In my Cocoa based application, I am having a user editable NSTextField.
I need to know when the user selects the NSTextField using mouse.
I tried the delegate method controlTextDidChange, but the problem is 
user need to enter an character to get this delegate invoked.
My requirement was when ever user selects the NSTextField, I need to 
know that.

Any inputs on this will be helpful.

Regards
Pappan


___

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: another responder chain docs bug (validateUserInterfaceItem:)

2010-02-03 Thread Jens Miltner


Am 26.01.2010 um 00:31 schrieb Andy Lee:

Semi-related to my previous post, I just filed rdar://7577360 (text  
below).  As far as I can tell, it's a bug in the docs.


--Andy


The Overview at http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSUserInterfaceValidations_Protocol/Reference/Reference.html 
 says: To validate a control, the application calls  
validateUserInterfaceItem: for each item in the responder chain,  
starting with the first responder. If no responder returns YES, the  
item is disabled.


From my experience, this is not what happens.  Rather, it works the  
way Jakob Olesen describes in this post on cocoa-dev:


http://www.cocoabuilder.com/archive/cocoa/168662-validateuserinterfaceitem-and-chaining-actions.html 


1. Find the target for my action
2. Validate using that target and nobody else.

I.e., validateUserInterfaceItem: does not go up the responder chain  
until it gets a YES answer; it goes up the responder chain until it  
finds a target that responds to the action message, meaning the docs  
are incorrect.


Well, in my experience the truth is somewhere between the two:

AppKit seems to go up the responder chain and call  
validateUserInterfaceItem: on each potential target (i.e. each  
responder that responds to the action message and responds to  
validateUserInterfaceItem:) until the first call to  
validateUserInterfaceItem: returns YES.
If none of the potential targets returns YES from  
validateUserInterfaceItem:, the item is disabled.


/jum

___

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: tab view look

2010-02-03 Thread Jens Miltner


Am 26.01.2010 um 23:24 schrieb Dave DeLong:


http://www.positivespinmedia.com/dev/PSMTabBarControl.html


FWIW, the code seems to have moved to google-code, packed as part of http://code.google.com/p/maccode 
.
IIRC, the PSMTabBarControl implementation there has additional  
features like tear-off tabs, etc.


/jum




On Jan 26, 2010, at 3:23 PM, Wesley Smith wrote:


I've been looking around for examples on how to get tab view too look
like they do on Terminal, Safari, etc.  Is there any example code
around?  I've not found any or really any references as to how to
provide a custom look to tabs.

thanks,
wes


___

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: Cloning an NSXMLElement and its children?

2010-02-03 Thread Jeremy Pereira

On 3 Feb 2010, at 00:28, Robert Monaghan wrote:

 Its a fairly deep copy. There are several nodes deep.
 I am trying to copy parts of the tree, so that I don't have to write code to 
 regenerate them.

No.  The question was not is your tree deep? but is the copy method 
implemented by NSXMLNode a deep or shallow copy i.e. does it copy the children 
of the node too or just reference the existing ones.

If it's a deep copy, you should be able to do copyNode = [node copy];


 
 bob.
 
 On Feb 2, 2010, at 4:26 PM, Jens Alfke wrote:
 
 
 On Feb 2, 2010, at 4:16 PM, Robert Monaghan wrote:
 
 Is there an easy way to clone an XML tree in Cocoa? Or will I be going thru 
 recursion code hell?
 
 Did you try -copy? NSXMLNode implements NSCopying. The only question is 
 whether it's a deep or a shallow copy.
 
 —Jens
 
 ___
 
 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/adc%40jeremyp.net
 
 This email sent to a...@jeremyp.net

___

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

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

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

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


Synthesize NSMutableString retain count question

2010-02-03 Thread Philip Vallone
Hi List,

This is probably a very elementary question. I have a NSMutableString that I 
Synthesize. When I assigned a value to it:

currentSection  = @Some value;

The retain count goes to 1

However if I assign a value with

[currentSection setString:@Some value];

The retain count is still zero.

Can someone explain the difference?

Thanks,

Phil


___

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: Synthesize NSMutableString retain count question

2010-02-03 Thread Alexander Spohr

 currentSection  = @Some value;
has nothing to do with
 [currentSection setString:@Some value];

The first sets currentSection to a string, the second sets the content of 
currentSection.

a) In the second line you just set the content but you never assigned an 
NSMutableString to currentSection before. Therefore the call is ignored and 
currentSection itself stays nil.

b) The first line should throw a warning as @Some value is not mutable. It is 
an error.

atze


Am 03.02.2010 um 12:55 schrieb Philip Vallone:

 Hi List,
 
 This is probably a very elementary question. I have a NSMutableString that I 
 Synthesize. When I assigned a value to it:
 
 currentSection  = @Some value;
 
 The retain count goes to 1
 
 However if I assign a value with
 
 [currentSection setString:@Some value];
 
 The retain count is still zero.
 
 Can someone explain the difference?
 
 Thanks,
 
 Phil
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/atze%40freeport.de
 
 This email sent to a...@freeport.de

___

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

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

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

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


Help with NSData dataWithContentsOfURL

2010-02-03 Thread cocoa-dev
I have an app that attaches a file to a document like when you attach a file to 
mail.  I use the following to store the file as data in an iVar:

fileData = [NSData dataWithContentsOfURL:url options:NSDataReadingUncached 
error:(NSError **)errorPtr];

This works fine for regular files but not for fileWrappers or folders 
(EXEC_BAD_ACCESS).  I haven't found anything in the documentation that will 
work and am now thinking I need to use an alternate strategy like storing the 
files in a fileWrapper and abandoning storing them as data all together.

Is there an alternative to capture the data of a wrapper and a folder?

Thanks___

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: Help with NSData dataWithContentsOfURL

2010-02-03 Thread Graham Cox

On 04/02/2010, at 1:08 AM, cocoa-dev wrote:

 Is there an alternative to capture the data of a wrapper and a folder?

Not really, because of what these things are. At best a folder could be reduced 
to a tree of data objects, which is what a wrapper is. But to reduce an 
arbitrary folder to a single data item is inadvisable as the size of that data 
is potentially unbounded.

You could copy the file/folder to a location within your app's support 
directory and save the path to it, perhaps?

--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: Help with NSData dataWithContentsOfURL

2010-02-03 Thread cocoa-dev
Thanks Graham, here's what I'm thinking.  The documents for my app are 
fileWrappers.  Before the document is saved for the first time I can copy the 
files to a temp folder and during a save move them into the fileWrapper.  I 
guess I need to just abandon the whole NSData idea altogether.  Too bad.

On Feb 3, 2010, at 9:19 AM, Graham Cox wrote:

 
 On 04/02/2010, at 1:08 AM, cocoa-dev wrote:
 
 Is there an alternative to capture the data of a wrapper and a folder?
 
 Not really, because of what these things are. At best a folder could be 
 reduced to a tree of data objects, which is what a wrapper is. But to reduce 
 an arbitrary folder to a single data item is inadvisable as the size of that 
 data is potentially unbounded.
 
 You could copy the file/folder to a location within your app's support 
 directory and save the path to it, perhaps?
 
 --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: Binding to an accessor that is only valid for subclass (was: Node hierarchy with subclasses)

2010-02-03 Thread Mike Abdullah

On 2 Feb 2010, at 06:39, BareFeet wrote:

 On Jan 29, 2010, at 9:38 AM, Jerry Krinock wrote:
 
 
 The problem is that when a subclass A is selected, the UI elements bound to 
 subclass B no longer have valid bindings so generate an error. How can I 
 solve this?
 
 You can also uncheck the Raises For Not Applicable Keys in the bindings 
 inspector pain in Interface Builder for your text fields.
 
 Thanks for the tip. Once I read it, it seemed like the logical solution. 
 However, it doesn't seem to make any difference. All I could find in the 
 documentation about that checkbox/attribute was:
 
 NSRaisesForNotApplicableKeysBindingOption
 An NSNumber object containing a Boolean value that specifies if an exception 
 is raised when the binding is bound to a key that is not applicable—for 
 example when an object is not key-value coding compliant for a key.
 
 
 To recall, I have something like this:
 
 @interface TopClass : NSObject
 {
   // some ivars
 }
 
 // some accessors
 
 @end
 
 @interface SubClass : TopClass
 {
   NSString* subValue;
 }
 
 - (NSString) subValue;
 
 @end
 
 I have an NSTreeController that contains a list of TopClass and SubClass 
 items. The user selects an item in that list.
 
 I have a text field in Interface Builder whose value is bound (ie via 
 bindings) to the subValue accessor, ie: NSTreeController - selection.subValue
 
 Obviously, the subValue accessor is only valid if the currently selected item 
 is a SubClass object. If the user selects a TopClass item, it throws an 
 exception. How can I prevent this?

With Raises for Not Applicable Keys turned off, the exception will still be 
thrown. But, the bound object will catch it and treat as a not applicable 
result.

The only way not to throw the exception in the first place is to make 
-valueForKey: return NSNotApplicableMarker. I'd suggest doing this by 
overriding -valueForUndefinedKey:

___

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


Multithread communication

2010-02-03 Thread McLaughlin, Michael P.
In a multithreaded app using NSOperationQueue and targeting Leopard, I am
having an inordinate amount of trouble communicating the results of the
thread computations to the main thread which acts as an overall coordinator.

Specifically, I am getting obscure and sporadic crashes (about 10 percent of
the time), some citing bad access and others unknown but which seem to
suggest that things are being done when the threads can no longer do them
(or something akin to that).  All of these crashes occur deep in the system,
not in my code.

The threads read data upon initialization but do not write to any structures
but their own.  I have to pass these filled structures back to the main
thread upon completion.  The last thing each thread does is
postNotificationName to the main thread saying that it is ready to return
lots of data which it does via an NSPointerArray
[ptr pointerArrayWithStrongObjects]
and dictionary.  The object which collects the results has a function
getOpResults() which accesses the passed pointer.

I thought that this should all be correct but somehow it crashes, at times
immediately, at other times only when everything is done and, 90 percent of
the time, not at all!  I have attempted various remedies, including a static
NSLock for getOpResults(), retaining the NSOperations for a while in the
main thread, using a dependent signal to say that all threads should be
finished, using a countdown int to say the same thing. So far, nothing has
solved the problem.

The debugger stops showing only assembly and setting a break in
malloc_error_break (cited in some crashes) doesn't seem to do anything.
[Possibly a spurious error location.]

Could someone recommend the best (most robust) way to pass back data from
threads to the main thread?  Is there a good way to probe crashes such as
these?  Right now, I cannot even tell where the error is really occurring.

Thanks.

-- 
Mike McLaughlin

___

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: another responder chain docs bug (validateUserInterfaceItem:)

2010-02-03 Thread Kyle Sluder
On Wed, Feb 3, 2010 at 1:02 AM, Jens Miltner j...@mac.com wrote:
 Well, in my experience the truth is somewhere between the two:

 AppKit seems to go up the responder chain and call
 validateUserInterfaceItem: on each potential target (i.e. each responder
 that responds to the action message and responds to
 validateUserInterfaceItem:) until the first call to
 validateUserInterfaceItem: returns YES.
 If none of the potential targets returns YES from
 validateUserInterfaceItem:, the item is disabled.

Correct.

If a control's target is non-nil, and that target doesn't respond to
the action selector, the control is disabled. If it does respond to
the action selector, and doesn't do UI validation, the control is
enabled. Otherwise, the control is either enabled or disabled
according to the result of calling the UI validation method.

If a control's target is nil (aka First Responder), AppKit walks the
responder chain until it finds a control that responds to the action
selector. If it can't find one, the control is enabled. If it does
find one, logic proceeds as above.

While this has served well for the past 20 years, we find it's not
optimal. We'd like AppKit to continue searching, rather than abort, if
it finds a control that responds to the action selector but doesn't
validate, and we would like targets to be able to add pieces to the
responder chain dynamically (very useful for control delegates).

So Tim wrote OATargetSelection. It lives in our open-sourced
OmniAppKit framework—specifically in -[OAAplication
sendAction:to:from:] and supporting methods. You can find it here:
http://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniAppKit/OAApplication.m

--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: Multithread communication

2010-02-03 Thread Kyle Sluder
On Wed, Feb 3, 2010 at 8:30 AM, McLaughlin, Michael P. mp...@mitre.org wrote:
 In a multithreaded app using NSOperationQueue and targeting Leopard, I am
 having an inordinate amount of trouble communicating the results of the
 thread computations to the main thread which acts as an overall coordinator.

Welcome to multithreaded programming. :)

 Specifically, I am getting obscure and sporadic crashes (about 10 percent of
 the time), some citing bad access and others unknown but which seem to
 suggest that things are being done when the threads can no longer do them
 (or something akin to that).  All of these crashes occur deep in the system,
 not in my code.

They are almost certainly your fault, though. What stinks about
multithreading is that a mistake has an excellent chance of
manifesting itself as a problem somewhere completely unrelated to
where that mistake has been made.

 The threads read data upon initialization but do not write to any structures
 but their own.  I have to pass these filled structures back to the main
 thread upon completion.  The last thing each thread does is
 postNotificationName to the main thread saying that it is ready to return
 lots of data which it does via an NSPointerArray
 [ptr pointerArrayWithStrongObjects]
 and dictionary.  The object which collects the results has a function
 getOpResults() which accesses the passed pointer.

It is not useful to discuss threading problems without the actual code
that you're having trouble with.

 I thought that this should all be correct but somehow it crashes, at times
 immediately, at other times only when everything is done and, 90 percent of
 the time, not at all!  I have attempted various remedies, including a static
 NSLock for getOpResults(), retaining the NSOperations for a while in the
 main thread, using a dependent signal to say that all threads should be
 finished, using a countdown int to say the same thing. So far, nothing has
 solved the problem.

You're thrashing. Threading must be approached from a mindset of correctness.

 Could someone recommend the best (most robust) way to pass back data from
 threads to the main thread?  Is there a good way to probe crashes such as
 these?  Right now, I cannot even tell where the error is really occurring.

The best kind of shared data is no shared data at all. Your threads
should receive copies of the data they need to operate, and return
copies of the data they have computed. Which thread owns the data is
handed off at those return boundaries.

Beyond that, you'll need to post your code. (That is, the actual code
you are feeding the compiler. Pseudocode, descriptions of code, and
redacted versions of code are all useless here.)

--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: Select NSTextField mouse event

2010-02-03 Thread Jerry Krinock

On 2010 Feb 03, at 00:34, padmakumar wrote:

 In my Cocoa based application, I am having a user editable NSTextField.
 I need to know when the user selects the NSTextField using mouse.
 I tried the delegate method controlTextDidChange, but the problem is user 
 need to enter an character to get this delegate invoked.
 My requirement was when ever user selects the NSTextField, I need to know 
 that.

Maybe knowing when it becomes First Responder would work.  NSTextField inherits 
from NSResponder.  From documentation:

-[NSResponder becomeFirstResponder]
Notifies the receiver that it’s about to become first responder in its NSWindow.

- (BOOL)becomeFirstResponder

Discussion
The default implementation returns YES, accepting first responder status. 
Subclasses can override this method to update state or perform some action such 
as


___

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: Multithread communication

2010-02-03 Thread Alexander Spohr

Am 03.02.2010 um 17:30 schrieb McLaughlin, Michael P.:

 Could someone recommend the best (most robust) way to pass back data from
 threads to the main thread?  Is there a good way to probe crashes such as
 these?  Right now, I cannot even tell where the error is really occurring.

Try

- (void)performSelectorOnMainThread:(SEL)aSelector 
withObject:(id)argwaitUntilDone:(BOOL)wait

atze


___

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: Synthesize NSMutableString retain count question

2010-02-03 Thread Jens Alfke


On Feb 3, 2010, at 3:55 AM, Philip Vallone wrote:


currentSection  = @Some value;
The retain count goes to 1


This assigns a new value to the pointer variable 'currentSection'. It  
now points to the immutable string literal @Some value.



However if I assign a value with
[currentSection setString:@Some value];
The retain count is still zero.


This tells the mutable string object that 'currentSection' currently  
points to, to replace its contents with the characters in the string  
@Some value.


If you find the retain count is zero after this, it's probably because  
the value of 'currentSection' is nil, i.e. it doesn't point to any  
object. In that case the -setString: message is a no-op since messages  
to nil are ignored, and -retainCount will return zero because messages  
to nil always return 0/nil.


In general, it sounds as though you're unclear on the distinction  
between an object and a pointer to an object. It's the same as structs  
vs. pointers to structs in C, or for objects in C++; the difference is  
that Objective-C objects can only be referred to by pointers (you  
can't have a variable of type NSString, only NSString*.)


—Jens___

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: Multithread communication

2010-02-03 Thread Jens Alfke


On Feb 3, 2010, at 8:30 AM, McLaughlin, Michael P. wrote:

but their own.  I have to pass these filled structures back to the  
main

thread upon completion.  The last thing each thread does is
postNotificationName to the main thread saying that it is ready to  
return

lots of data which it does via an NSPointerArray
[ptr pointerArrayWithStrongObjects]
and dictionary.  The object which collects the results has a function
getOpResults() which accesses the passed pointer.


My hunch is that the data is sometimes being freed/dealloced before it  
gets to the main thread. Take a careful look at the memory and  
refcount management in the code. (Are your data values objects or just  
structs? You say they're structures, and you're using NSPointerArray,  
but callijng +pointerArrayWithStrongObjects implies you're putting  
objects in the array.)


Setting the environment variable MallocScribble can help catch bugs  
that access freed memory. It causes free() to fill blocks with 0x55  
before freeing them, which often causes a crash when something tries  
to use the freed memory later on.


—Jens___

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: Help with NSData dataWithContentsOfURL

2010-02-03 Thread Fritz Anderson
On 3 Feb 2010, at 8:08 AM, cocoa-dev wrote:

 I have an app that attaches a file to a document like when you attach a file 
 to mail.  I use the following to store the file as data in an iVar:
 
 fileData = [NSData dataWithContentsOfURL:url options:NSDataReadingUncached 
 error:(NSError **)errorPtr];

Side issue: If fileData really is an instance variable holding an NSData, you 
almost certainly want to take ownership of it by retaining it. Doing it as 
you're showing here will result in fileData pointing to a released object the 
next time the current NSAutoreleasePool is drained.

If you're using garbage collection, never mind; you're fine.

— F

___

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


NSFont to CGFontRef

2010-02-03 Thread Andy O'Meara
Hi everyone,

Given an NSFont object how can I extract or create a CGFontRef from it to use 
directly with CoreGraphics?

I've already searched around in the lists and ADC with no luck.  

So far, I've tried the following:

NSFontManager* fm = [NSFontManager sharedFontManager];
NSFont* font = [ fm fontWithFamily:... ];

CFDictionaryRef dict = CFDictionaryCreate( kCFAllocatorDefault, NULL, 
NULL, 0, NULL, NULL );
CGFontRef fontRef = CGFontCreateCopyWithVariations( (CGFontRef) font, 
dict );
CFRelease( dict );

int unitsPerEM = CGFontGetUnitsPerEm( fontRef );   // CRASH!


Thanks in advance!

Andy___

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

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

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

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


Re: NSFont to CGFontRef

2010-02-03 Thread Andy O'Meara


On Feb 2, 2010, at 9:00 PM, Nick Zitzmann wrote:

 
 On Feb 2, 2010, at 10:26 AM, Andy O'Meara wrote:
 
 Given an NSFont object how can I extract or create a CGFontRef from it to 
 use directly with CoreGraphics?
 
 You're close. Starting in (I think) Leopard, NSFont and CTFontRef (not 
 CGFontRef) are toll-free bridged, so you should be able to use 
 CTFontCopyGraphicsFont() to get a CGFontRef from an NSFont.
 


Thanks for the response.

Phew, ok so I'm not going completely crazy then about thinking it's toll-free 
bridged.  :)  

My concern with CoreText is that it rules out 10.4 as I understand it, so 
anyone loading the app under 10.4 will see a message saying that the app can't 
be run, no?

Thanks,
Andy___

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

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

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

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


Re: NSFont to CGFontRef

2010-02-03 Thread Nick Zitzmann

On Feb 3, 2010, at 11:08 AM, Andy O'Meara wrote:

 My concern with CoreText is that it rules out 10.4 as I understand it, so 
 anyone loading the app under 10.4 will see a message saying that the app 
 can't be run, no?

No, it'll just crash unless you set the minimum system requirement key in the 
info plist.

Nick Zitzmann
http://www.chronosnet.com/

___

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

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

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

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


what is the struct of SecKeychainItemRef?

2010-02-03 Thread John Yeh
After a ponter to SecKeychainItemRef is returned, How do I extract (or explore) 
the data from SecKeychainItemRef?
-John___

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

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

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

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


Re: what is the struct of SecKeychainItemRef?

2010-02-03 Thread Nick Zitzmann

On Feb 3, 2010, at 11:29 AM, John Yeh wrote:

 After a ponter to SecKeychainItemRef is returned, How do I extract (or 
 explore) the data from SecKeychainItemRef?

SecKeychainItemCopyContent()?

Nick Zitzmann
http://www.chronosnet.com/

___

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

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

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

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


Re: Help with NSData dataWithContentsOfURL

2010-02-03 Thread Charles Srstka
On Feb 3, 2010, at 8:26 AM, cocoa-dev wrote:

 Thanks Graham, here's what I'm thinking.  The documents for my app are 
 fileWrappers.  Before the document is saved for the first time I can copy the 
 files to a temp folder and during a save move them into the fileWrapper.  I 
 guess I need to just abandon the whole NSData idea altogether.  Too bad.

If you use NSFileWrapper’s initWithURL:options:error method, and then send it 
-serializedRepresentation, you should be able to get an NSData. But be careful 
when doing this, because as has already been mentioned, a directory could 
contain far more data than will fit in RAM.

Charles___

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: what is the struct of SecKeychainItemRef?

2010-02-03 Thread Jens Alfke


On Feb 3, 2010, at 10:29 AM, John Yeh wrote:

After a ponter to SecKeychainItemRef is returned, How do I extract  
(or explore) the data from SecKeychainItemRef?


It's not a struct, it's an opaque CoreFoundation object. Take a look  
at the accessor functions named SecKeychainItemGetXXX or  
SecKeychainItemCopyXXX.


—Jens___

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: NSFont to CGFontRef

2010-02-03 Thread Andy O'Meara

 No, it'll just crash unless you set the minimum system requirement key in the 
 info plist.

Sure, but in terms of supporting our 10.4 customers (which is a significant 
number for us), it seems like we're out of luck wrt to turning a NSFont* into a 
CGFontRef (or namely, creating a CGFontRef from standard attributes).  No doubt 
that there's a twisty and windy way to create a CGFontRef from a font name and 
set of attribs, but I have been unsuccessful thus far with 
CGFontCreateCopyWithVariations() and I've been unable to find any sample code 
that does so (either in ADC or in google).

Oh well, but thanks for your thoughts and suggestions!

Andy



On Feb 3, 2010, at 12:10 PM, Nick Zitzmann wrote:

 
 On Feb 3, 2010, at 11:08 AM, Andy O'Meara wrote:
 
 My concern with CoreText is that it rules out 10.4 as I understand it, so 
 anyone loading the app under 10.4 will see a message saying that the app 
 can't be run, no?
 
 No, it'll just crash unless you set the minimum system requirement key in the 
 info plist.
 
 Nick Zitzmann
 http://www.chronosnet.com/
 

___

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

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

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

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


Re: Multithread communication

2010-02-03 Thread Bill Bumgarner
What Kyle and Jens said, but there is one particular cardiac action impaired 
horse that I wanted to flog...

On Feb 3, 2010, at 8:30 AM, McLaughlin, Michael P. wrote:

 I thought that this should all be correct but somehow it crashes, at times
 immediately, at other times only when everything is done and, 90 percent of
 the time, not at all!  I have attempted various remedies, including a static
 NSLock for getOpResults(), retaining the NSOperations for a while in the
 main thread, using a dependent signal to say that all threads should be
 finished, using a countdown int to say the same thing. So far, nothing has
 solved the problem.

No amount of locking around thread unsafe API will make said API thread safe.   
That is, you can't -- say -- put locks around your calls into the methods of -- 
say -- the AppKit and make the AppKit magically thread safe. 

If you are using locks around code that you didn't write to fix threading 
issues, you aren't actually fixing anything (but you are guaranteed to be 
making for some terribly fun debugging sessions later).

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: another responder chain docs bug (validateUserInterfaceItem:)

2010-02-03 Thread Andy Lee
On Feb 3, 2010, at 11:42 AM, Kyle Sluder wrote:
 On Wed, Feb 3, 2010 at 1:02 AM, Jens Miltner j...@mac.com wrote:
 Well, in my experience the truth is somewhere between the two:
 
 AppKit seems to go up the responder chain and call
 validateUserInterfaceItem: on each potential target (i.e. each responder
 that responds to the action message and responds to
 validateUserInterfaceItem:) until the first call to
 validateUserInterfaceItem: returns YES.
 If none of the potential targets returns YES from
 validateUserInterfaceItem:, the item is disabled.
 
 Correct.
 
 If a control's target is non-nil, and that target doesn't respond to
 the action selector, the control is disabled. If it does respond to
 the action selector, and doesn't do UI validation, the control is
 enabled. Otherwise, the control is either enabled or disabled
 according to the result of calling the UI validation method.
 
 If a control's target is nil (aka First Responder), AppKit walks the
 responder chain until it finds a control that responds to the action
 selector. If it can't find one, the control is enabled. If it does
 find one, logic proceeds as above.

This is my understanding, but it is not quite what Jens wrote.  The difference 
is in when the traversal of the responder chain stops.  As you say, it stops 
with the first object that responds to the action selector, *regardless* of 
whether that object does UI validation, and *regardless* of what UI validation 
(if implemented) returns.

 While this has served well for the past 20 years, we find it's not
 optimal. We'd like AppKit to continue searching, rather than abort, if
 it finds a control that responds to the action selector but doesn't
 validate, and we would like targets to be able to add pieces to the
 responder chain dynamically (very useful for control delegates).
 
 So Tim wrote OATargetSelection. It lives in our open-sourced
 OmniAppKit framework—specifically in -[OAAplication
 sendAction:to:from:] and supporting methods. You can find it here:
 http://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniAppKit/OAApplication.m

Thanks!

--Andy


___

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

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

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

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


Re: Multithread communication

2010-02-03 Thread Matt Neuburg
On Wed, 3 Feb 2010 11:30:15 -0500, McLaughlin, Michael P.
mp...@mitre.org said:
In a multithreaded app using NSOperationQueue and targeting Leopard, I am
having an inordinate amount of trouble communicating the results of the
thread computations to the main thread which acts as an overall coordinator.

thread upon completion.  The last thing each thread does is
postNotificationName to the main thread saying that it is ready to return
lots of data which it does via an NSPointerArray
[ptr pointerArrayWithStrongObjects]
and dictionary.  The object which collects the results has a function
getOpResults() which accesses the passed pointer.

Three things come immediately to mind just reading what you've said (without
seeing the actual code):

(1) Posting a notification does not, of itself, post to the main thread.
Of course you may already know this. But it might be worth keeping in mind
that if you are code running in a background thread and you are not
explicitly saying performSelectorOnMainThread:, stuff that you trigger, even
thru a notification, is still triggered in the background thread.

(2) NSOperationQueues and NSOperations are KVO compliant, so it should be
sufficient to observe - there shouldn't be any need for an explicit posting
of a notification in any case. Usually you just observe isFinished. Of
course you will receive *that* notification in the background thread, so you
must *still* then jump out to the main thread explicitly with
performSelectorOnMainThread:.

(3) NSOperationQueues and NSOperations are objects, which means that they
have their own data and persist if you want them to. So once you *are* back
in the main thread you can return to these objects and pick up the data, at
your leisure, as it were; the thread is finished, the datat is just sitting
there, and you are the main thread so you are not danger of conflicting with
yourself (there can't be two main threads), and there is no need to pass
anything back via the notification or any other way. This approach may add a
measure of safety and clarity to your code.

I also like to arrange my code into regions with comments that state very
clearly whether a method is to run in a background thread or the main
thread.

m.

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



___

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

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

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

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


Re: another responder chain docs bug (validateUserInterfaceItem:)

2010-02-03 Thread Kyle Sluder
Ack, I need to correct myself.

On Wed, Feb 3, 2010 at 8:42 AM, Kyle Sluder kyle.slu...@gmail.com wrote:
 selector. If it can't find one, the control is enabled. If it does

I meant to say that if AppKit can't find a control in the responder
chain that responds to the action selector, the control is *disabled.*

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


Drawing Attention to a Control to aid user in Error Recovery

2010-02-03 Thread Jerry Krinock
An app I'm developing has a multi-tabbed window.  Sometimes one of the Error 
Recovery Options is to click into some tab and adjust control Foo.  And in many 
cases, either due to the complexity of it, or to help the user learn where the 
control is, I want them to actually do it themselves, using the control.

So, when a user clicks the Recovery Option Change Foo, I reveal the tab, and 
then I'm thinking that I'd like to maybe draw a red outline around the frame of 
the control.  Are there any API, Apple or other frameworks that I should 
consider to do something like this?

How about that fat blue arrow which Apple uses to direct users to menu items 
after searching in Help?  Any way to get ahold of that?

Thanks,

Jerry___

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

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

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

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


cross-process file open notifications

2010-02-03 Thread Alexander Cohen
Is there any way in cocoa to get some sort of notifications when any process 
opens or closes any file? The reason i need this is because i need to watch the 
system and do a certain task every time a particular dylib is loaded by an 
application.

thx

AC___

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: cross-process file open notifications

2010-02-03 Thread Dave Carrigan

On Feb 3, 2010, at 1:50 PM, Alexander Cohen wrote:

 Is there any way in cocoa to get some sort of notifications when any process 
 opens or closes any file? The reason i need this is because i need to watch 
 the system and do a certain task every time a particular dylib is loaded by 
 an application.


The FSEvents API is most likely what you're looking for.

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

___

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

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

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

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


Re: cross-process file open notifications

2010-02-03 Thread Dave Carrigan

On Feb 3, 2010, at 1:54 PM, Dave Carrigan wrote:

 
 On Feb 3, 2010, at 1:50 PM, Alexander Cohen wrote:
 
 Is there any way in cocoa to get some sort of notifications when any process 
 opens or closes any file? The reason i need this is because i need to watch 
 the system and do a certain task every time a particular dylib is loaded by 
 an application.
 
 
 The FSEvents API is most likely what you're looking for.


Come to think of it, FSEvents might not tell you about files being opened, so 
it might not be exactly what you want, after all.

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

___

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

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

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

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


Re: cross-process file open notifications

2010-02-03 Thread Jens Alfke


On Feb 3, 2010, at 1:50 PM, Alexander Cohen wrote:

Is there any way in cocoa to get some sort of notifications when any  
process opens or closes any file?


I'm pretty sure there isn't. The rate at which those notifications  
were sent would be pretty horrific (ever run fs_usage on all  
processes?) Even the private file notification firehose that's  
consumed by Spotlight only tracks modifications, not opening.


The reason i need this is because i need to watch the system and do  
a certain task every time a particular dylib is loaded by an  
application.


Can you put code into the dylib itself that will do this? Like a +load  
method?



On Feb 3, 2010, at 1:57 PM, Dave Carrigan wrote:


The FSEvents API is most likely what you're looking for.
Come to think of it, FSEvents might not tell you about files being  
opened, so it might not be exactly what you want, after all.


No, FSEvents notifies you when a particular directory (or anything  
inside it) changes.


—Jens___

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: Drawing Attention to a Control to aid user in Error Recovery

2010-02-03 Thread jonat...@mugginsoft.com

On 3 Feb 2010, at 21:04, Jerry Krinock wrote:

 An app I'm developing has a multi-tabbed window.  Sometimes one of the Error 
 Recovery Options is to click into some tab and adjust control Foo.  And in 
 many cases, either due to the complexity of it, or to help the user learn 
 where the control is, I want them to actually do it themselves, using the 
 control.
 
 So, when a user clicks the Recovery Option Change Foo, I reveal the tab, 
 and then I'm thinking that I'd like to maybe draw a red outline around the 
 frame of the control.  Are there any API, Apple or other frameworks that I 
 should consider to do something like this?
 
 How about that fat blue arrow which Apple uses to direct users to menu items 
 after searching in Help?  Any way to get ahold of that?

What about using a child window?
I use MAAttachedWindow for this sort of thing.

http://mattgemmell.com/2007/10/03/maattachedwindow-nswindow-subclass

Lots of possibilities with it as you can wrap it around an NSView instance of 
your choice.

Regards

Jonathan Mitchell

Developer
http://www.mugginsoft.com

___

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

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

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

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


Re: cross-process file open notifications

2010-02-03 Thread Jerry Krinock

On 2010 Feb 03, at 14:28, Jens Alfke wrote:

 FSEvents notifies you when a particular directory (or anything inside it) 
 changes.

Or, preferably, if your process does not need to be running to do other stuff, 
you could set up a launchd task to watch a particular directory and launch your 
process when anything in it changes.

http://developer.apple.com/MacOsX/launchd.html

___

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: Synthesize NSMutableString retain count question

2010-02-03 Thread Philip Vallone
Thanks.. perfect explanation. 

On Feb 3, 2010, at 12:37 PM, Jens Alfke wrote:

 
 On Feb 3, 2010, at 3:55 AM, Philip Vallone wrote:
 
 currentSection  = @Some value;
 The retain count goes to 1
 
 This assigns a new value to the pointer variable 'currentSection'. It now 
 points to the immutable string literal @Some value.
 
 However if I assign a value with
 [currentSection setString:@Some value];
 The retain count is still zero.
 
 This tells the mutable string object that 'currentSection' currently points 
 to, to replace its contents with the characters in the string @Some value.
 
 If you find the retain count is zero after this, it's probably because the 
 value of 'currentSection' is nil, i.e. it doesn't point to any object. In 
 that case the -setString: message is a no-op since messages to nil are 
 ignored, and -retainCount will return zero because messages to nil always 
 return 0/nil.
 
 In general, it sounds as though you're unclear on the distinction between an 
 object and a pointer to an object. It's the same as structs vs. pointers to 
 structs in C, or for objects in C++; the difference is that Objective-C 
 objects can only be referred to by pointers (you can't have a variable of 
 type NSString, only NSString*.)
 
 —Jens

___

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: cross-process file open notifications

2010-02-03 Thread Alexander Cohen
I can't put any code into the dylib. It's library that's not being developed 
anymore but many users have it and use it. We have a new approach but the dylib 
has a sort of lock on some things we need. Because of this, we've decided to 
watch for usage of this dylib and when there is no usage, we can enable our new 
approach. As of now, all i can do is poll for new processes and run lsof on the 
to see what files they are using. I consider this approach very bad but i can't 
think of anything better.

AC

On Feb 3, 2010, at 5:28 PM, Jens Alfke wrote:

 
 On Feb 3, 2010, at 1:50 PM, Alexander Cohen wrote:
 
 Is there any way in cocoa to get some sort of notifications when any process 
 opens or closes any file?
 
 I'm pretty sure there isn't. The rate at which those notifications were sent 
 would be pretty horrific (ever run fs_usage on all processes?) Even the 
 private file notification firehose that's consumed by Spotlight only tracks 
 modifications, not opening.
 
 The reason i need this is because i need to watch the system and do a 
 certain task every time a particular dylib is loaded by an application.
 
 Can you put code into the dylib itself that will do this? Like a +load method?
 
 
 On Feb 3, 2010, at 1:57 PM, Dave Carrigan wrote:
 
 The FSEvents API is most likely what you're looking for.
 Come to think of it, FSEvents might not tell you about files being opened, 
 so it might not be exactly what you want, after all.
 
 No, FSEvents notifies you when a particular directory (or anything inside it) 
 changes.
 
 —Jens___
 
 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/alex%40toomuchspace.com
 
 This email sent to a...@toomuchspace.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: cross-process file open notifications

2010-02-03 Thread Alexander Cohen
Unfortunately, the files i need to watch could be anywhere on the system. So i 
would need something more like a filename only watch and not a complete path.

AC

On Feb 3, 2010, at 6:15 PM, Jerry Krinock wrote:

 
 On 2010 Feb 03, at 14:28, Jens Alfke wrote:
 
 FSEvents notifies you when a particular directory (or anything inside it) 
 changes.
 
 Or, preferably, if your process does not need to be running to do other 
 stuff, you could set up a launchd task to watch a particular directory and 
 launch your process when anything in it changes.
 
 http://developer.apple.com/MacOsX/launchd.html
 
 ___
 
 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/alex%40toomuchspace.com
 
 This email sent to a...@toomuchspace.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: Breaking on 'autoreleased with no pool in place - just leaking'

2010-02-03 Thread Keith Duncan

On 2 Feb 2010, at 09:40, Matt Gough wrote:

 What symbol should I put a break point on […]
 
 I tried NSLog and printf but it wasn't them.

You can also set a breakpoint on 'asl_send' to catch logging.

Keith___

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


IKImageBrowserView IKImageView subclasses not getting called

2010-02-03 Thread Charles Burnstagger
I subclass IKImageBrowserView  IKImageView overriding initWithFrame:  
drawRect: and sending the same messages to super in both cases.

I've set them as the classes for the UI objects in my IB file, and as IBOutlets 
in my window's window controller subclass.

But when I run the code, neither of my two subclasses ever get called. What 
gives? Is there anything else I need to do in my subclasses?

If I set the IBOutlets in the contoller subclass and class types in IB back to 
IKImageBrowserView  IKImageView, the code seems to do the same thing as when I 
use my subclasses.

Thanks,

Chuck



  
___

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


EnumeratorAtPath and duplicate files during drag to open

2010-02-03 Thread Trygve Inda
If a user drags 3 Finder objects to my file processor app...

DirectoryA
FileA
FileB

And FileA is in the directory tree below DirectoryA, what is the best way to
avoid processing the file twice?

When I get the array of paths in my drop handler, when I see the directory,
I use EnumeratorAtPath to process the tree, but don't want to re-process
files.

This becomes a real issue if someone drops DirectoryA and DirectoryB if
DirectoryB is in the tree below DirectoryA... Since a bunch of files could
be re-processed.

Do I just need to keep a temporary array of paths that I have processed and
search it for each file... Could be a lot of searching if the user drops the
entire Documents folder.

Thoughts?

Trygve


___

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: Help with NSData dataWithContentsOfURL

2010-02-03 Thread Michael Ash
On Wed, Feb 3, 2010 at 1:46 PM, Charles Srstka cocoa...@charlessoft.com wrote:
 On Feb 3, 2010, at 8:26 AM, cocoa-dev wrote:

 Thanks Graham, here's what I'm thinking.  The documents for my app are 
 fileWrappers.  Before the document is saved for the first time I can copy 
 the files to a temp folder and during a save move them into the fileWrapper. 
  I guess I need to just abandon the whole NSData idea altogether.  Too bad.

 If you use NSFileWrapper’s initWithURL:options:error method, and then send it 
 -serializedRepresentation, you should be able to get an NSData. But be 
 careful when doing this, because as has already been mentioned, a directory 
 could contain far more data than will fit in RAM.

Why is everybody so worried about loading an excessive amount of data
if it's a directory, but not if it's a file? HFS+ is capable of
holding files over a billion gigabytes long, which you're going to
have a certain amount of trouble squeezing into RAM. (Or onto any kind
of storage, for that matter.)

If you know that your data will fit into RAM, then you can read it all
at once. If you're not certain, then you must read it in pieces.
Whether the data in question is a single file or a directory of files
doesn't influence this decision 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: Help with NSData dataWithContentsOfURL

2010-02-03 Thread Graham Cox

On 04/02/2010, at 4:21 PM, Michael Ash wrote:

 Why is everybody so worried about loading an excessive amount of data
 if it's a directory, but not if it's a file? HFS+ is capable of
 holding files over a billion gigabytes long, which you're going to
 have a certain amount of trouble squeezing into RAM. (Or onto any kind
 of storage, for that matter.)
 
 If you know that your data will fit into RAM, then you can read it all
 at once. If you're not certain, then you must read it in pieces.
 Whether the data in question is a single file or a directory of files
 doesn't influence this decision at all.


True, but I guess that with a single file you can find out its size ahead of 
time easily, whereas with a directory it's quite a bit more involved to find 
out the size of it.

--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: EnumeratorAtPath and duplicate files during drag to open

2010-02-03 Thread Jens Alfke

On Feb 3, 2010, at 9:06 PM, Trygve Inda wrote:

 This becomes a real issue if someone drops DirectoryA and DirectoryB if
 DirectoryB is in the tree below DirectoryA... Since a bunch of files could
 be re-processed.

Convert each input path into canonical form (to resolve symlinks), sort them 
alphabetically, then go through the list and discard any path that has the 
preceding path as a prefix (being careful not to match partial filenames, e.g. 
/foo/bar is not a prefix of /foo/barbell. Making sure directory paths end in 
/ should take care of that.)

—Jens___

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: EnumeratorAtPath and duplicate files during drag to open

2010-02-03 Thread Jerry Krinock

On 2010 Feb 03, at 21:06, Trygve Inda wrote:

 Do I just need to keep a temporary array of paths that I have processed and
 search it for each file.

That's one way that would work.  Another way would be to, before processing 
each item, iterate through its lineage,  somethling like this:

   parent = theItem ;
   BOOL processThisItem = YES ;
   do {
   parent = [theItem parent] ;
   if ([parent isInTheDroppedArray]) {
   processThisItem = NO ;
   break ;
   }  
   } while (parent != nil) ;

   if (processThisItem) {
...
   }

I don't know if it would be any more or less efficient than your original idea. 
 Probably depends on the dimensions of the typical drop.

 Could be a lot of searching if the user drops the
 entire Documents folder.

Yup.  No matter how you do 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


objc_msgSend() tour

2010-02-03 Thread Bill Bumgarner
Folks-

I finally banged out part IV -- the 'slow path'  odds/ends -- of my 
tour of objc_msgSend() on x86_64.  If you want to know how method invocations 
works in instruction by instruction detail on x86_64, you might find it 
interesting:

http://www.friday.com/bbum/2009/12/18/objc_msgsend-part-1-the-road-map/

(that contains the table of contents to the other three articles)

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


Invitation to connect on LinkedIn

2010-02-03 Thread Yong Li
LinkedIn


   
cocoa-dev,

I'd like to add you to my professional network on LinkedIn.

- Yong

Confirm that you know Yong Li
https://www.linkedin.com/e/isd/1047213400/v9UH383H/



 
--
(c) 2010, LinkedIn Corporation
___

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