Bindings and MenuItems

2009-04-01 Thread Ben Lachman
I have a menu item that is bound to a target.  The menu is resides in  
has "Auto Enables Items" checked which means that it should call - 
validateMenuItem on a items target if it is available.  However  
validate is never called on the target.  If I remove the binding and  
set the target to one of the objects manually in IB the validation  
method is called as expected.  Has anyone else run into this and if  
so, is there a work around?


Thanks,
->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



___

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

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

Help/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: Shortcut handling in different keyboard layouts

2009-04-01 Thread Rimas M.
> In that case, you'd want to use the virtual keycode - available as [event
> keyCode] - rather than the character code. I thought when you'd posted your
> original question, though, you said that you wanted your keyboard event
> matching to be dependent on the keyboard layout, so that if you used, for
> example, a Dvorak keyboard layout, where the 'p' key is generated from the
> physical key that has an 'r' on it in the US layout, you'd still detect and
> match against that physical key. That's why I suggested using the character
> code rather than the keycode.
>
> -eric

You are right. If I would choose "keyCode way", there will be problems
with layouts like Dvorak.
I have an idea: Check if input character has code 0-255 (ASCII). If
yes - perform matching by symbol or its code. Otherwise (Unicode
symbol, like Cyrillic) perform matching by keyCode. I am wondering if
it will work in right way...

Regards,

Rimas 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


Persistent store removal throwing invalidated NSManagedObject exceptions

2009-04-01 Thread Drew McCormack
I've setup a temporary managed object context to export data to an  
external XML file (persistent store). When I remove the persistent  
store from the context, I am getting errors like this:


Exception raised during posting of notification.  Ignored.  exception:  
'The NSManagedObject with ID:0x18656990 > has been invalidated.'  invoked observer method: '*** - 
[NSManagedObjectContext _storeConfigurationChanged:]'  observer:  
0x1864d370  notification name:  
'_NSPersistentStoreCoordinatorStoresDidChangePrivateNotification'


The managed object subclass causing the issue is one that uses KVO to  
follow changes in other objects.
I've tracked the notification down to one KVC method for a core data  
relationship property called 'collections'.


-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
[anObject removeObserver:self forKeyPath:@"knowledgeItems"];
[self willChangeValueForKey:@"collections"];
[[self primitiveValueForKey:@"collections"] removeObject:anObject];
[self didChangeValueForKey:@"collections"];
[self refresh];
}

This has been included to remove the object as a KVO observer, and  
refresh a lazy property, but actually, the notification also arises  
when I just use this


-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
[self willChangeValueForKey:@"collections"];
[[self primitiveValueForKey:@"collections"] removeObject:anObject];
[self didChangeValueForKey:@"collections"];
}

If I remove the method altogether, the exception does not get raised.

So I'm confused, because I would have thought that the implementation
above would be pretty much the same as what Core Data would do  
internally if the method is not included. Apparently it is doing other  
things to

avoid the exception, but what?

Drew



 Drew McCormack
 Chief Developer
 The Mental Faculty

 drewmccorm...@mentalfaculty.com
 www.mentalfaculty.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: Persistent store removal throwing invalidated NSManagedObject exceptions

2009-04-01 Thread Jonathan Dann


On 1 Apr 2009, at 11:20, Drew McCormack wrote:

I've setup a temporary managed object context to export data to an  
external XML file (persistent store). When I remove the persistent  
store from the context, I am getting errors like this:




[...]

This has been included to remove the object as a KVO observer, and  
refresh a lazy property, but actually, the notification also arises  
when I just use this


-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
   [self willChangeValueForKey:@"collections"];
   [[self primitiveValueForKey:@"collections"] removeObject:anObject];
   [self didChangeValueForKey:@"collections"];
}

If I remove the method altogether, the exception does not get raised.

So I'm confused, because I would have thought that the implementation
above would be pretty much the same as what Core Data would do  
internally if the method is not included. Apparently it is doing  
other things to

avoid the exception, but what?


Hi Drew,

When writing a custom to-many accessor in an NSManagedObject subclass,  
you need to invoke the correct KVO -will/didChange methods


These are:

-[NSManagedObject willChangeValueForKey:withSetMutation:usingObjects:]
-[NSManagedObject didChangeValueForKey:withSetMutation:usingObjects:]

So your method should change to:

-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
   NSSet *removedObjects = [[NSSet alloc] initWithObjects:&anObject  
count:1];
   [self willChangeValueForKey:@"collections"  
withSetMutation:NSKeyValueMinusSetMutation usingObjects:removedObjects];

   [[self primitiveValueForKey:@"collections"] removeObject:anObject];
   [self didChangeValueForKey:@"collections"  
withSetMutation:NSKeyValueMinusSetMutation usingObjects:removedObjects];

   [removedObjects release];
}

Hope this helps, there's a full example in the programming guide:

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


Jonathan

http://espresso-served-here.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: Bindings and MenuItems

2009-04-01 Thread Andy Lee

On Apr 1, 2009, at 3:34 AM, Ben Lachman wrote:
I have a menu item that is bound to a target.  The menu is resides  
in has "Auto Enables Items" checked which means that it should call - 
validateMenuItem on a items target if it is available.  However  
validate is never called on the target.  If I remove the binding and  
set the target to one of the objects manually in IB the validation  
method is called as expected.  Has anyone else run into this and if  
so, is there a work around?


What do you mean "binding"?  "Binding" has a very specific meaning,  
and is not how you connect an object to its target.


Do you mean you're making the connection in code?  If so, it should  
look something like:


[myMenuItem setTarget:myTarget];
[myMenuItem setAction:@selector(doMyAction:)];

Note the name of the action method is "doMyAction:", not "doMyAction",  
though I don't know if this affects whether validateMenuItem: is called.


Assuming your code does look like this, are you sure these lines of  
code are being executed?  If so, *when* are they being executed?  If  
you doing this in init, it's possible myMenuItem and myTarget have not  
been set yet -- you need to make the connection in awakeFromNib.


--Andy

___

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

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

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

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


Re: Best Strategy to Control iTunes

2009-04-01 Thread has

Michael Ash wrote:

On Tue, Mar 31, 2009 at 3:57 PM, Luca C.   
wrote:

2009/3/31 Ammar Ibrahim 

If I want to add a track to iTunes, I need to make sure iTunes is
responsive.

Are you sure it is that important? Actually, if you run an AS  
script wich,
say, opens with the Finder some mp3 files whilst iTunes has dialog  
windows
opened, the command will be automatically enqueued. Â In other  
words, your

tracks will be added after the user closes the dialog window.
 Run the script in a separate thread so it won't block your  
application's

interface in any case.


No, don't do this. AppleScript is not safe to use outside the main
thread. If you must run AppleScript asynchronously, either spawn a
subprocess to run it or, better yet, don't use AS at all but send
Apple Events in some other way, such as with ScriptingBridge.



Scripting Bridge apparently isn't thread-safe either:

http://www.dribin.org/dave/blog/archives/2009/02/01/main_thread_apis/

ObjC-appscript is almost entirely thread-safe. You'll need to watch  
when using methods that rely on the Carbon Process Manager (some  
initializers, -isRunning) as the PM APIs don't appear to be thread- 
safe itself, but the main query builder and event dispatch methods  
should work fine on any thread (e.g. I use Python appscript in a  
background thread without problems).


For example:

tell application "iTunes"
set newPlaylist to make new playlist with properties {name:"Rock- 
n-Roll", shuffle:true}
duplicate (every track of library playlist 1 whose artist is  
"Chuck Berry") to newPlaylist

end tell


#import "ITGlue/ITGlue.h"

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

// create a new application object
ITApplication *itunes = [ITApplication applicationWithBundleID:  
@"com.apple.itunes"];


// create a new playlist
ITMakeCommand *cmd = [[[itunes make] new_: [ITConstant playlist]]
   withProperties: [NSDictionary  
dictionaryWithObjectsAndKeys:
ASTrue, [ITConstant  
shuffle],
@"Rock-n-Roll",  
[ITConstant name],

nil]];
ITReference *newPlaylist = [cmd send];

// duplicate all tracks that match the given criteria to the new  
playlist

ITReference *ref = itunes libraryPlaylists] at: 1] tracks]
byTest: [[ITIts  
artist] equals: @"Chuck Berry"]];


NSError *error;
NSArray *tracks = [[[ref duplicate] to: newPlaylist]  
sendWithError: &error];

if (!tracks) {
// check for errors
NSLog(@"%@", [error localizedDescription]);
err = [error code];
} else
// display result
NSLog(@"%@", tracks);

[pool drain];
return err;
}

The ASDictionary application on the appscript site has options for  
exporting application dictionaries in both human-readable HTML format  
and as ObjC glue files.


Not surprisingly, the ObjC code's a bit more verbose, but  
straightforward enough to construct once you understand the general  
principles behind Apple event-based IPC. Appscript respects the  
original Apple event semantics and doesn't obfuscate them under piles  
of fake Cocoa-isms, so if you already know how to do it in AppleScript  
then it's pretty much a straight translation: there's even a free  
tool, ASTranslate, that will help you with that.


Apple event IPC is kinda weird and very different to Cocoa/OOP (a  
rough analogy would be to using XPath queries over XML-RPC) but is  
usually serviceable once you get your head around it. Apple docs do a  
lousy job of explaining how it all works, but there's an introduction  
to the basic concepts in the appscript manual and links on the  
appscript site to further information.



Oh, and as for checking if an application is responsive - I'd suggest  
just sending an event and seeing if it times out (timeouts may be  
reported as either error -609 or -1712, depending on what sort of mood  
AESendMessage is in at the time). The launch event (ascr/noop) is  
basically a no-op that will return error -1708 if 'successfully'  
handled; handy if you don't want to send a 'work' event.


HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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


xml parsing

2009-04-01 Thread developers mac
Hi there, I have to parse a xml & return the values for val & id
(attribute). I have pasted a sample xml below.   
 Alabama . . . Wyoming 
   Australia . . . ZambiaI am able to retrieve
the val(Alabama, Austalia...) & display it in a table view. I need to get
the attribute values (AL, 1) - to know which val has been selected. I need
to get the attribute value. but i am not sure to get the attribute value
according to the click of the val. Can some help me to get through this one
please Also i am able to get the attribute values in didstartelement of
xml parser by : tagid = [attributeDict objectForKey:@"id"]; But I am not
aware of how to add this value to a array something similar to : -
(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
attributes:(NSDictionary *)attributeDict{ currentElement = [elementName
copy]; if ([elementName isEqualToString:@"val"]) { item =
[[NSMutableDictionary alloc] init]; tagid = [attributeDict objectForKey:@"id"];
( I am getting all the values of attribute here) } } -
(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ if
([elementName isEqualToString:@"val"]) { [item setObject:errorcode
forKey:@"val"];
[item setObject:obtID forKey:@"Id"]; [item objectForKey:@"id"]; [stories
addObject:[item copy]]; } } - (void)parser:(NSXMLParser *)parser
foundCharacters:(NSString *)string{ if ([currentElement
isEqualToString:@"val"]){
[errorcode appendString:string]; } else if ([currentElement
isEqualToString:@"Id"]) { obtrowid = string; [obtID appendString:string]; }
} I need to retrieve the values of - (void)tableView:(UITableView
*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int
storyIndex = [indexPath indexAtPosition: [indexPath length] - 1]; retselval
= [[stories objectAtIndex: storyIndex] objectForKey: @"val"]; //retseltag =
[dupattr objectForKey:@"id"]; ( This is where I am trying to read the
attribute values) }
___

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

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

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

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


Saving Address Book for more than 1000 recrods

2009-04-01 Thread Vijay Kanse
Hello list,
I tried simple program that add first name and last name to address book. I
just loop it to 3000 times.
I am saving the address book outside the loop.

but when it executes its [book save] command, my application goes in to Not
responding mode for few seconds.

Then i tried to save it with a looping 3 times to 1000 records. and saving
after each 1000 records. again i am getting my application in not responding
mode after 1000 records saved.

What should be the problem ?

is This a behavior of address book for more than 1000 records ? if it is,
how can i fix it?


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


disable row highlighting NSTableView

2009-04-01 Thread Jo Phils
Hello everyone,

This seems it should be easy enough but I can't quite figure it out.  Normally 
when selecting an item in a table view it gets highlighted blue.  How do you 
disable this highlighting?

Thank you,

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: How to know when a UISwitch is being touched

2009-04-01 Thread Brian Slick
We may be able to combine forces here.  What I was doing gets the  
correct answer from the switch, but what I was finding is that certain  
circumstances do not result in a message being sent from the switch.   
I forget just now which circumstance it was, but I believe it was a  
direct tap on the "button" of the switch.  Swiping the switch worked  
fine, tapping on the text of the switch worked fine, but tapping on  
the button did not send a message.  I finally just punted and asked  
each switch for their current status in viewWillDisappear, but this  
means I cannot react to changes while the user is still in the view.


So, if you use your method, but change it to [sender isOn], does that  
work?  I hope so, because that opens up some possibilities for me.


Brian

On Mar 31, 2009, at 9:22 AM, Joan Lluch-Zorrilla wrote:

I need to know whether the user is touching inside a UISwitch  
control. The UIControlEvent(s) do fire, but then isTouchInside  
always gives NO. My code is:


- (void)switchTouched:(UIControl *)sender
  {
   NSLog( @"switchtouched:%d", [sender isTouchInside]) ;
  }

The switchTouched method was added as a target to touch events upon  
creation of the switch like this


[switchv addTarget:self action:@selector(switchTouched:)  
forControlEvents:UIControlEventAllTouchEvents] ;


Whatever the user does on the switch the result is always Zero. What  
am I missing?


Joan Lluch-Zorrilla



___

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

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

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

This email sent to briansl...@mac.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: Delayed Undo Problem

2009-04-01 Thread Richard Somers

On Mar 30, 2009, at 5:55 AM, Richard Somers wrote:

I have a basic core data document based application (Hillegass 3rd  
Edition, Chapter 11, CarLot). With a single primary window every  
thing works. Then a second window is added with a generic master  
detail interface using the core data entity from the Interface  
Builder pallet.


When making a change to the model in the second window, undo/redo in  
the main menu is not available until the primary window is clicked  
and brought to the front.


I need the undo/redo menu to work regardless of which window is  
frontmost. Any thoughts as to how this can be done?


On Mar 30, 2009, at 9:17AM, Keary Suska wrote:


This FAQ might help:

http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdFAQ.html#/ 
/apple_ref/doc/uid/TP40001802-244036


I think I found the answer to my question.

The Undo/redo menu items reflect the state of the undo manager for the  
key window (Hillegass, 3rd Edition, page 152).


The default cocoa document based architecture has a one window for  
each document. To have multiple inspector panels reflect the undo  
state of the document you need to subclass NSWindowController.


Refer to Apple Cocoa "Document-Based Applications Overview" page 62  
"How can I use NSWindowController for shared panels (inspectors, find  
panels, etc.)?" Also the Sketch application uses NSWindowController  
subclasses for its various secondary panels.


Richard

___

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

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

Help/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: disable row highlighting NSTableView

2009-04-01 Thread Jens Miltner


Am 01.04.2009 um 15:58 schrieb Jo Phils:


Hello everyone,

This seems it should be easy enough but I can't quite figure it  
out.  Normally when selecting an item in a table view it gets  
highlighted blue.  How do you disable this highlighting?


This was answered just a few days ago on this list (unless I misread  
your question): 





___

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

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

Help/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: [BUG] Cursor Flicker

2009-04-01 Thread Eric Gorr


On Mar 31, 2009, at 9:18 PM, Graham Cox wrote:



On 01/04/2009, at 4:46 AM, Eric Gorr wrote:

There is a bug when changing from [[NSCursor arrowCursor] set] to a  
NSCursor based on a 64x64 PNG.


Basically, there is some horrible cursor flickering.

For a demonstration of this bug, please check out the sample  
application at:


http://ericgorr.net/cocoadev/CursorFlicker.zip

I have filed a bug as well: rdar://6741558



But it's not a bug - you are making it flicker by repeatedly  
switching it between the two cursors.


WAYTTD?

As your while loop runs it will set the arrow cursor every 4th time  
(x % 2), and the large cursor otherwise. It's impossible to tell  
what you expected or intended, but overall it looks like a weird  
thing to do.


It might be easier to see the problem if you change:

[NSEvent startPeriodicEventsAfterDelay:0.1 withPeriod:.1];

to

[NSEvent startPeriodicEventsAfterDelay:0.1 withPeriod:.5];


and increase the number of iterations to 50 or something.

The cursor clearly should not jump around when one changes it. Do not  
move the mouse.



In the real application, there are some cursors based on 64x64 images.  
When switching to these cursors, one sees the cursor quickly jump to a  
different position and then back to where it should be. This is very  
jarring and shouldn't happen. Why it briefly jumps, I do not know.




___

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

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

Help/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: Persistent store removal throwing invalidated NSManagedObject exceptions

2009-04-01 Thread Drew McCormack


Hi Drew,

When writing a custom to-many accessor in an NSManagedObject  
subclass, you need to invoke the correct KVO -will/didChange methods


These are:

-[NSManagedObject willChangeValueForKey:withSetMutation:usingObjects:]
-[NSManagedObject didChangeValueForKey:withSetMutation:usingObjects:]

So your method should change to:

-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
   NSSet *removedObjects = [[NSSet alloc] initWithObjects:&anObject  
count:1];
   [self willChangeValueForKey:@"collections"  
withSetMutation:NSKeyValueMinusSetMutation  
usingObjects:removedObjects];

   [[self primitiveValueForKey:@"collections"] removeObject:anObject];
   [self didChangeValueForKey:@"collections"  
withSetMutation:NSKeyValueMinusSetMutation  
usingObjects:removedObjects];

   [removedObjects release];
}

Hope this helps, there's a full example in the programming guide:

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


Jonathan


Thanks Jonathan. You're absolutely right.

However, when I made the appropriate changes, I have the same issue:  
with my new custom remove... accessor, I get the exception, and  
without the custom accessor, there is no exception. So something  
strange is still going on.


Here is the new accessor for good measure:

-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
NSSet *removedObjects = [[NSSet alloc] initWithObjects:&anObject  
count:1];
[self willChangeValueForKey:@"collections"  
withSetMutation:NSKeyValueMinusSetMutation usingObjects:removedObjects];

[[self primitiveValueForKey:@"collections"] removeObject:anObject];
[self didChangeValueForKey:@"collections"  
withSetMutation:NSKeyValueMinusSetMutation usingObjects:removedObjects];

[removedObjects release];
}

Drew
___

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

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

Help/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: NSMutableArray is null?

2009-04-01 Thread Pierce Freeman
Hey Graham :

Yeah, I finally figured that out. ;) It now works like a charm.


On 3/31/09 7:20 PM, "Graham Cox"  wrote:

> 
> On 01/04/2009, at 1:16 PM, Pierce Freeman wrote:
> 
>> The global variable is in the Controller.h... Is this what you are
>> asking
>> for?
> 
> 
> No. Just declaring  doesn't actually make an instance
> of NSMutableArray. You have to write code to do that. Where is it?
> 
> If you haven't done this, that's your problem.
> 
> Somewhere you need:
> 
> globalVariable = [[NSMutableArray alloc] init];
> 
> 
> 
> --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: Shortcut handling in different keyboard layouts

2009-04-01 Thread Peter Castine

Matching on keycode will almost always confuse your users.

There are at least 9 different Cyrillic keyboard layouts supported by  
OS X. If you write code that matches the virtual keycode for 2nd rank  
11th key, it will match "з" (ze) for half or those layouts and  
"п" (pe) for the other half. Your users are not going to count off  
ranks and keys, they will be looking for a Cyrillic character. Half of  
them will hit a different key from what you're expecting.


If Cyrillic keyboards are likely to be a part of your user base, you  
would probably be better advised to set up a mapping table for  
Cyrillic characters. Either map the Cyrillic alphabet to the Latin  
alphabet and from thence to your keyboard commands or, better still,  
map the Cyrillic alphabet directly to the keyboard-triggered commands.


As pointed out earlier, the OS handles this automagically for Cmd-key  
combinations. You can see this for yourself by turning on a couple of  
relevant keyboard layouts in System Preferences->International->Input  
Menu, selecting one of them and turning on the Keyboard Viewer (at the  
bottom of the Input Menu). While the Command key is depressed, the  
layout reverts to US Sholes.


I have used a few applications that implemented keyboard shortcuts  
beyond Command-key combinations. Those that implemented keyboard- 
command mappings based on an assumed physical location of characters  
have always left international users confused and disatisfied.


My €0.02 -- Peter



On 1-Apr-2009, at 10:11, Rimas M. wrote:

I have an idea: Check if input character has code 0-255 (ASCII). If
yes - perform matching by symbol or its code. Otherwise (Unicode
symbol, like Cyrillic) perform matching by keyCode. I am wondering if
it will work in right way...


___

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

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

Help/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 List of Hardware Devices in NSTableView w/ Asynchronous Updates

2009-04-01 Thread Grant Erickson
I've a list of hardware devices in an NSTableView. The contents of the table
view are updated accordingly using the device model (C++) getters in
objectValueForTableColumn and using the device model setters in
setObjectValue.

However, the device model can also asynchronously create (sometimes
rapidly-order of tens to hundreds of milliseconds) updates for one of the
model values independently of the getter. To handle this, I currently have
the controller implement a delegate method for these asynchronous updates
and then do:

[mDeviceTable reloadData];

Unfortunately, this then causes the table to hit all the device getters for
all the devices and update all the columns even though only a single column
(and possibly row) has changed thereby creating needless bus traffic and
activity.

My first inclination is to create an array of dictionaries that act as a
cache for the device attributes, have the asynchronous delegate update the
appropriate key/value and then have reloadData update from there.

Is this the best or recommended approach? I'm only vaguely familiar with
Cocoa's KVC/KVO, but based on my understanding it also seems like a KVC/KVO
wrapper for the C++ device model might also work.

Thanks,

Grant


___

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

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

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

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


Re: Best Strategy to Control iTunes

2009-04-01 Thread Sean McBride
On 4/1/09 12:25 PM, has said:

>ObjC-appscript is almost entirely thread-safe. You'll need to watch
>when using methods that rely on the Carbon Process Manager (some
>initializers, -isRunning) as the PM APIs don't appear to be thread-
>safe itself

Looking through Processes.h, it would appear that all public Process
Manager APIs claim to be thread safe since 10.3.  I guess there can
always be bugs...

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

Help/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: Handling List of Hardware Devices in NSTableView w/ Asynchronous Updates

2009-04-01 Thread Michael Ash
On Wed, Apr 1, 2009 at 10:51 AM, Grant Erickson  wrote:
> I've a list of hardware devices in an NSTableView. The contents of the table
> view are updated accordingly using the device model (C++) getters in
> objectValueForTableColumn and using the device model setters in
> setObjectValue.
>
> However, the device model can also asynchronously create (sometimes
> rapidly-order of tens to hundreds of milliseconds) updates for one of the
> model values independently of the getter. To handle this, I currently have
> the controller implement a delegate method for these asynchronous updates
> and then do:
>
>        [mDeviceTable reloadData];
>
> Unfortunately, this then causes the table to hit all the device getters for
> all the devices and update all the columns even though only a single column
> (and possibly row) has changed thereby creating needless bus traffic and
> activity.
>
> My first inclination is to create an array of dictionaries that act as a
> cache for the device attributes, have the asynchronous delegate update the
> appropriate key/value and then have reloadData update from there.
>
> Is this the best or recommended approach? I'm only vaguely familiar with
> Cocoa's KVC/KVO, but based on my understanding it also seems like a KVC/KVO
> wrapper for the C++ device model might also work.

You can cause the table view to update only a single row by simply
invalidating the rectangle covered by that one row and causing it to
redraw. Since the table doesn't cache any values, it will re-fetch
them from your data source. The documentation for the -rectOfRow:
method has a small example.

Depending on what you're doing, you might also want to cache the
values in an array, so that simple GUI updates (like scrolling the
table or resizing the window) don't have to hit your devices again.

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: NSMutableArray is null?

2009-04-01 Thread I. Savant
On Wed, Apr 1, 2009 at 10:33 AM, Pierce Freeman
 wrote:

> Yeah, I finally figured that out. ;) It now works like a charm.

  Just for completeness, the plain-language concept to remember is:

// "Let there be an NSMutableArray pointer named 'globalVariable'."
NSMutableArray * globalVariable;

... and ...

// "Create an NSMutableArray instance and assign it to the
'globalVariable' pointer
// ... so when I talk to 'globalVariable', I mean this instance of
NSMutableArray."
globalVariable = [[NSMutableArray alloc] init];

  By contrast, when you're creating objects inside a method (temporary
objects whose scope is limited to that method), do this all in one go:

NSMutableArray * myTemporaryArray = [[NSMutableArray alloc] init];

  - or, more simply -

NSMutableArray * myTemporaryArray = [NSMutableArray array];

  ... then you'll use it then let it die, or hand it off to someone else.

  However, since you're creating an instance variable in your class,
you declare the pointer in your header and then create an array and
assign it to the pointer somewhere in your implementation. The most
likely place (arguably by best practice) would be the class's -init
method, since you want a mutable array ready for use when an instance
of your class is created (allocated and initialized).

   I hope that helps a bit.

--
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: Bindings and MenuItems

2009-04-01 Thread Keary Suska

On Apr 1, 2009, at 3:34 AM, Ben Lachman wrote:

I have a menu item that is bound to a target.  The menu is resides  
in has "Auto Enables Items" checked which means that it should call - 
validateMenuItem on a items target if it is available.  However  
validate is never called on the target.  If I remove the binding and  
set the target to one of the objects manually in IB the validation  
method is called as expected.  Has anyone else run into this and if  
so, is there a work around?



IIRC, I had a situation where I discovered that both target & action  
have to be bound (i.e. key-value binding) or target-action fails  
entirely.


HTH,

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

___

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

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

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

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


Re: Best Strategy to Control iTunes

2009-04-01 Thread has


On Apr 1, 2009, at 3:57 PM, Sean McBride wrote:


On 4/1/09 12:25 PM, has said:


ObjC-appscript is almost entirely thread-safe. You'll need to watch
when using methods that rely on the Carbon Process Manager (some
initializers, -isRunning) as the PM APIs don't appear to be thread-
safe itself


Looking through Processes.h, it would appear that all public Process
Manager APIs claim to be thread safe since 10.3.


Huh. Thanks for the heads-up. Very annoying though that Apple put this  
information in the HTML documentation for some APIs (e.g. Apple Event  
Manager), yet omit it from others (e.g. Process Manager). Clearly I  
lack the instinctive Apple developer-fu to always check headers as well.




I guess there can always be bugs...



True; but are they Apple's, mine, or the user's...? :)

(I had a report a while back from a user who couldn't get the - 
isRunning method to work correctly from a background thread, but  
haven't investigated in depth due to lack of time. I figured that  
since Apple docs usually state when something is thread-safe, the PM  
APIs weren't. Oh well, back to the ol' drawing board now)


Cheers,

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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


Re: Saving Address Book for more than 1000 recrods

2009-04-01 Thread Nick Zitzmann


On Apr 1, 2009, at 7:17 AM, Vijay Kanse wrote:

is This a behavior of address book for more than 1000 records ? if  
it is,

how can i fix it?



You can't. As you've discovered, the AddressBook framework is rather  
slow when it comes to large batch operations, and has been since they  
switched from Metakit to CoreData in Leopard. You'll just have to wait  
for it to finish, because I will be very surprised if the framework  
turns out to be thread-safe.


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: disable row highlighting NSTableView

2009-04-01 Thread Jo Phils
Thank you for your reply and my apologies for asking what had been answered a 
few days ago. :-)  It does lead me to another question though...I'm still a 
beginner and I have never overridden a method via subclassing before.  Is there 
a tutorial you might be able to point me to that could show me how to do this?

Thanks again,

Rick






From: Jens Miltner 
To: Cocoa List 
Cc: Jo Phils 
Sent: Wednesday, April 1, 2009 10:10:20 PM
Subject: Re: disable row highlighting NSTableView


Am 01.04.2009 um 15:58 schrieb Jo Phils:

> Hello everyone,
> 
> This seems it should be easy enough but I can't quite figure it out.  
> Normally when selecting an item in a table view it gets highlighted blue.  
> How do you disable this highlighting?

This was answered just a few days ago on this list (unless I misread your 
question): 




  
___

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

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

Help/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: disable row highlighting NSTableView

2009-04-01 Thread I. Savant
On Wed, Apr 1, 2009 at 11:54 AM, Jo Phils  wrote:
> Thank you for your reply and my apologies for asking what had been answered a 
> few days ago. :-)  It does lead me to another question though...I'm still a 
> beginner and I have never overridden a method via subclassing before.  Is 
> there a tutorial you might be able to point me to that could show me how to 
> do this?

  Have you tried reading the documentation?

The Objective-C 2.0 Programming Language
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html

Specifically:

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocObjectsClasses.html#//apple_ref/doc/uid/TP30001163-CH11-TPXREF111

--
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: user access privileges to plist in /library/preferences

2009-04-01 Thread Memo Akten
Hi Greg, actually /Users/Shared didn't work either. If I am logged in  
as admin it works, but if I am logged in as a normal user it doesn't.  
My code is:


#define LOG_PATH_FOLDER @"/Users/Shared/Library/Preferences/"
#define LOG_FILENAME@"MyLog.plist"
#define	LOG_PATH		[LOG_PATH_FOLDER  
stringByAppendingPathComponent:LOG_FILENAME]


NSFileManager *fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath: LOG_PATH_FOLDER] == NO) {
NSLog(@"creating folder %@", LOG_PATH_FOLDER);
[fileManager createDirectoryAtPath: LOG_PATH_FOLDER attributes: nil];
}

logInfo= [[NSMutableDictionary alloc] initWithContentsOfFile:  
LOG_PATH];

if(logInfo == nil) logInfo  = [[NSMutableDictionary alloc] init];




On 30 Mar 2009, at 01:14, Memo Akten wrote:


Hi Greg, /Users/Shared may work, I'll give that a shot thanks.

On 27 Mar 2009, at 18:26, Greg Guerin wrote:



I'd like the file to be user independent, so it should always read/ 
write to
the same file whoever logs in (it actually collects stats of  
usage). Is
there a better place to store the file? (has to be outside of / 
users) How

can I overcome the privileges issue?


If it's just collecting stats of usage, then why don't you use a  
public-readable file in each user's private-writable Library dir.


Or store private-writable public-readable per-user plists in a  
public-writable dir like /Users/Shared.  Or if /Users/Shared is  
unacceptable, then use another dir created for your app, or explain  
why /Users/Shared is unacceptable.


If you can avoid having to use AEWP and elevated privileges, it  
will greatly simplify things and enhance security.


Just because you *can* do something with AEWP doesn't mean you  
*should*.


-- GG

___

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

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

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

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


___

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

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

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

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


___

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

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

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

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


Re: Shortcut handling in different keyboard layouts

2009-04-01 Thread Rimas M.
> Matching on keycode will almost always confuse your users.
>
> There are at least 9 different Cyrillic keyboard layouts supported by OS X.
> If you write code that matches the virtual keycode for 2nd rank 11th key, it
> will match "з" (ze) for half or those layouts and "п" (pe) for the other
> half. Your users are not going to count off ranks and keys, they will be
> looking for a Cyrillic character. Half of them will hit a different key from
> what you're expecting.
>
> If Cyrillic keyboards are likely to be a part of your user base, you would
> probably be better advised to set up a mapping table for Cyrillic
> characters. Either map the Cyrillic alphabet to the Latin alphabet and from
> thence to your keyboard commands or, better still, map the Cyrillic alphabet
> directly to the keyboard-triggered commands.
>
> As pointed out earlier, the OS handles this automagically for Cmd-key
> combinations. You can see this for yourself by turning on a couple of
> relevant keyboard layouts in System Preferences->International->Input Menu,
> selecting one of them and turning on the Keyboard Viewer (at the bottom of
> the Input Menu). While the Command key is depressed, the layout reverts to
> US Sholes.
>
> I have used a few applications that implemented keyboard shortcuts beyond
> Command-key combinations. Those that implemented keyboard-command mappings
> based on an assumed physical location of characters have always left
> international users confused and disatisfied.
>
> My EURO 0.02 -- Peter

Thanks for your 0.02 Peter :)

Currently I am a bit confused. I am not sure which way is best for
users. The best example for I am talking about is Photoshop tools
switching via keyboard. I doubt it uses (or maybe?) Cyrillic
characters mapping. Because if you want to switch to Pencil tool, you
need to press "P" labeled keyboard button in US layout. Even more, you
must press the same button on RU layout. But that button produces "з".
I am not talking about command-key -> actions. I want to implement key
-> action in the correct way. I am quite sure, that such company as
Adobe and long-time project as Photoshop would do that in right way.
Maybe I am wrong. For this reason I am writing here.

Regards,

Rimas 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: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-01 Thread James Montgomerie

This is not doing exactly what you think it is.

You are certainly right that UIKit calls should /always/ be made from  
the main thread, but the "performSelector:withObject:AfterDelay"  
method actually performs the selector on the same thread that you call  
it from, not a separate thread.  This means that - presuming  
viewDidLoad: is getting called on the main thread, which it is if it's  
the system that's calling it - your "addViewInSeparateThread:" is in  
fact getting called on the main thread.


You could not have the addViewInSeparateThread: method at-all, and  
just call performSelector:withObject:AfterDelay with your   
@selector(addViewInMainThread:) selector, and it would have the same  
effect.


Jamie.

On 31 Mar 2009, at 17:20, WT wrote:


Hello again,

in anticipation that the answer to my question might be to add  
UIImageViews as subviews rather than to draw UIImages from within  
the superview's drawRect:, I tried the following little test, which  
works like a charm. The question remains, though, whether this is  
the right/best approach.


Wagner

The following code goes in the view controller managing the view  
where the images should be drawn into. It adds 25 image views to the  
view managed by the view controller, as a 5 x 5 grid, with a  
separation of 40 pixels between images. The grid rectangle has an  
origin at x = 30, y = 50. The time delay between images is 0.1  
second, for a total animation time of 2.5 seconds.


- (void) viewDidLoad
{
   for (int i = 0; i < 5; ++i)
   {
   CGFloat x = 40*i + 30;
   for (int j = 0; j < 5; ++j)
   {
   CGFloat y = 40*j + 50;

   UIImageView* imgView = [[UIImageView alloc]
   initWithImage: [UIImage imageNamed: @"img.png"]];

   CGRect frame = imgView.frame;
   frame.origin.x = x - frame.size.width / 2.0;
   frame.origin.y = y - frame.size.height / 2.0;
   imgView.frame = frame;

   [self performSelector: @selector(addViewInSeparateThread:)
  withObject: imgView
  afterDelay: (5*j + i) / 10.0];

   [imgView release];
   }
   }
}

- (void) addViewInSeparateThread: (UIView*) imgView
{
   [self performSelectorOnMainThread: @selector(addViewInMainThread:)
  withObject: imgView
  waitUntilDone: YES];
}

- (void) addViewInMainThread: (UIView*) imgView
{
   [self.view addSubview: imgView];
}

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jamie%40montgomerie.net

This email sent to ja...@montgomerie.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


Re: Handling List of Hardware Devices in NSTableView w/ Asynchronous Updates

2009-04-01 Thread Steve Christensen

On Apr 1, 2009, at 7:51 AM, Grant Erickson wrote:

I've a list of hardware devices in an NSTableView. The contents of  
the table

view are updated accordingly using the device model (C++) getters in
objectValueForTableColumn and using the device model setters in
setObjectValue.

However, the device model can also asynchronously create (sometimes
rapidly-order of tens to hundreds of milliseconds) updates for one  
of the
model values independently of the getter. To handle this, I  
currently have
the controller implement a delegate method for these asynchronous  
updates

and then do:

[mDeviceTable reloadData];

Unfortunately, this then causes the table to hit all the device  
getters for
all the devices and update all the columns even though only a  
single column
(and possibly row) has changed thereby creating needless bus  
traffic and

activity.


One approach would be to use a NSMutableIndex to keep track of which  
device/table row is in need of an update. As each device finishes an  
update it would set its index in the set. The benefit is that if your  
hardware updates more often than your chosen UI update rate, only the  
most recent values will be used. If device updates are happening in  
another thread, you'll need to protect read/write accesses to the  
index set with a lock so you don't access it when it's in an  
inconsistent state.


Then have a timer run periodically to check if any devices have  
updated information. For each index, just mark the corresponding  
table row as needing an update, then remove that index from the index  
set. When the table view is asked to update stale rows, it will just  
call tableView:objectValueForTableColumn:row: as for any other update.


My first inclination is to create an array of dictionaries that act  
as a
cache for the device attributes, have the asynchronous delegate  
update the

appropriate key/value and then have reloadData update from there.


Caching information would be a good idea, whether it happens in your C 
++ device class(es) or by copying information into a NSArray. It  
allows you to repeatedly access current device information without  
further touching the hardware, particularly if device access times  
are on the slow side. Getting that information synchronously would  
lock up the UI while the data is being fetched.


___

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

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

Help/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: Launching a preference pane from inside a Cocoa app

2009-04-01 Thread Mark Suman
The part that's tripping me up is launch System Preferences and then opening
a certain pane. In Apple Script, I'd say:

*tell* application "System Preferences"

activate

*set* *the* current pane *to* pane id "com.foo.prefpane"

*end* *tell*

[[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:
@"com.apple.systempreferences" options:nil additionalEventParamDescriptor
:??? launchIdentifier:nil];

I would like to pass in something like "set the current pane to pane id
\"com.foo.prefpane\" to the event to tell System Preferences to change to my
pane.

Can anyone tell me how to pass that in?  I tried through
additionalEventParamDescriptor, but was unsuccessful.  It launches System
Preferences, but does not switch to my prefpane.  (It works correctly if I
run the Apple Script.)

Mark

On Mon, Mar 30, 2009 at 2:40 PM, Nick Zitzmann  wrote:

>
> On Mar 30, 2009, at 11:17 AM, Mark Suman wrote:
>
>  Does anyone know the "Apple" way of launching a prefPane from a Cocoa app?
>>
>
>
> Yes. (If you were wondering _how_ to do it, then all you need to do is open
> the preference pane using NSWorkspace or Launch Services. System Preferences
> will then display the pane.)
>
> 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: Launching a preference pane from inside a Cocoa app

2009-04-01 Thread Nick Zitzmann


On Apr 1, 2009, at 11:54 AM, Mark Suman wrote:

I would like to pass in something like "set the current pane to pane  
id \"com.foo.prefpane\" to the event to tell System Preferences to  
change to my pane.


Can anyone tell me how to pass that in?



You're making this way too complicated. Try this instead:

[[NSWorkspace sharedWorkspace] openFile:@"/System/Library/ 
PreferencePanes/Network.prefPane"];


Of course, you would replace the string with the path to the  
preference pane you wish to load.


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: [BUG] Cursor Flicker

2009-04-01 Thread Shawn Erickson
On Wed, Apr 1, 2009 at 7:28 AM, Eric Gorr  wrote:

> In the real application, there are some cursors based on 64x64 images. When
> switching to these cursors, one sees the cursor quickly jump to a different
> position and then back to where it should be. This is very jarring and
> shouldn't happen. Why it briefly jumps, I do not know.

Is the cursors hot spot staying in the same place or not? If the hot
spot is moving around I would tend to agree that this is problem. If
the hot spot is unchanged then I think things are operating correctly.

-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


Re: Launching a preference pane from inside a Cocoa app

2009-04-01 Thread Sherm Pendley
On Wed, Apr 1, 2009 at 1:54 PM, Mark Suman  wrote:

> The part that's tripping me up is launch System Preferences and then
> opening
> a certain pane.


Just open the .prefPane bundle itself - System Preferences.app knows how to
handle the rest. For instance:

[[NSWorkspace sharedWorkspace] openFile:@
"/Library/PreferencePanes/Growl.prefPane"];

Additionally, if the .prefPane hasn't been installed yet, System
Preferences.app will ask if you want to install it, and if so, whether to
install it globally or just for the current user. In the former case, it
will handle the necessary authentication for you.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.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


Re: [BUG] Cursor Flicker

2009-04-01 Thread Eric Gorr


On Apr 1, 2009, at 2:04 PM, Shawn Erickson wrote:

On Wed, Apr 1, 2009 at 7:28 AM, Eric Gorr   
wrote:


In the real application, there are some cursors based on 64x64  
images. When
switching to these cursors, one sees the cursor quickly jump to a  
different
position and then back to where it should be. This is very jarring  
and

shouldn't happen. Why it briefly jumps, I do not know.


Is the cursors hot spot staying in the same place or not? If the hot
spot is moving around I would tend to agree that this is problem. If
the hot spot is unchanged then I think things are operating correctly.


Why would it make sense for a cursor to only for an instant move to a  
different location 30 or more pixels away and then move back to where  
it is supposed to be before the next cursor change?


The Hot Spot should essentially be in the same place for both cursors.

___

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

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

Help/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: [BUG] Cursor Flicker

2009-04-01 Thread Eric E. Dolecki
A quick question - why are you using a 64x64 image? Couldn't you use a
smaller image?
E.

On Wed, Apr 1, 2009 at 2:09 PM, Eric Gorr  wrote:

>
> On Apr 1, 2009, at 2:04 PM, Shawn Erickson wrote:
>
>  On Wed, Apr 1, 2009 at 7:28 AM, Eric Gorr  wrote:
>>
>>  In the real application, there are some cursors based on 64x64 images.
>>> When
>>> switching to these cursors, one sees the cursor quickly jump to a
>>> different
>>> position and then back to where it should be. This is very jarring and
>>> shouldn't happen. Why it briefly jumps, I do not know.
>>>
>>
>> Is the cursors hot spot staying in the same place or not? If the hot
>> spot is moving around I would tend to agree that this is problem. If
>> the hot spot is unchanged then I think things are operating correctly.
>>
>
> Why would it make sense for a cursor to only for an instant move to a
> different location 30 or more pixels away and then move back to where it is
> supposed to be before the next cursor change?
>
> The Hot Spot should essentially be in the same place for both cursors.
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/edolecki%40gmail.com
>
> This email sent to edole...@gmail.com
>



-- 
http://ericd.net
Interactive design and development
___

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

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

Help/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: Bindings and MenuItems

2009-04-01 Thread Ben Lachman
I mean a "Cocoa bindings" kind of binding.  e.g. the "target" binding  
of the menu item is bound in IB.  The action field of the binding is  
set to "print:".  I'm not talking about the traditional way of  
connecting a button/menu item to another object through the basic  
control drag from source to target and select the action method and  
I'm not talking about setting it in code.  I know how to do both of  
those and they work, what I'm going for is a dynamic target.


->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



On Apr 1, 2009, at 7:12 AM, Andy Lee wrote:


On Apr 1, 2009, at 3:34 AM, Ben Lachman wrote:
I have a menu item that is bound to a target.  The menu is resides  
in has "Auto Enables Items" checked which means that it should call  
-validateMenuItem on a items target if it is available.  However  
validate is never called on the target.  If I remove the binding  
and set the target to one of the objects manually in IB the  
validation method is called as expected.  Has anyone else run into  
this and if so, is there a work around?


What do you mean "binding"?  "Binding" has a very specific meaning,  
and is not how you connect an object to its target.


Do you mean you're making the connection in code?  If so, it should  
look something like:


   [myMenuItem setTarget:myTarget];
   [myMenuItem setAction:@selector(doMyAction:)];

Note the name of the action method is "doMyAction:", not  
"doMyAction", though I don't know if this affects whether  
validateMenuItem: is called.


Assuming your code does look like this, are you sure these lines of  
code are being executed?  If so, *when* are they being executed?  If  
you doing this in init, it's possible myMenuItem and myTarget have  
not been set yet -- you need to make the connection in awakeFromNib.


--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: Launching a preference pane from inside a Cocoa app

2009-04-01 Thread Mark Suman
I have a tendency to overcomplicate things.  Thanks for the simple solution.
 That worked like a charm.
Mark

On Wed, Apr 1, 2009 at 12:07 PM, Sherm Pendley wrote:

> On Wed, Apr 1, 2009 at 1:54 PM, Mark Suman  wrote:
>
>> The part that's tripping me up is launch System Preferences and then
>> opening
>> a certain pane.
>
>
> Just open the .prefPane bundle itself - System Preferences.app knows how to
> handle the rest. For instance:
>
> [[NSWorkspace sharedWorkspace] openFile:@
> "/Library/PreferencePanes/Growl.prefPane"];
>
> Additionally, if the .prefPane hasn't been installed yet, System
> Preferences.app will ask if you want to install it, and if so, whether to
> install it globally or just for the current user. In the former case, it
> will handle the necessary authentication for you.
>
> sherm--
>
> --
> Cocoa programming in Perl: http://camelbones.sourceforge.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


Re: [BUG] Cursor Flicker

2009-04-01 Thread Andy Lee

On Apr 1, 2009, at 2:09 PM, Eric Gorr wrote:

On Apr 1, 2009, at 2:04 PM, Shawn Erickson wrote:
On Wed, Apr 1, 2009 at 7:28 AM, Eric Gorr   
wrote:


In the real application, there are some cursors based on 64x64  
images. When
switching to these cursors, one sees the cursor quickly jump to a  
different
position and then back to where it should be. This is very jarring  
and

shouldn't happen. Why it briefly jumps, I do not know.


Is the cursors hot spot staying in the same place or not? If the hot
spot is moving around I would tend to agree that this is problem. If
the hot spot is unchanged then I think things are operating  
correctly.


Why would it make sense for a cursor to only for an instant move to  
a different location 30 or more pixels away and then move back to  
where it is supposed to be before the next cursor change?


The Hot Spot should essentially be in the same place for both cursors.


After some experimentation, it looks like the transparency has  
something to do with it.  It looks like NSCursor trims the transparent  
area from the edges so the actual image it uses is smaller than what  
you gave it.


I put a border around the image drawn with 1% opaqueness and I *think*  
the problem went away, but I have to run back to work now so I don't  
have time to look more closely.


--Andy

___

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

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

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

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


Re: Best Strategy to Control iTunes

2009-04-01 Thread Ammar Ibrahim
On Wed, Apr 1, 2009 at 12:15 AM, Nate Weaver wrote:

> On Mar 30, 2009, at 5:44 PM, Ammar Ibrahim wrote:
>
>>
- It's known that if any dialog is open in iTunes it freezes any
 communication through the scriptable interface, how can I detect that
 and
 put all my "messages" in a queue, so that when iTunes is responsive, I

>>> can
>>>
 send my messages?

>>>
>>>
>>> What kind of task are you trying to accomplish?  Are you sure you have to
>>> know whether a dialog is open in iTunes?  AFAIK you can't do anything
>>> similar, in any application.
>>>
>>
>>
>> If I want to add a track to iTunes, I need to make sure iTunes is
>> responsive.
>>
>
> Interestingly enough, iTunes sends a distributed notification (listenable
> via NSDistributedNotificationCenter) whenever it shows or hides a modal
> dialog. It even sends the resource ID (in the iTunes.rsrc file) of the
> particular dialog along with the "show" notification.
>
> I don't have the specific notification name on hand here at work, but you
> can easily discover it by writing a simple test app that listens for every
> distributed notification.


Thanks, this was very helpful, I found so far that all iTunes notifications
are prefixed with "com.apple.iTunes". Now, two more questions:

1- How can I open the .rsrc file, and what is it exactly?
2- Is there a way to programmatically close a dialog in another App (e.g.
close the iTunes dialog from an external App)
___

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

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

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

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


Re: Best Strategy to Control iTunes

2009-04-01 Thread Ammar Ibrahim
On Wed, Apr 1, 2009 at 2:25 PM, has  wrote:

> Michael Ash wrote:
>
>  On Tue, Mar 31, 2009 at 3:57 PM, Luca C. 
>> wrote:
>>
>>> 2009/3/31 Ammar Ibrahim 
>>>
 If I want to add a track to iTunes, I need to make sure iTunes is
 responsive.

  Are you sure it is that important? Actually, if you run an AS script
>>> wich,
>>> say, opens with the Finder some mp3 files whilst iTunes has dialog
>>> windows
>>> opened, the command will be automatically enqueued. Â In other words,
>>> your
>>> tracks will be added after the user closes the dialog window.
>>> Â Run the script in a separate thread so it won't block your
>>> application's
>>> interface in any case.
>>>
>>
>> No, don't do this. AppleScript is not safe to use outside the main
>> thread. If you must run AppleScript asynchronously, either spawn a
>> subprocess to run it or, better yet, don't use AS at all but send
>> Apple Events in some other way, such as with ScriptingBridge.
>>
>
>
> Scripting Bridge apparently isn't thread-safe either:
>
> http://www.dribin.org/dave/blog/archives/2009/02/01/main_thread_apis/
>
> ObjC-appscript is almost entirely thread-safe. You'll need to watch when
> using methods that rely on the Carbon Process Manager (some initializers,
> -isRunning) as the PM APIs don't appear to be thread-safe itself, but the
> main query builder and event dispatch methods should work fine on any thread
> (e.g. I use Python appscript in a background thread without problems).
>
> For example:
>
> tell application "iTunes"
>set newPlaylist to make new playlist with properties
> {name:"Rock-n-Roll", shuffle:true}
>duplicate (every track of library playlist 1 whose artist is "Chuck
> Berry") to newPlaylist
> end tell
>
>
> #import "ITGlue/ITGlue.h"
>
> int main (int argc, const char * argv[]) {
>NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>int err = 0;
>
>// create a new application object
>ITApplication *itunes = [ITApplication applicationWithBundleID:
> @"com.apple.itunes"];
>
>// create a new playlist
>ITMakeCommand *cmd = [[[itunes make] new_: [ITConstant playlist]]
>   withProperties: [NSDictionary
> dictionaryWithObjectsAndKeys:
>ASTrue, [ITConstant
> shuffle],
>@"Rock-n-Roll", [ITConstant
> name],
>nil]];
>ITReference *newPlaylist = [cmd send];
>
>// duplicate all tracks that match the given criteria to the new
> playlist
>ITReference *ref = itunes libraryPlaylists] at: 1] tracks]
>byTest: [[ITIts artist]
> equals: @"Chuck Berry"]];
>
>NSError *error;
>NSArray *tracks = [[[ref duplicate] to: newPlaylist] sendWithError:
> &error];
>if (!tracks) {
>// check for errors
>NSLog(@"%@", [error localizedDescription]);
>err = [error code];
>} else
>// display result
>NSLog(@"%@", tracks);
>
>[pool drain];
>return err;
> }
>
> The ASDictionary application on the appscript site has options for
> exporting application dictionaries in both human-readable HTML format and as
> ObjC glue files.
>
> Not surprisingly, the ObjC code's a bit more verbose, but straightforward
> enough to construct once you understand the general principles behind Apple
> event-based IPC. Appscript respects the original Apple event semantics and
> doesn't obfuscate them under piles of fake Cocoa-isms, so if you already
> know how to do it in AppleScript then it's pretty much a straight
> translation: there's even a free tool, ASTranslate, that will help you with
> that.
>
> Apple event IPC is kinda weird and very different to Cocoa/OOP (a rough
> analogy would be to using XPath queries over XML-RPC) but is usually
> serviceable once you get your head around it. Apple docs do a lousy job of
> explaining how it all works, but there's an introduction to the basic
> concepts in the appscript manual and links on the appscript site to further
> information.
>
>
> Oh, and as for checking if an application is responsive - I'd suggest just
> sending an event and seeing if it times out (timeouts may be reported as
> either error -609 or -1712, depending on what sort of mood AESendMessage is
> in at the time). The launch event (ascr/noop) is basically a no-op that will
> return error -1708 if 'successfully' handled; handy if you don't want to
> send a 'work' event.
>
> HTH
>
> has
> --
> Control AppleScriptable applications from Python, Ruby and ObjC:
> http://appscript.sourceforge.net
>
>
Thanks for your answer.

I'm afraid I'm new and don't quite understand, do you recommend I use
appscript? If so, what's the difference between the following methods:

1- NSAppleScript
2- Cocoa Scripting Bridge
3- AppScript
4- Command line invocation of osascript
___

Cocoa-dev mailing list (Cocoa-dev@li

Re: Best Strategy to Control iTunes

2009-04-01 Thread Luca C.
2009/4/1 Michael Ash 
>
>
> No, don't do this. AppleScript is not safe to use outside the main
> thread. If you must run AppleScript asynchronously, either spawn a
> subprocess to run it or, better yet, don't use AS at all but send
> Apple Events in some other way, such as with ScriptingBridge.


  I didn't realize the unsafety of NSAppleScript - so I have been quite
lucky, because my usage of applescript in non-main threads haven't caused me
any problems.

  ScriptingBridge seems not to be thread safe, too.  Adding a track to the
iTunes library using either applescript or SB will cause a block of the app
if iTunes has dialog windows opened.

  The solution could be writing a command line application, wich does all
the work you need, either using AS or SB.

--Luca C.
___

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

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

Help/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: NS <-> CG Rect Conversion and screen coordinates

2009-04-01 Thread Peter Ammon


On Mar 31, 2009, at 9:34 PM, Trygve Inda wrote:


Using these two calls:

NSRect nsRect = [screen frame];
CGRect cgRect = CGDisplayBounds (displayID);

I get for my two screens:

NSx=0y=0  w=2560h=1600  // screen A
CGx=0y=0  w=2560h=1600

NSx=-1920y=184w=1920h=1200  // screen B
CGx=-1920y=216w=1920h=1200


It seems CG origin is Top, Left with y growing down, while NS is  
origin

Bottom, Left, y growing up. So I convert CG to NS with:

// Convert CG coordinates from (TL, y down) to (BL, y up)

CGRectmainScreenRect = CGDisplayBounds (CGMainDisplayID ());

cgRect.origin.y = (cgRect.origin.y + cgRect.size.height -
mainScreenRect.size.height) * -1;

(216 + 1200 - 1600) * -1 = 184

Is there a system function that does this? NSRectFromCGRect does not  
do the

coordinate conversion.


No, there is no function to do this conversion.

Note that your conversion has a subtle bug that will fail for multiple  
displays.  The CG coordinate system has its origin at the top of the  
zero screen, not the main screen (which changes with the user focus).   
The zero screen is the screen at index zero in the +screens array.


So if you define a function like this:

CGFloat zeroScreenHeight(void) {
   CGFloat result = 0;
   NSArray *screens = [NSScreen screens];
   if ([screens count] > 0) result = NSHeight([[screens objectAtIndex: 
0] frame]);

   return result;
}

then you can do screen-coordinate conversions like this:

NSMakePoint(cgPoint.x, zeroScreenHeight() - cgPoint.y);
NSMakeRect(cgRect.origin.x,  zeroScreenHeight() - cgRect.origin.y -  
cgRect.size.height, cgRect.size.width, cgRect.size.height);


-Peter


___

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

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

Help/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: Persistent store removal throwing invalidated NSManagedObject exceptions

2009-04-01 Thread Jonathan Dann

Thanks Jonathan. You're absolutely right.

However, when I made the appropriate changes, I have the same issue:  
with my new custom remove... accessor, I get the exception, and  
without the custom accessor, there is no exception. So something  
strange is still going on.


Here is the new accessor for good measure:

-(void)removeCollectionsObject:(KnowledgeCollection *)anObject {
NSSet *removedObjects = [[NSSet alloc] initWithObjects:&anObject  
count:1];
[self willChangeValueForKey:@"collections"  
withSetMutation:NSKeyValueMinusSetMutation  
usingObjects:removedObjects];
[[self primitiveValueForKey:@"collections"]  
removeObject:anObject];
[self didChangeValueForKey:@"collections"  
withSetMutation:NSKeyValueMinusSetMutation  
usingObjects:removedObjects];

[removedObjects release];
}

Drew


Have you tried declaring your own -primitiveCollections and - 
setPrimitiveCollections: methods like in the example code (not that  
I'm sure that's the issue at all.


Can you post more of your model so I can get the bigger picture,  
please? Particularly how the CollectionGroup managed object fits in.


Jonathan

http://espresso-served-here.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:Persistent store removal throwing invalidated NSManagedObject exceptions

2009-04-01 Thread Ben Trumbull

I've setup a temporary managed object context to export data to an
external XML file (persistent store). When I remove the persistent
store from the context, I am getting errors like this:

Exception raised during posting of notification.  Ignored.  exception:
'The NSManagedObject with ID:0x18656990 

has been invalidated.'  invoked observer method: '*** -

[NSManagedObjectContext _storeConfigurationChanged:]'  observer:
0x1864d370  notification name:
'_NSPersistentStoreCoordinatorStoresDidChangePrivateNotification'


When you remove a store from the coordinator, all the live managed  
objects from that store are invalidated.  Their backing store is gone,  
so they are pretty useless, and we cannot fulfill any requests to  
materialize faults without the store.


So what you see here is a KVO observer trying to fire a fault after  
you've removed the store and the fault is severed from the backing  
persistence mechanism.


You should remove all your KVO observers before removing the store.

- Ben



___

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

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

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

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


Re: Best Strategy to Control iTunes

2009-04-01 Thread Ammar Ibrahim
On Wed, Apr 1, 2009 at 10:21 PM, Luca C.  wrote:

> 2009/4/1 Michael Ash 
> >
> >
> > No, don't do this. AppleScript is not safe to use outside the main
> > thread. If you must run AppleScript asynchronously, either spawn a
> > subprocess to run it or, better yet, don't use AS at all but send
> > Apple Events in some other way, such as with ScriptingBridge.
>
>
>   I didn't realize the unsafety of NSAppleScript - so I have been quite
> lucky, because my usage of applescript in non-main threads haven't caused
> me
> any problems.
>
>  ScriptingBridge seems not to be thread safe, too.  Adding a track to the
> iTunes library using either applescript or SB will cause a block of the app
> if iTunes has dialog windows opened.
>
>  The solution could be writing a command line application, wich does all
> the work you need, either using AS or SB.
>

Right now, I'm more confused than I was, hehe. My question is: Why would I
care about thread safety? Assuming that everytime I communicate with iTunes
I create a thread and have the communication happen from there, even if it's
blocking and times out, it wouldn't affect my main application. I'm I
missing anything here? How would be the command line application any
different from this?
___

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

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

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

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


How to synchronize two managedObjectContexts...

2009-04-01 Thread Jon C. Munson II
Namaste!

I'm having trouble with an implementation of drag-and-drop for a
core-data-based application.

Scenario:  I'm implementing the drag destination for file names coming from
an application (like Finder).  The receiving window will take the filenames
and create the appropriate records for the core-data entity that is the
basis of the window.

The drop isn't so much the issue, but rather what to do with it.

If there is a better way to do this, I'd appreciate hearing about it.

After trying:

1.  Adding to the array controller for that entity,
2.  Adding to the main managedObjectContext,
3.  Adding to a distinct managedObjectContext,

And finding that 1 & 2 weren't workable (didn't go too far with #1 as the
add method didn't do what I wanted, and #2 wouldn't create the default data
as stipulated by the class file for the entity and did a great deal of
hangtime), #3 works just fine (no crashes, and default data populates as
expected) EXCEPT I can't seem to get the secondary MOC to notify the primary
MOC of the additions.

I've seen the dox for -mergeChangesFromContextDidSaveNotification (and then
the refreshObject to follow), however, I could not find a complete example
of its implementation (where does that go, etc.).

So, I'm not sure where to go with this - I could use a good example or
better explanation.

Many thanks in advance!

Peace, Love, and Light,

/s/ Jon C. Munson II


___

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

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

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

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


Re: Saving Address Book for more than 1000 recrods

2009-04-01 Thread Ben Trumbull

On Apr 1, 2009, at 7:17 AM, Vijay Kanse wrote:


is This a behavior of address book for more than 1000 records ? if
it is,
how can i fix it?



You can't. As you've discovered, the AddressBook framework is rather
slow when it comes to large batch operations, and has been since they
switched from Metakit to CoreData in Leopard. You'll just have to wait
for it to finish, because I will be very surprised if the framework
turns out to be thread-safe.


You can create a new AB on a background thread (e.g. not the default  
sharedAddressBook) and save in the background to avoid blocking the  
main thread.


If you have performance issues, you should file them with bugeport.apple.com 
.  In situations like this, Shark traces are very helpful.


- Ben



___

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

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

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

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


Re: user access privileges to plist in /library/preferences

2009-04-01 Thread Greg Guerin

Memo Akten wrote:

Hi Greg, actually /Users/Shared didn't work either. If I am logged  
in as admin it works, but if I am logged in as a normal user it  
doesn't. My code is:


#define LOG_PATH_FOLDER @"/Users/Shared/Library/Preferences/"
#define LOG_FILENAME @"MyLog.plist"
#define LOG_PATH [LOG_PATH_FOLDER  
stringByAppendingPathComponent:LOG_FILENAME]


NSFileManager *fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath: LOG_PATH_FOLDER] == NO) {
NSLog(@"creating folder %@", LOG_PATH_FOLDER);
[fileManager createDirectoryAtPath: LOG_PATH_FOLDER attributes: nil];


Do you understand the Posix permissions and ownership concepts, as  
applied to files and dirs?  If not, you need to learn those.


Do you understand the Posix 'umask' concept and its default value?   
Again, you should learn that.


Finally, you will need to provide non-nil attributes to  
createDirectoryAtPath: that specifies all-read, all-write, and all- 
search permissions on the created dir.  If you don't, then the  
directory will not be writable to anyone except its owner (the user  
account that creates it), due to how the default umask value affects  
the created dirs initial permissions.


Whenever you write the log-file, you may also need to specify all- 
write permissions.  It may depend on how you write the file.


You might also consider having a user-specific LOG_FILENAME,  
constructed from the current user-ID.  This means that users won't be  
overwriting one another's logs.  It also means that a log-analyzer  
would have to coalesce multiple plist files, but that's not too  
difficult with NSDictionary.


  -- GG

___

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

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

Help/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: Bindings and MenuItems

2009-04-01 Thread Keary Suska


On Apr 1, 2009, at 12:31 PM, Ben Lachman wrote:

I mean a "Cocoa bindings" kind of binding.  e.g. the "target"  
binding of the menu item is bound in IB.  The action field of the  
binding is set to "print:".  I'm not talking about the traditional  
way of connecting a button/menu item to another object through the  
basic control drag from source to target and select the action  
method and I'm not talking about setting it in code.  I know how to  
do both of those and they work, what I'm going for is a dynamic  
target.



I think I wasn't recalling correctly--my issue had to do with an  
NSButton, and binding didn't work for me. There is no reason to  
suspect that the binding wouldn't work as advertised.


Anyway, I suppose you have verified that the correct object is being  
set when the binding is established (and/or when the bound property  
changes)?


Best,

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

___

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

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

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

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


Re: Best Strategy to Control iTunes

2009-04-01 Thread Luca C.
2009/4/1 Ammar Ibrahim 

> On Wed, Apr 1, 2009 at 10:21 PM, Luca C.  wrote
>>
>>
>>   I didn't realize the unsafety of NSAppleScript - so I have been quite
>> lucky, because my usage of applescript in non-main threads haven't caused
>> me
>> any problems.
>>
>>  ScriptingBridge seems not to be thread safe, too.  Adding a track to the
>> iTunes library using either applescript or SB will cause a block of the
>> app
>> if iTunes has dialog windows opened.
>>
>>  The solution could be writing a command line application, wich does all
>> the work you need, either using AS or SB.
>>
>
> Right now, I'm more confused than I was, hehe. My question is: Why would I
> care about thread safety? Assuming that everytime I communicate with iTunes
> I create a thread and have the communication happen from there, even if it's
> blocking and times out, it wouldn't affect my main application. I'm I
> missing anything here? How would be the command line application any
> different from this?
>

You have to care about thread safety when using a multithreaded design.To
keep it simple:
  The main thread of your application handles every event-related action and
the user interface.  So if you perform a lenghty operation in it, your
application will not able to handle anything until your operation ends.  To
avoid that, a solution could be creating a new worker thread, in wich
performing every action you need.  Note that you can use only thread-safe
classes in your created threads.
 For further information, you can read the Apple's documentation about
thread safety
<
http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html
>

 Creating an helper tool would be useful, since opening it will cause the
creation of a new process.  Your application's main thread will not be
affected in any way by it.

--Luca C.
___

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

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

Help/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: XMLParser

2009-04-01 Thread Marcel Weiher
If you like that type of higher-level, more Objective-C-like approach,  
you might want to have a look at Objective-XML, and more specifically  
the MAX parser ( MAX = Message oriented API for XML):



http://www.metaobject.com/blog/2009/01/iphone-xml-performance.html
http://www.metaobject.com/blog/2009/01/objective-xml-50.html


Parser callbacks in MAX are of the form:
-itemElement:(MPWXMLAttributes*)children attributes: 
(MPWXMLAttributes*)attributes parser:(MPWMAXParser*)p
where  is a tag name.  MAX handles both children and  
attributes.  MPWXmlAttributes handle the required XML semantics, such  
as preserving order, dealing with duplicates (in the case of  
children), preserving namespaces and even supporting case-insensitive  
lookups for HTML.  Where possible, they preserve compatibility with  
NSDictionary and NSArray.


The callback can return an object, and if it does, MAX will build a  
tree for you similar to a DOM, except with your objects.  If you don't  
return objects in your callbacks, no tree will be built.


Finally, MAX can load and parse data incrementally when given a URL  
data source, is around 10x faster than NSXMLParser and can be  
configured to parse HTML in addition to XML.


Cheers,

Marcel



On Mar 29, 2009, at 12:20 , David Blanton wrote:


acolol way to  parse is make you element names method names



- (void)parser:(NSXMLParser *)parser didStartElement:(NSString  
*)elementName namespaceURI:(NSString *)namespaceURI qualifiedName: 
(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict {


elementName = [elementName stringByAppendingString:@":"];
SEL selector = NSSelectorFromString(elementName);
if([self respondsToSelector:selector])
[self performSelector:selector withObject:attributeDict];

}


Then an element parser looks like where 'properties'was an XML:  
element name


- (void)properties:(NSDictionary *)attributeDict {

id obj = [attributeDict objectForKey:@"count"];
// do more
}



___

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

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

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

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


Re: Best Strategy to Control iTunes

2009-04-01 Thread Bill Bumgarner

On Apr 1, 2009, at 2:04 PM, ammar.ibrahim wrote:
Right now, I'm more confused than I was, hehe. My question is: Why  
would I
care about thread safety? Assuming that everytime I communicate  
with iTunes
I create a thread and have the communication happen from there,  
even if it's

blocking and times out, it wouldn't affect my main application. I'm I
missing anything here? How would be the command line application any
different from this?



Simply because you isolate your use of the AppleScript API to a thread  
does not make the API safe to use from that thread.You have no  
control over what other bits of framework infrastructure might tickle  
the thread-unsafe parts of the target API while updating the UI or  
responding to user events.


By isolating the code to a subprocess -- a command line application --  
it can be both single threaded and isolated from your application's  
threads.


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: NS <-> CG Rect Conversion and screen coordinates

2009-04-01 Thread Jesper Storm Bache

Forgive me for being dense. Where is the subtle bug?
The code is using CGMainDisplayID (not [NSScreen mainScreen] which  
would be the display with the key window)


CGMainDisplayID is documented as:
===
The main display is the display with its screen location at (0,0) in  
global coordinates. In a system without display mirroring, the display  
with the menu bar is typically the main display.

===

I would expect that CGRectGetHeight(CGDisplayBounds (CGMainDisplayID  
())) == zeroScreenHeight()?



Jesper Storm Bache
Core Technologies
Adobe Systems Inc


On Apr 1, 2009, at 12:25 PM, Peter Ammon wrote:



On Mar 31, 2009, at 9:34 PM, Trygve Inda wrote:


Using these two calls:

NSRect nsRect = [screen frame];
CGRect cgRect = CGDisplayBounds (displayID);

I get for my two screens:

NSx=0y=0  w=2560h=1600  // screen A
CGx=0y=0  w=2560h=1600

NSx=-1920y=184w=1920h=1200  // screen B
CGx=-1920y=216w=1920h=1200


It seems CG origin is Top, Left with y growing down, while NS is
origin
Bottom, Left, y growing up. So I convert CG to NS with:

// Convert CG coordinates from (TL, y down) to (BL, y up)

CGRectmainScreenRect = CGDisplayBounds (CGMainDisplayID ());

cgRect.origin.y = (cgRect.origin.y + cgRect.size.height -
mainScreenRect.size.height) * -1;

(216 + 1200 - 1600) * -1 = 184

Is there a system function that does this? NSRectFromCGRect does not
do the
coordinate conversion.


No, there is no function to do this conversion.

Note that your conversion has a subtle bug that will fail for multiple
displays.  The CG coordinate system has its origin at the top of the
zero screen, not the main screen (which changes with the user focus).
The zero screen is the screen at index zero in the +screens array.

So if you define a function like this:

CGFloat zeroScreenHeight(void) {
   CGFloat result = 0;
   NSArray *screens = [NSScreen screens];
   if ([screens count] > 0) result = NSHeight([[screens objectAtIndex:
0] frame]);
   return result;
}

then you can do screen-coordinate conversions like this:

NSMakePoint(cgPoint.x, zeroScreenHeight() - cgPoint.y);
NSMakeRect(cgRect.origin.x,  zeroScreenHeight() - cgRect.origin.y -
cgRect.size.height, cgRect.size.width, cgRect.size.height);

-Peter


___

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

Please do not post admin requests or moderator comments to the list.
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: NS <-> CG Rect Conversion and screen coordinates

2009-04-01 Thread Peter Ammon
My mistake, I saw mainScreenRect and assumed it was the frame of what  
Cocoa calls the main screen.


-Peter

On Apr 1, 2009, at 2:52 PM, Jesper Storm Bache wrote:


Forgive me for being dense. Where is the subtle bug?
The code is using CGMainDisplayID (not [NSScreen mainScreen] which  
would be the display with the key window)


CGMainDisplayID is documented as:
===
The main display is the display with its screen location at (0,0) in  
global coordinates. In a system without display mirroring, the  
display with the menu bar is typically the main display.

===

I would expect that CGRectGetHeight(CGDisplayBounds (CGMainDisplayID  
())) == zeroScreenHeight()?



Jesper Storm Bache
Core Technologies
Adobe Systems Inc


On Apr 1, 2009, at 12:25 PM, Peter Ammon wrote:



On Mar 31, 2009, at 9:34 PM, Trygve Inda wrote:


Using these two calls:

NSRect nsRect = [screen frame];
CGRect cgRect = CGDisplayBounds (displayID);

I get for my two screens:

NSx=0y=0  w=2560h=1600  // screen A
CGx=0y=0  w=2560h=1600

NSx=-1920y=184w=1920h=1200  // screen B
CGx=-1920y=216w=1920h=1200


It seems CG origin is Top, Left with y growing down, while NS is
origin
Bottom, Left, y growing up. So I convert CG to NS with:

// Convert CG coordinates from (TL, y down) to (BL, y up)

CGRectmainScreenRect = CGDisplayBounds (CGMainDisplayID ());

cgRect.origin.y = (cgRect.origin.y + cgRect.size.height -
mainScreenRect.size.height) * -1;

(216 + 1200 - 1600) * -1 = 184

Is there a system function that does this? NSRectFromCGRect does not
do the
coordinate conversion.


No, there is no function to do this conversion.

Note that your conversion has a subtle bug that will fail for  
multiple

displays.  The CG coordinate system has its origin at the top of the
zero screen, not the main screen (which changes with the user focus).
The zero screen is the screen at index zero in the +screens array.

So if you define a function like this:

CGFloat zeroScreenHeight(void) {
  CGFloat result = 0;
  NSArray *screens = [NSScreen screens];
  if ([screens count] > 0) result = NSHeight([[screens objectAtIndex:
0] frame]);
  return result;
}

then you can do screen-coordinate conversions like this:

NSMakePoint(cgPoint.x, zeroScreenHeight() - cgPoint.y);
NSMakeRect(cgRect.origin.x,  zeroScreenHeight() - cgRect.origin.y -
cgRect.size.height, cgRect.size.width, cgRect.size.height);

-Peter


___

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

Please do not post admin requests or moderator comments to the list.
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


NSAccessibilityLinkedUIElementsAttributes

2009-04-01 Thread Rich Collyer
Are there any samples of using  
NSAccessibilityLinkedUIElementsAttribute?  Specifically, I need to do  
something like what iTunes does where it links the outline view  in  
the left navigation with the content view in the middle.


+++
Rich Collyer - Senior Software Engineer
+++



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Cocoa Access to iPhone info

2009-04-01 Thread Jeff Laing
My boss has just discovered the iPhone Field Test mode (described here:
http://www.wirelessinfo.com/content/inside-the-iphone-field-test-mode.ht
m) and was wondering whether there is a mechanism for a regular Cocoa
app to get at that Cell information.

I'm guessing the answer is no, but I figured I might as well ask.
Failing Cocoa, is that info available via some sort of sysctl() or
ioctl() interface ?

Thanks in advance,

Jeff Laing 

--
Remember kids, there are no stupid questions, just stupid people.
  -- Mr Garrison, "South
Park"

___

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

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

Help/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: NS <-> CG Rect Conversion and screen coordinates

2009-04-01 Thread Jesper Storm Bache

Good (otherwise I would have had to change a few things on my side).

The term "main" is very confusing and I did log the following radar a  
while back.

6392495 Confusing documentation for NSScreen
 It looks like it has been fixed (and is ready to be included in a  
future documentation update).


Jesper

On Apr 1, 2009, at 3:27 PM, Peter Ammon wrote:


My mistake, I saw mainScreenRect and assumed it was the frame of what
Cocoa calls the main screen.

-Peter

On Apr 1, 2009, at 2:52 PM, Jesper Storm Bache wrote:


Forgive me for being dense. Where is the subtle bug?
The code is using CGMainDisplayID (not [NSScreen mainScreen] which
would be the display with the key window)

CGMainDisplayID is documented as:
===
The main display is the display with its screen location at (0,0) in
global coordinates. In a system without display mirroring, the
display with the menu bar is typically the main display.
===

I would expect that CGRectGetHeight(CGDisplayBounds (CGMainDisplayID
())) == zeroScreenHeight()?


Jesper Storm Bache
Core Technologies
Adobe Systems Inc


On Apr 1, 2009, at 12:25 PM, Peter Ammon wrote:



On Mar 31, 2009, at 9:34 PM, Trygve Inda wrote:


Using these two calls:

NSRect nsRect = [screen frame];
CGRect cgRect = CGDisplayBounds (displayID);

I get for my two screens:

NSx=0y=0  w=2560h=1600  // screen A
CGx=0y=0  w=2560h=1600

NSx=-1920y=184w=1920h=1200  // screen B
CGx=-1920y=216w=1920h=1200


It seems CG origin is Top, Left with y growing down, while NS is
origin
Bottom, Left, y growing up. So I convert CG to NS with:

// Convert CG coordinates from (TL, y down) to (BL, y up)

CGRectmainScreenRect = CGDisplayBounds (CGMainDisplayID ());

cgRect.origin.y = (cgRect.origin.y + cgRect.size.height -
mainScreenRect.size.height) * -1;

(216 + 1200 - 1600) * -1 = 184

Is there a system function that does this? NSRectFromCGRect does  
not

do the
coordinate conversion.


No, there is no function to do this conversion.

Note that your conversion has a subtle bug that will fail for
multiple
displays.  The CG coordinate system has its origin at the top of the
zero screen, not the main screen (which changes with the user  
focus).

The zero screen is the screen at index zero in the +screens array.

So if you define a function like this:

CGFloat zeroScreenHeight(void) {
 CGFloat result = 0;
 NSArray *screens = [NSScreen screens];
 if ([screens count] > 0) result = NSHeight([[screens objectAtIndex:
0] frame]);
 return result;
}

then you can do screen-coordinate conversions like this:

NSMakePoint(cgPoint.x, zeroScreenHeight() - cgPoint.y);
NSMakeRect(cgRect.origin.x,  zeroScreenHeight() - cgRect.origin.y -
cgRect.size.height, cgRect.size.width, cgRect.size.height);

-Peter


___

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

Please do not post admin requests or moderator comments to the list.
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: Why does -[NSURLConnection start] crash?

2009-04-01 Thread Jeff Johnson
Thanks, Dave. The first link does seem to have a workaround for the  
crash. (Not sure the second link is the same problem, though.)


Bug filed:

rdar://problem/6747757

The question is whether this is a framework bug or just a  
documentation bug. Can anyone from Apple please clarify this?


-Jeff


On Mar 30, 2009, at 4:29 PM, Dave Keck wrote:


I had this problem several months ago, and found several other
references to the issue:

http://veys.com/2008/08/17/nsurlconnection-startimmediatelyno-boom/
http://amromousa.com/2008/08/27/nsurlconnection-timeoutconnection-amdev-woes/

I suppose a bug report is in order...

On Mon, Mar 30, 2009 at 9:32 AM, Jeff Johnson
 wrote:

Here's the sample code:

http://lapcatsoftware.com/downloads/ConnectionStartCrash.m

It crashes when calling this:

_connection = [[NSURLConnection alloc] initWithRequest:request  
delegate:self

startImmediately:NO];
[_connection start];

but not this:

_connection = [[NSURLConnection alloc] initWithRequest:request  
delegate:self

startImmediately:YES];

Of course, you wouldn't normally want to call [_connection start]
immediately; in my tool, I was using performSelector:afterDelay: to  
call it,

and the crash still occurs.

Here's the backtrace:

#0  0x97092152 in CFSetApplyFunction ()
#1  0x95b0cdad in CFNSchedulingSetScheduleSource ()
#2  0x95b375bb in RunLoopMultiplexer::sourceForScheduling ()
#3  0x95b3769a in RunLoopMultiplexer::schedule ()
#4  0x95b88d96 in URLConnectionClient::start ()
#5  0x1bd9 in -[MyConnectionDelegate connectWithCrash:]  
(self=0x103330,

_cmd=0x1f5c, shouldCrash=1 '\001') at
/Users/jeff/Documents/Programming/TestProjects/ConnectionStartCrash/ 
ConnectionStartCrash.m:24

#6  0x1d38 in main (argc=1, argv=0xb694) at
/Users/jeff/Documents/Programming/TestProjects/ConnectionStartCrash/ 
ConnectionStartCrash.m:50


The argument for cachePolicy: doesn't seem to matter, by the way.

Am I missing something? Is there some run loop setup I need to  
perform?


-Jeff


___

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

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

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

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


Double Clicks in an NSTextView.

2009-04-01 Thread Тимофей Даньшин

Hello.

I would like to be able to intercept double clicks on the text in an  
NSTextView even if the text is not a link and is not in an  
NSTextAttachmentCell. I did try to do this by implementing the  
textView: willChangeSelectionFromCharacterRange: toCharacterRange and  
comparing the initial and the proposed ranges and the time between the  
current call to this method and the previous one. But that doesn't  
work quite well, for i often get "double clicks" when i select the  
text by holding shift and an arrow key.


I know, that the method for intercepting double clicks is private.

Is there any working work around for that?

Thank you for your replies in advance.


Timofey.
___

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

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

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

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


Line height of drawWithRect:options: seems a bit messed up

2009-04-01 Thread Yung-Luen Lan
Hi,

I have some code that draws attributed string to a given location
using given fonts/sizes/styles with [NSAttributedString
drawWithRect:options:].

However, I found that the string were not aways aligned to top on some
fonts when I supply NSStringDrawingUsesLineFragmentOrigin option,
which should use the rect origin as the top left corner of line
fragments.

http://www.flickr.com/photos/yllan/3405764516/
Here is the figure that explains what I encountered: I don't want the
extra red space in this picture.

What option/attribute should I supply to make my string align to the
top edge of bounding box just like how TextEdit does?
The string may contains different fonts/sizes.

I'm also curious about why some fonts have these extra space, but some
fonts don't. Is this because the metric/feature of fonts or the bug of
NSStringDrawing method that calculate the wrong line height?

Any suggestions are welcome.

Regards,
yllan
___

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

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

Help/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: Double Clicks in an NSTextView.

2009-04-01 Thread Martin Wierschin
I would like to be able to intercept double clicks on the text in  
an NSTextView even if the text is not a link and is not in an  
NSTextAttachmentCell. I did try to do this by implementing the  
textView: willChangeSelectionFromCharacterRange: toCharacterRange  
and comparing the initial and the proposed ranges and the time  
between the current call to this method and the previous one.


Can't you simply check if a double-click is in progress during the  
"willChange" method? Eg: [[[textView window] currentEvent] clickCount].


If not, subclass NSTextView and override mouseDown and you can check  
the click count of the NSEvent parameter directly.


~Martin

___

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

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

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

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


Re: NSMutableArray is null?

2009-04-01 Thread Pierce Freeman
Yeah, it helps a lot... And hopefully anyone that has this problem will look
at this before writing to any support site. :)


On 4/1/09 8:06 AM, "I. Savant"  wrote:

> On Wed, Apr 1, 2009 at 10:33 AM, Pierce Freeman
>  wrote:
> 
>> Yeah, I finally figured that out. ;) It now works like a charm.
> 
>   Just for completeness, the plain-language concept to remember is:
> 
> // "Let there be an NSMutableArray pointer named 'globalVariable'."
> NSMutableArray * globalVariable;
> 
> ... and ...
> 
> // "Create an NSMutableArray instance and assign it to the
> 'globalVariable' pointer
> // ... so when I talk to 'globalVariable', I mean this instance of
> NSMutableArray."
> globalVariable = [[NSMutableArray alloc] init];
> 
>   By contrast, when you're creating objects inside a method (temporary
> objects whose scope is limited to that method), do this all in one go:
> 
> NSMutableArray * myTemporaryArray = [[NSMutableArray alloc] init];
> 
>   - or, more simply -
> 
> NSMutableArray * myTemporaryArray = [NSMutableArray array];
> 
>   ... then you'll use it then let it die, or hand it off to someone else.
> 
>   However, since you're creating an instance variable in your class,
> you declare the pointer in your header and then create an array and
> assign it to the pointer somewhere in your implementation. The most
> likely place (arguably by best practice) would be the class's -init
> method, since you want a mutable array ready for use when an instance
> of your class is created (allocated and initialized).
> 
>I hope that helps a bit.
> 
> --
> 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: How to detect curly quotes

2009-04-01 Thread John Engelhart
On Tue, Mar 31, 2009 at 6:21 PM, Steve Cronin  wrote:

> Folks;
>
> I'm reading input from a text file (stringWithContentsOfFile) I have no
> control over.
> Testing is going well until a I encounter a phrase is wrapped in curly
> quotes.
> (Note phrases wrapped in straight quotes are fine)
>
> Without trying to digest the entirety of the Mac OS Text Encoding system,
> can someone suggest a simple way to detect these characters?
>

You can use regular expressions.  RegexKitLite @
http://regexkit.sourceforge.net/RegexKitLite/ which you can download at
http://downloads.sourceforge.net/regexkit/RegexKitLite-2.2.tar.bz2

For example, you can be extremely lazy and do something along the lines of:

NSStringEncoding fileEncoding;
NSString *fileString = [[NSString stringWithContentsOfFile:@"file.txt"
usedEncoding:&fileEncoding error:NULL] stringByReplacingOccurrencesOfRegex:@
"[\u201c\u201d]" withString:@"\""];

And violla! This will turn “ (\u201c) and ” (\u201d) in 'file.txt' into a
plain " (ascii 0x22), the result of which is fileString.

There's other methods available as well if you just need to find the
locations of the curly quotes and what not.  Well documented, and the
documentation is available in .docset format so it's integrated and
available inside Xcode, just like all the other documentation.
___

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

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

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

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


App icon

2009-04-01 Thread fawad shafi

Dear All,
i m developing one application, my requirement is that when the user opens the 
application first time in simulator, i want to display 1.icn file as an app 
icn, and if not the first time. then i wana display 2.icn.
is it possible?

Regards,
Fawad Shafi



_
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009___

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

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

Help/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 know when a UISwitch is being touched

2009-04-01 Thread Joan Lluch-Zorrilla
Using isOn gives you whether the switch is on of off. I'm not sure if  
this is what you are looking for. In my case I wanted to know whether  
the user is manipulating (touching) the switch, regardless of its  
state. I found a way to do it. The code is as follows:


Add this upon creation of the switch.

 [theSwitch addTarget:self action:@selector(controlTouched:forEvent:)  
forControlEvents:UIControlEventAllTouchEvents] ;


Add the following to the class referred by self in the above sentence.

- (void)controlTouched:(UIControl *)sender forEvent:(UIEvent*)event
   {
UITouch *touch = [[event allTouches] anyObject] ;
BOOL tag ;
if ( touch == nil ) tag = NO ;
else
   {
UITouchPhase phase = [touch phase] ;
tag = (phase != UITouchPhaseEnded && phase !=  
UITouchPhaseCancelled) ;

   }
[sender setTag:tag] ;
   }

Now you have 1 in the tag property if the switch is being touched, or  
0 otherwise.


Hope that helps.

Joan Lluch-Zorrilla


El 01/04/2009, a las 16:03, Brian Slick escribió:

We may be able to combine forces here.  What I was doing gets the  
correct answer from the switch, but what I was finding is that  
certain circumstances do not result in a message being sent from the  
switch.  I forget just now which circumstance it was, but I believe  
it was a direct tap on the "button" of the switch.  Swiping the  
switch worked fine, tapping on the text of the switch worked fine,  
but tapping on the button did not send a message.  I finally just  
punted and asked each switch for their current status in  
viewWillDisappear, but this means I cannot react to changes while  
the user is still in the view.


So, if you use your method, but change it to [sender isOn], does  
that work?  I hope so, because that opens up some possibilities for  
me.


Brian

On Mar 31, 2009, at 9:22 AM, Joan Lluch-Zorrilla wrote:

I need to know whether the user is touching inside a UISwitch  
control. The UIControlEvent(s) do fire, but then isTouchInside  
always gives NO. My code is:


- (void)switchTouched:(UIControl *)sender
 {
  NSLog( @"switchtouched:%d", [sender isTouchInside]) ;
 }

The switchTouched method was added as a target to touch events upon  
creation of the switch like this


[switchv addTarget:self action:@selector(switchTouched:)  
forControlEvents:UIControlEventAllTouchEvents] ;


Whatever the user does on the switch the result is always Zero.  
What am I missing?


Joan Lluch-Zorrilla










___

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

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

Help/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 detect curly quotes

2009-04-01 Thread Dave DeLong
Just to chime in  The RegexKit linked below is absolutely  
FANTASTIC.  I use it pretty much any time I need to do beyond-basic  
text manipulation.  RegexKitLite is some NSString categories, allowing  
you to do things like [myString isMatchedByRegex:@"some regex"] and so  
on.  It's incredibly useful.


Dave

On Mar 31, 2009, at 5:55 PM, John Engelhart wrote:


You can use regular expressions.  RegexKitLite @
http://regexkit.sourceforge.net/RegexKitLite/ which you can download  
at

http://downloads.sourceforge.net/regexkit/RegexKitLite-2.2.tar.bz2

For example, you can be extremely lazy and do something along the  
lines of:


NSStringEncoding fileEncoding;
NSString *fileString = [[NSString stringWithContentsOfFile:@"file.txt"
usedEncoding:&fileEncoding error:NULL]  
stringByReplacingOccurrencesOfRegex:@

"[\u201c\u201d]" withString:@"\""];

And violla! This will turn “ (\u201c) and ” (\u201d) in 'file.txt'  
into a

plain " (ascii 0x22), the result of which is fileString.

There's other methods available as well if you just need to find the
locations of the curly quotes and what not.  Well documented, and the
documentation is available in .docset format so it's integrated and
available inside Xcode, just like all the other documentation.
___

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

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

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

This email sent to davedel...@me.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: App icon

2009-04-01 Thread Dave DeLong
Not without hacking something, no.  The bundle directory is write- 
protected, which means you can't alter Info.plist (which is where the  
icon is specified).


Dave

On Apr 1, 2009, at 9:44 AM, fawad shafi wrote:



Dear All,
i m developing one application, my requirement is that when the user  
opens the application first time in simulator, i want to display  
1.icn file as an app icn, and if not the first time. then i wana  
display 2.icn.

is it possible?

Regards,
Fawad Shafi



_
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009___

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

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

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

This email sent to davedel...@me.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: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-01 Thread WT
Indeed. I actually already knew that - 
performSelector:withObject:afterDelay: executes in the caller's thread  
but, in n my haste to throw together a quick test, succumbed to my  
thread-safety obsession (thanks to years of Java programming). No  
harm, though.


I ended up doing something sligthly different. I collect all the  
subviews-to-be in an array, then repeatedly fire a timer that grabs  
one view and adds it as a subview to the superview in question.


The issue remains, though, whether this is the right/best approach.  
I'm still open to alternative ways and suggestions, if someone would  
like to jump in.


( For a refresher on the original question, here's the archive link to  
it:


http://lists.apple.com/archives/cocoa-dev/2009/Mar/msg02058.html )

As always, I'm grateful for any responses.

Wagner

On Apr 1, 2009, at 6:59 PM, James Montgomerie wrote:


This is not doing exactly what you think it is.

You are certainly right that UIKit calls should /always/ be made  
from the main thread, but the  
"performSelector:withObject:AfterDelay" method actually performs the  
selector on the same thread that you call it from, not a separate  
thread.  This means that - presuming viewDidLoad: is getting called  
on the main thread, which it is if it's the system that's calling it  
- your "addViewInSeparateThread:" is in fact getting called on the  
main thread.


You could not have the addViewInSeparateThread: method at-all, and  
just call performSelector:withObject:AfterDelay with your   
@selector(addViewInMainThread:) selector, and it would have the same  
effect.


Jamie.

On 31 Mar 2009, at 17:20, WT wrote:


Hello again,

in anticipation that the answer to my question might be to add  
UIImageViews as subviews rather than to draw UIImages from within  
the superview's drawRect:, I tried the following little test, which  
works like a charm. The question remains, though, whether this is  
the right/best approach.


Wagner

The following code goes in the view controller managing the view  
where the images should be drawn into. It adds 25 image views to  
the view managed by the view controller, as a 5 x 5 grid, with a  
separation of 40 pixels between images. The grid rectangle has an  
origin at x = 30, y = 50. The time delay between images is 0.1  
second, for a total animation time of 2.5 seconds.


- (void) viewDidLoad
{
  for (int i = 0; i < 5; ++i)
  {
  CGFloat x = 40*i + 30;
  for (int j = 0; j < 5; ++j)
  {
  CGFloat y = 40*j + 50;

  UIImageView* imgView = [[UIImageView alloc]
  initWithImage: [UIImage imageNamed: @"img.png"]];

  CGRect frame = imgView.frame;
  frame.origin.x = x - frame.size.width / 2.0;
  frame.origin.y = y - frame.size.height / 2.0;
  imgView.frame = frame;

  [self performSelector: @selector(addViewInSeparateThread:)
 withObject: imgView
 afterDelay: (5*j + i) / 10.0];

  [imgView release];
  }
  }
}

- (void) addViewInSeparateThread: (UIView*) imgView
{
  [self performSelectorOnMainThread: @selector(addViewInMainThread:)
 withObject: imgView
 waitUntilDone: YES];
}

- (void) addViewInMainThread: (UIView*) imgView
{
  [self.view addSubview: imgView];
}

___

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

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

Help/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 know when a UISwitch is being touched

2009-04-01 Thread Brian Slick
For my case, I just needed to know when the value changed.  So I  
adapted what you came up with to look like this:
[switchView addTarget:self action:@selector(switchTouched:)  
forControlEvents:UIControlEventValueChanged];


UIControlEventAllTouchEvents was sending 3 messages to switchTouched:  
each time the switch was touched - I'm guessing touch down, touch up,  
value changed - but the state wasn't correct until the second or  
sometimes third message.  So I tried ValueChanged, and only got a  
single message with the correct state.  Right now I only have a single  
switch that I'm handling this way, but when I add more, I can sort  
them out by tag to respond accordingly in switchTouched.


Thanks for the help!  I'm new to target/action, but it sure is handy.

Brian

On Apr 1, 2009, at 3:56 PM, Joan Lluch-Zorrilla wrote:

Using isOn gives you whether the switch is on of off. I'm not sure  
if this is what you are looking for. In my case I wanted to know  
whether the user is manipulating (touching) the switch, regardless  
of its state. I found a way to do it. The code is as follows:


Add this upon creation of the switch.

[theSwitch addTarget:self action:@selector(controlTouched:forEvent:)  
forControlEvents:UIControlEventAllTouchEvents] ;


Add the following to the class referred by self in the above sentence.

- (void)controlTouched:(UIControl *)sender forEvent:(UIEvent*)event
  {
   UITouch *touch = [[event allTouches] anyObject] ;
   BOOL tag ;
   if ( touch == nil ) tag = NO ;
   else
  {
   UITouchPhase phase = [touch phase] ;
   tag = (phase != UITouchPhaseEnded && phase !=  
UITouchPhaseCancelled) ;

  }
   [sender setTag:tag] ;
  }

Now you have 1 in the tag property if the switch is being touched,  
or 0 otherwise.


Hope that helps.

Joan Lluch-Zorrilla


El 01/04/2009, a las 16:03, Brian Slick escribió:

We may be able to combine forces here.  What I was doing gets the  
correct answer from the switch, but what I was finding is that  
certain circumstances do not result in a message being sent from  
the switch.  I forget just now which circumstance it was, but I  
believe it was a direct tap on the "button" of the switch.  Swiping  
the switch worked fine, tapping on the text of the switch worked  
fine, but tapping on the button did not send a message.  I finally  
just punted and asked each switch for their current status in  
viewWillDisappear, but this means I cannot react to changes while  
the user is still in the view.


So, if you use your method, but change it to [sender isOn], does  
that work?  I hope so, because that opens up some possibilities for  
me.


Brian

On Mar 31, 2009, at 9:22 AM, Joan Lluch-Zorrilla wrote:

I need to know whether the user is touching inside a UISwitch  
control. The UIControlEvent(s) do fire, but then isTouchInside  
always gives NO. My code is:


- (void)switchTouched:(UIControl *)sender
{
 NSLog( @"switchtouched:%d", [sender isTouchInside]) ;
}

The switchTouched method was added as a target to touch events  
upon creation of the switch like this


[switchv addTarget:self action:@selector(switchTouched:)  
forControlEvents:UIControlEventAllTouchEvents] ;


Whatever the user does on the switch the result is always Zero.  
What am I missing?


Joan Lluch-Zorrilla










___

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

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

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

This email sent to briansl...@mac.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: App icon

2009-04-01 Thread Kiel Gillard

NSApplication provides the instance method setApplicationIconImage:

At startup (say, the applicationDidFinishLaunching: method) you could  
determine what icon you need to display and set it, using the above  
method, to the appropriate icns file from your bundle.


Note that this will not permanently modify the icon, it only modifies  
the icon image used for one session of your application.


Kiel

On 02/04/2009, at 2:44 AM, fawad shafi wrote:



Dear All,
i m developing one application, my requirement is that when the user  
opens the application first time in simulator, i want to display  
1.icn file as an app icn, and if not the first time. then i wana  
display 2.icn.

is it possible?

Regards,
Fawad Shafi



_
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/kiel.gillard%40gmail.com

This email sent to kiel.gill...@gmail.com


___

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

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

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

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


Re: App icon

2009-04-01 Thread Dave DeLong
Given that he mentioned running it in the simulator, I was guessing  
that he was asking about an iPhone application (upon which assumption  
I based my answer).


Dave

On Apr 1, 2009, at 6:24 PM, Kiel Gillard wrote:


NSApplication provides the instance method setApplicationIconImage:

At startup (say, the applicationDidFinishLaunching: method) you  
could determine what icon you need to display and set it, using the  
above method, to the appropriate icns file from your bundle.


Note that this will not permanently modify the icon, it only  
modifies the icon image used for one session of your application.


Kiel

___

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

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

Help/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 animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-01 Thread WT
Indeed. I actually already knew that - 
performSelector:withObject:afterDelay: executes in the caller's thread  
but, in n my haste to throw together a quick test, succumbed to my  
thread-safety obsession (thanks to years of Java programming). No  
harm, though.


I ended up doing something sligthly different. I collect all the  
subviews-to-be in an array, then repeatedly fire a timer that grabs  
one view and adds it as a subview to the superview in question.


The issue remains, though, whether this is the right/best approach.  
I'm still open to alternative ways and suggestions, if someone would  
like to jump in.


( For a refresher on the original question, here's the archive link to  
it:


http://lists.apple.com/archives/cocoa-dev/2009/Mar/msg02058.html )

As always, I'm grateful for any responses.

Wagner

On Apr 1, 2009, at 6:59 PM, James Montgomerie wrote:


This is not doing exactly what you think it is.

You are certainly right that UIKit calls should /always/ be made  
from the main thread, but the  
"performSelector:withObject:AfterDelay" method actually performs the  
selector on the same thread that you call it from, not a separate  
thread.  This means that - presuming viewDidLoad: is getting called  
on the main thread, which it is if it's the system that's calling it  
- your "addViewInSeparateThread:" is in fact getting called on the  
main thread.


You could not have the addViewInSeparateThread: method at-all, and  
just call performSelector:withObject:AfterDelay with your   
@selector(addViewInMainThread:) selector, and it would have the same  
effect.


Jamie.

On 31 Mar 2009, at 17:20, WT wrote:


Hello again,

in anticipation that the answer to my question might be to add  
UIImageViews as subviews rather than to draw UIImages from within  
the superview's drawRect:, I tried the following little test, which  
works like a charm. The question remains, though, whether this is  
the right/best approach.


Wagner

The following code goes in the view controller managing the view  
where the images should be drawn into. It adds 25 image views to  
the view managed by the view controller, as a 5 x 5 grid, with a  
separation of 40 pixels between images. The grid rectangle has an  
origin at x = 30, y = 50. The time delay between images is 0.1  
second, for a total animation time of 2.5 seconds.


- (void) viewDidLoad
{
 for (int i = 0; i < 5; ++i)
 {
 CGFloat x = 40*i + 30;
 for (int j = 0; j < 5; ++j)
 {
 CGFloat y = 40*j + 50;

 UIImageView* imgView = [[UIImageView alloc]
 initWithImage: [UIImage imageNamed: @"img.png"]];

 CGRect frame = imgView.frame;
 frame.origin.x = x - frame.size.width / 2.0;
 frame.origin.y = y - frame.size.height / 2.0;
 imgView.frame = frame;

 [self performSelector: @selector(addViewInSeparateThread:)
withObject: imgView
afterDelay: (5*j + i) / 10.0];

 [imgView release];
 }
 }
}

- (void) addViewInSeparateThread: (UIView*) imgView
{
 [self performSelectorOnMainThread: @selector(addViewInMainThread:)
withObject: imgView
waitUntilDone: YES];
}

- (void) addViewInMainThread: (UIView*) imgView
{
 [self.view addSubview: imgView];
}

___

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

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

Help/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: App icon

2009-04-01 Thread Kiel Gillard
That's ok, his original question said "first time in simulator" so I  
figured his app had some sort of simulator mode for its first launch.


Kiel

On 02/04/2009, at 11:26 AM, Dave DeLong wrote:

Given that he mentioned running it in the simulator, I was guessing  
that he was asking about an iPhone application (upon which  
assumption I based my answer).


Dave

On Apr 1, 2009, at 6:24 PM, Kiel Gillard wrote:


NSApplication provides the instance method setApplicationIconImage:

At startup (say, the applicationDidFinishLaunching: method) you  
could determine what icon you need to display and set it, using the  
above method, to the appropriate icns file from your bundle.


Note that this will not permanently modify the icon, it only  
modifies the icon image used for one session of your application.


Kiel

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/kiel.gillard%40gmail.com

This email sent to kiel.gill...@gmail.com


___

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

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

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

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


Re: Looking for [NSNumber numberWithString:]

2009-04-01 Thread Bryan Henry
There is no -numberWithString:, no. You'd need to do something like  
[NSNumber numberWithDouble:[someStr doubleValue]].


- Bryan

On Apr 1, 2009, at 9:17 PM, Greg Robertson wrote:


I would like to convert an NSString to an NSNumber. Is there a direct
method for this or should I go NSString to double and then double to
NSNumber?

Thanks

Greg
___

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

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

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

This email sent to bryanhe...@mac.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: Looking for [NSNumber numberWithString:]

2009-04-01 Thread Kiel Gillard

As far as I know, this is the simplest way:
NSNumber *number = [NSNumber numberWithDouble:[@"3.14159" doubleValue]];

Kiel

On 02/04/2009, at 12:17 PM, Greg Robertson wrote:


I would like to convert an NSString to an NSNumber. Is there a direct
method for this or should I go NSString to double and then double to
NSNumber?

Thanks

Greg
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/kiel.gillard%40gmail.com

This email sent to kiel.gill...@gmail.com


___

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

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

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

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


Looking for [NSNumber numberWithString:]

2009-04-01 Thread Greg Robertson
I would like to convert an NSString to an NSNumber. Is there a direct
method for this or should I go NSString to double and then double to
NSNumber?

Thanks

Greg
___

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

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

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

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


NSPopUpButton pullsDown:YES and dummy first item - normal?

2009-04-01 Thread Rua Haszard Morris
I am using a pull-down NSPopUpButton for a little button which  
displays a little menu. The menu has some commands in it, i.e. it's  
not a selection menu, the title of the button just displays an icon,  
no title, no indication of a current item from the menu. I am calling  
(ahem, sending) setUsesItemFromMenu:NO on (to) the cell.


It appears that with pull-down menus I need to insert a dummy item at  
index zero as my NSPopUpButton as a placeholder, and that  
NSPopUpButton/Cell (when in pull-down mode) will handily ignore this  
item.


This seems like a weird hack, and makes me think I'm going about this  
the wrong way - is this a normal approach?


The documentation mentions that the index of the first item in a pull- 
down should be 1, but it doesn't explain that you need to add a dummy  
item (for the zeroth) or else your first item will go missing.


thanks
Rua HM.
___

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

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

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

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


Obj-C equivalent to Python generator functions

2009-04-01 Thread Sam Krishna
Does anyone here know of any Obj-C functional equivalent to Python  
generator functions? These are *categorically* different that the  
Spotlight API generator functions.


Here's a link in case you're not familiar with them:

http://is.gd/qcYt

Any ideas?

Live Playfully,

Sam
-
If he listens in faith,
finding no fault, a man is free
and will attain the cherished words
of those who act in virtue.

___

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

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

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

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


Seeking advice on best practice for managing visibility of many subviews

2009-04-01 Thread Stuart Malin
I have a view that has hundreds of subviews. The user can control  
filters which causes different of the subviews to be presented; the  
collection of selected-for-presentation subviews are repositioned in  
the super view. I can think of two ways to handle this, and am not  
sure which is best:
1) remove and add subviews from the super view each time the filter  
criteria changes, or
2) leave all views in the super view, and just use -setHidden: to  
control whether presented or not.
If the second approach is a better practice, does it matter where the  
hidden views are positioned?

TIA.
___

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

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

Help/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: Obj-C equivalent to Python generator functions

2009-04-01 Thread Andrew Farmer

On 01 Apr 09, at 19:04, Sam Krishna wrote:
Does anyone here know of any Obj-C functional equivalent to Python  
generator functions? These are *categorically* different that the  
Spotlight API generator functions.


Depends on what you're after. If all you need is to be able to iterate  
over an object, you can implement fast enumeration:


http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocFastEnumeration.html

If you actually want the continuation behavior of generators, though,  
there's no way to get that in C (or ObjC, or C++) at the moment  
without massive, horrifying hacks.

___

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

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

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

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


Re: Cocoa Access to iPhone info

2009-04-01 Thread Andrew Farmer

On 01 Apr 09, at 15:58, Jeff Laing wrote:
My boss has just discovered the iPhone Field Test mode (described  
here:

http://www.wirelessinfo.com/content/inside-the-iphone-field-test-mode.ht
m) and was wondering whether there is a mechanism for a regular Cocoa
app to get at that Cell information.

I'm guessing the answer is no, but I figured I might as well ask.
Failing Cocoa, is that info available via some sort of sysctl() or
ioctl() interface ?


If it's not documented in the SDK - which it probably isn't - it's off- 
limits.

___

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

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

Help/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: disable row highlighting NSTableView

2009-04-01 Thread Jo Phils
Thank you very much I will do my homework...

Sincerely,

Rick






From: I. Savant 
To: Jo Phils 
Cc: Jens Miltner ; Cocoa List 
Sent: Thursday, April 2, 2009 12:02:29 AM
Subject: Re: disable row highlighting NSTableView

On Wed, Apr 1, 2009 at 11:54 AM, Jo Phils  wrote:
> Thank you for your reply and my apologies for asking what had been answered a 
> few days ago. :-)  It does lead me to another question though...I'm still a 
> beginner and I have never overridden a method via subclassing before.  Is 
> there a tutorial you might be able to point me to that could show me how to 
> do this?

  Have you tried reading the documentation?

The Objective-C 2.0 Programming Language
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html

Specifically:

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocObjectsClasses.html#//apple_ref/doc/uid/TP30001163-CH11-TPXREF111

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


Toll-free bridge type at runtime

2009-04-01 Thread Ryan Joseph
I'm trying to determine at runtime if a type is CoreFoundation or  
Cocoa, for example NSArray/CFArray. I must use Carbon API however to  
determine this before I attempt to use Cocoa methods for introspection.


My first test was to use CFGetTypeID and CFCopyTypeIDDescription but  
they both returned CFArray on both Cocoa and CoreFoundation types.  
Maybe some of the Objective-C runtime functions could be used? But I'm  
not sure if they will crash taking CoreFoundation types for the  
purpose of testing. Are there any other clever ways to get this  
information? Thanks for helping.


Regards,
Josef

___

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

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

Help/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: Toll-free bridge type at runtime

2009-04-01 Thread Michael Ash
On Thu, Apr 2, 2009 at 12:33 AM, Ryan Joseph
 wrote:
> I'm trying to determine at runtime if a type is CoreFoundation or Cocoa, for
> example NSArray/CFArray. I must use Carbon API however to determine this
> before I attempt to use Cocoa methods for introspection.
>
> My first test was to use CFGetTypeID and CFCopyTypeIDDescription but they
> both returned CFArray on both Cocoa and CoreFoundation types. Maybe some of
> the Objective-C runtime functions could be used? But I'm not sure if they
> will crash taking CoreFoundation types for the purpose of testing. Are there
> any other clever ways to get this information? Thanks for helping.

The test cannot be performed, because the question does not make any sense.

Bridging doesn't mean that there are two types which interoperate.
Bridging means that there is one type, available under two names. It's
as though you have a friend named Bob, who sometimes also goes by
Bill. Now your question is, given a person, is this person Bob or is
it Bill? The answer is, both (or neither, if it's someone else).

An NSArray is a CFArray. A CFArray is an NSArray. You can't take one
of them and ask which one it is any more than you can ask your friend
whether he's Bob or Bill. They're just two names for the same thing.

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: NSPopUpButton pullsDown:YES and dummy first item - normal?

2009-04-01 Thread Michael Ash
On Wed, Apr 1, 2009 at 9:55 PM, Rua Haszard Morris
 wrote:
> I am using a pull-down NSPopUpButton for a little button which displays a
> little menu. The menu has some commands in it, i.e. it's not a selection
> menu, the title of the button just displays an icon, no title, no indication
> of a current item from the menu. I am calling (ahem, sending)
> setUsesItemFromMenu:NO on (to) the cell.
>
> It appears that with pull-down menus I need to insert a dummy item at index
> zero as my NSPopUpButton as a placeholder, and that NSPopUpButton/Cell (when
> in pull-down mode) will handily ignore this item.
>
> This seems like a weird hack, and makes me think I'm going about this the
> wrong way - is this a normal approach?
>
> The documentation mentions that the index of the first item in a pull-down
> should be 1, but it doesn't explain that you need to add a dummy item (for
> the zeroth) or else your first item will go missing.

Don't forget to check the conceptual docs:

http://developer.apple.com/documentation/Cocoa/Conceptual/MenuList/Articles/ManagingPopUpItems.html#//apple_ref/doc/uid/2274

Partway down it says:

"Note that in a pull-down list, the first item is stored at index 1,
not index 0 as is the case with pop-up lists or ordinary menus. This
is done so that the pull-down list’s title can be stored at index 0 if
necessary. Even when the title is stored at index 0, always change the
buttons title with the setTitle: method."

So yes, this is the typical way to do things.

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: Bindings and MenuItems

2009-04-01 Thread Ben Lachman

On Apr 1, 2009, at 5:01 PM, Keary Suska wrote:


On Apr 1, 2009, at 12:31 PM, Ben Lachman wrote:

I mean a "Cocoa bindings" kind of binding.  e.g. the "target"  
binding of the menu item is bound in IB.  The action field of the  
binding is set to "print:".  I'm not talking about the traditional  
way of connecting a button/menu item to another object through the  
basic control drag from source to target and select the action  
method and I'm not talking about setting it in code.  I know how to  
do both of those and they work, what I'm going for is a dynamic  
target.



I think I wasn't recalling correctly--my issue had to do with an  
NSButton, and binding didn't work for me. There is no reason to  
suspect that the binding wouldn't work as advertised.


Anyway, I suppose you have verified that the correct object is being  
set when the binding is established (and/or when the bound property  
changes)?


Yeah, I ended up reverting to just setting the target of the menu item  
in code when certain notifications happened (NSWindowDidBecomeKey and  
NSOutlineViewSelectionDidChange).  This works, but isn't quite as  
simple as a bindings based solution should have been. Planning to file  
a bug on this.


Thanks for the thoughts.

->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



___

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

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

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

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


How to download images for a contact in Cocoa?

2009-04-01 Thread albert jordan Mobility


I'm trying to implement code that downloads contact image from the  
net.  I thought the following would do...



NSString* mapURL = [currentStringValue   
stringByReplacingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL  
URLWithString:mapURL]];

BOOL success = [currentPerson setImageData: imageData];


but I don't think this is right.  It seems I need to initiate a  
download process, and need to do something with  
"beginLoadingImageDataForClient: ".  But I can't find any good  
documentation on the method.   can some please point me in the right  
direction?


Thanks

Albert
___

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

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

Help/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: Seeking advice on best practice for managing visibility of many subviews

2009-04-01 Thread WT
From the perspective of efficiency, I speculate that hiding/showing  
views would be a better approach, given that adding/removing subviews  
has to traverse and manipulate the view hierarchy, which could be  
potentially an expensive proposition (unless all the subviews are  
siblings of one superview and the hierarchy is very shallow). Only  
profiling the application can really tell for sure, however.


As far as your last question, the documentation for NSView and UIView  
states that hidden subviews still participate in the view hierarchy  
and contribute to autoresizing when the visible subviews are moved or  
resized, though they do not respond to events and aren't visible.


On Apr 2, 2009, at 4:47 AM, Stuart Malin wrote:

I have a view that has hundreds of subviews. The user can control  
filters which causes different of the subviews to be presented; the  
collection of selected-for-presentation subviews are repositioned in  
the super view. I can think of two ways to handle this, and am not  
sure which is best:
1) remove and add subviews from the super view each time the filter  
criteria changes, or
2) leave all views in the super view, and just use -setHidden: to  
control whether presented or not.
If the second approach is a better practice, does it matter where  
the hidden views are positioned?

TIA.
___

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

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

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

This email sent to jrca...@gmail.com


___

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

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

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

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


UITableView "port" to Mac?

2009-04-01 Thread Seth Pellegrino

Hello list,

I'm looking for something similar to UITableView for Mac development.  
NSCollectionView seems a little like what I'd want, but the API on  
UITableView is much cleaner and easier to use (and I'm only really  
interested in a single column rather than a grid). I've also looked at  
stepwise's method for using views as rows in a NSTableView, but it  
seems like it would be much cleaner to start from scratch.


Toward this end, I was wondering if anyone had seen/built such a  
class, or (alternately) can tell me why such a class would be a very  
bad idea. I've done some searching through both Google and the  
archives, and haven't been able to find any previous posts on this  
topic, but my apologies if it's come up before and I missed it.


Thanks,

Seth Pellegrino
___

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

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

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

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