Reading image from system clipboard

2009-08-03 Thread Deepa

Hi,

I am developing an desktop app for which I want to implement a  
behavior which is similar to 'New from clipboard' of Preview  
application.


I tried using NSPasteboard:

// To get file copied to clipboard from Finder
NSArray *files = [[NSPasteboard generalPasteboard]  
propertyListForType: NSFilenamesPboardType];


This returns array of files copied to the clipboard

// To get tiff image
NSData *pbData = [[NSPasteboard generalPasteboard] dataForType:  
NSTIFFPboardType];

CIImage *pbImg = [CIImage imageWithData: pbData];

But this doesn't return null (tiff image data was copied to the  
clipboard).


Am I doing something wrong here???

Can someone help me out to sove this problem. I also wanted to know a  
method which copies and reads jpeg/gif/png image formats to/from  
system clipboard.


Thanks in advance.


Thanks and Regards,
Deepa
de...@robosoftin.com




---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.
___

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

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

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

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


Re: Design pattern for per-document settings

2009-08-03 Thread Negm-Awad Amin


Am Mo,03.08.2009 um 02:18 schrieb Graham Cox:


Hi all,

I'm just thinking through a couple of problems and wondered if  
anyone had anything to say about it...


In my app I have several things that apply on a per document  
level, for example, the mapping from Quartz co-ordinate values to  
some other measurement system, such as millimetres. Different  
documents might have different mappings. Other parts of my interface  
will want to work with these settings, for example text fields that  
set geometric properties such as line width. Many of these text  
fields live in floating palettes that respond to different document  
windows becoming main, etc.


So what I'm thinking is that I can write a custom formatter attached  
to the text fields that can pick up the current main document's co- 
ordinate mappings. I'm just not sure what the most efficient and  
most straightforward implementation might look like.


I could get every formatter instance to subscribe to certain  
notifications, but that requires a lot of code to set up and tear  
down as nibs are loaded, etc. Alternatively, I could give the  
formatter some class methods that centralise the notification  
handling and also keep track of all the individual instances.  
Trouble with that is that class methods are global, rather than per  
document, though since most (but not all) of the formatters are  
also global in the sense that they are in context sensitive  
palettes, that is favourite at the moment.


Or maybe formatters are not a sensible way to deal with this at all?  
Is there a better design pattern I'm overlooking?


--Graham


Never tried, but should work:
1. Make a subclass
2. add a property that holds the information
3. add a binding for that property
4. bind the property through the application to get the active  
dorument



___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to negm-a...@cocoading.de


Amin Negm-Awad
negm-a...@cocoading.de




___

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

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

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

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


text control for keyboard shortcut input?

2009-08-03 Thread aaron smith
Does anyone know of any prebuilt views for something like this:
http://tinyurl.com/mggdtd - I've been snooping around google for a
while but can't seem to get the right keywords to bring anything up.
Any ideas? Thanks much!
___

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

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

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

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


Re: Design Paterns: +/- Initializers and Subclassing (Solved)

2009-08-03 Thread Christopher J Kemsley
Oh yeah - I thought I did that once and it didn't work... Though, now  
that I think about it, I think I did it the other way in the past   
(used self in a +method to refer to a newly created object)


So, in all reality, the +method could be boiled down to:

[self.new autorelease] ;

since

self.new  =  MyClass.new  =  [MyClass new]  =  [ [self alloc] init ]

Thanks for clearing that up!



On Aug 2, 2009, at 10:34 PM, Quincey Morris wrote:


On Aug 2, 2009, at 22:26, Quincey Morris wrote:


return [ [ [[self class] alloc] init ] autorelease ] ;

('self' refers to the class object because this is a class method)


Doh, if that's true, then:

return [ [ [self alloc] init ] autorelease ] ;

should be good enough. (IIRC, [self class] == self when self is a  
class, but I always confuse myself with the class versions of  
methods, sorry.)



___

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

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

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

This email sent to kd7...@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: Design Paterns: +/- Initializers and Subclassing (Solved)

2009-08-03 Thread Kyle Sluder
On Aug 3, 2009, at 1:13 AM, Christopher J Kemsley kd7...@gmail.com  
wrote:



So, in all reality, the +method could be boiled down to:

[self.new autorelease] ;


This is improper use of the dot syntax. new is not a property, so it  
should not be accessed using the dot syntax.


--Kyle Sluder
___

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

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

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

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


Re: From NSTextView to address an NSTextField

2009-08-03 Thread Alastair Houghton

On 2 Aug 2009, at 21:48, Steve Cronin wrote:


Folks;

NSTextView - NSText - NSView - NSReponder - NSObject

NSTextField - NSView - NSReponder - NSObject

At runtime if I have access to an instance of NSTextView how can I  
address the NSTextField?

I know I should know this but I having a 'moment'...


In addition to what Kyle said, the confusion probably arises because  
NSTextField uses the field editor, so it is possible to receive  
notifications relating to the field editor in which case you might not  
know which text field it was about.


Usually this means you're watching the wrong notification.  The  
inheritance diagram for NSTextField above is wrong; it should look  
like this:


  NSTextField - NSControl - NSView - NSResponder - NSObject

and the important part here is NSControl.  NSControl sends a number of  
notifications that mirror those sent by NSText(View), and if you're  
finding that you're getting a notification that doesn't tell you which  
NSTextField (or other editable control) you're dealing with, it's  
probably just that you're somehow listening to the NSText(View)  
notifications rather than the NSControl ones.


Kind regards,

Alastair.

--
http://alastairs-place.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


[IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Alexander Bokovikov

Hi, All,

It's my first attempt to assign a popup menu to a view, so perhaps my  
question is stupid, but I can't find an explanation in the Apple's  
docs... The Key Equiv. field is grayed, and don't see any obvious  
solution to activate it. I've created a menu, associated it with a  
view, associated a menu item with action, but this field is still gray.


Where is the problem?

Thanks.
 
___


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

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

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

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


Re: Reading image from system clipboard

2009-08-03 Thread Graham Cox


On 03/08/2009, at 4:07 PM, Deepa wrote:

I am developing an desktop app for which I want to implement a  
behavior which is similar to 'New from clipboard' of Preview  
application.


I tried using NSPasteboard:

// To get file copied to clipboard from Finder
NSArray *files = [[NSPasteboard generalPasteboard]  
propertyListForType: NSFilenamesPboardType];


This returns array of files copied to the clipboard

// To get tiff image
NSData *pbData = [[NSPasteboard generalPasteboard] dataForType:  
NSTIFFPboardType];

CIImage *pbImg = [CIImage imageWithData: pbData];

But this doesn't return null (tiff image data was copied to the  
clipboard).


Am I doing something wrong here???

Can someone help me out to sove this problem. I also wanted to know  
a method which copies and reads jpeg/gif/png image formats to/from  
system clipboard.



It's not clear what the problem is.

Do you want image data or not? Preview's 'New from clipboard' is  
looking for image data.


Normally when you read a pasteboard, you should pass it a list of  
types using -availableTypeFromArray:, where the array you give it  
indicates your *preferred order*. The type returned is the first  
matching type found, so if you prefer image data over file data, you  
list the image type first. It is up to the receiving application to  
set the preferred order, not the sending application, which has no  
idea who might make use of which copied data.


So if you want to read an image, you might prefer the order PDF, TIFF,  
File... then deal appropriately with whichever one you get back.


--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: text control for keyboard shortcut input?

2009-08-03 Thread I. Savant

On Aug 3, 2009, at 4:07 AM, aaron smith wrote:


Does anyone know of any prebuilt views for something like this:
http://tinyurl.com/mggdtd - I've been snooping around google for a
while but can't seem to get the right keywords to bring anything up.
Any ideas? Thanks much!


  I believe this is what you're looking for:

Shortcut Recorder
http://code.google.com/p/shortcutrecorder/

  The project contains more than the control - it contains some good  
code for managing shortcuts (including global).


--
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: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Graham Cox


On 03/08/2009, at 9:38 PM, Alexander Bokovikov wrote:

OK, nothing to do here, but notice, that Dad Bill (unlike to Dad  
Steve) :) uses another approach - a view, having keyboard focus,  
automatically activates its popup menu shortcuts, so it's easy to  
work with a view as by mouse, as by keyboard. The main menu, of  
course, can contain all shortcuts. And it will be pretty enough for  
a simple application interface. Nevertheless, the inability of  
having popup menus shortcuts in an application, having a complex UI,  
may cause the need of very complex or (sooner) dynamic main menu  
creation. Of course, it's not my case.


Another reason, why shortcuts would be useful in popup menu, is just  
yet another possibility to show them to user.



You can do this if you want - but you have to do it all yourself,  
including matching the keyboard to the menu item and invoking it.


The reason it's not supported by default is that a view might not be  
the final target for a contextual menu - the view may have many  
objects any of which could be the menu's target - only the click  
location can tell you which one, so your code might have to deal with  
that possibility also. If the view is the final unambiguous target,  
it's easy, but that isn't always the case.


--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: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Alexander Bokovikov


On 03.08.2009, at 17:45, Graham Cox wrote:

the view may have many objects any of which could be the menu's  
target - only the click location can tell you which one,


Can't agree. If we setup a control, as capable to have keyboard focus,  
then, activating this control, we activate all hierarchy of its  
parents, and we definitely can apply the lowest level parent's popup  
menu (if any) with its shortcuts.  Of course, we can't do it, if we  
have no focusable controls, so we can work by mouse only in this case.  
But in this case we even can't speak about keyboard shortcuts. In any  
other cases we can.


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


NSPathControl - popup panel doesn't work

2009-08-03 Thread Alexander Bokovikov

Hi, All,

I can't understand why, but target path is not changed when I click on  
NSPathControl's popup panel. The control shows the same path, as was  
chosen earlier. I can click Choose... item and NSOpenPanel will  
appear, where I can choose a new directory, and these changes will be  
saved. But none of other items in the popup panel work. Why? I don't  
see any options in the Inspector, which could help here. NSPathControl  
has style set to PopUp. Please help.


Thanks.
___

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

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

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

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


Re: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Graham Cox


On 03/08/2009, at 10:47 PM, Alexander Bokovikov wrote:

Can't agree. If we setup a control, as capable to have keyboard  
focus, then, activating this control, we activate all hierarchy of  
its parents, and we definitely can apply the lowest level parent's  
popup menu (if any) with its shortcuts.  Of course, we can't do it,  
if we have no focusable controls, so we can work by mouse only in  
this case. But in this case we even can't speak about keyboard  
shortcuts. In any other cases we can.



There's much more to life than controls. Many views have elements that  
are spatially distributed and would not be considered controls but  
actual content. It is often useful to apply contextual menus to those  
elements, but almost impossible to meaningfully navigate them using  
just the keyboard. For example, in the Finder an icon view where the  
icons are not regularly ordered and spaced - keyboard navigation is  
hard. In fact the Finder makes a reasonable stab at this for selecting  
but you still can't activate the selected object(s) contextual menus  
without the mouse.


But back to your question - feel free to implement it if you feel it  
does make sense in your app. But I bet you'll find that the cost/ 
benefit of doing so is simply not worth it - users will be very  
unlikely to discover the feature (as it's not widespread in other  
apps) and understand how to manage the focus in an obvious way to make  
good use of it. The presence of a shortcut in a menu is so that the  
user, having clicked it so many times, notices that there's a quicker  
way to do whatever it is. The expectation then is that the shortcut  
will simply perform the action. If the user has to tab through umpteen  
views and somehow manipulate the selection just to get access to the  
shortcut, it's not really much of a shortcut, is it?


--Graham


___

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

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

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

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


Adding more and more key/value observers is much too slow - workaround needed.

2009-08-03 Thread Andreas Känner

Hi,

If you add more and more key/value observers with  
addObserver:forKeyPath:options:context: this call takes longer and  
longer in a non-linear way.


I posted a bug report today (ID: 7112953) but maybe someone already  
has a workaround. Here is my sample code:


#include Foundation/Foundation.h

@interface ModelObject : NSObject
{
 NSString* title;
}
@property (readwrite, copy) NSString* title;
@end

@implementation ModelObject
@synthesize title;
@end

@interface Observer : NSObject
{}
@end

@implementation Observer
@end

void addObservers(NSUInteger count)
{
// Create model objects and observers:

	NSMutableArray* modelObjects	= [NSMutableArray  
arrayWithCapacity:count];

NSMutableArray* observers   = [NSMutableArray 
arrayWithCapacity:count];
for(NSUInteger i=0; icount; i++)
{
 [modelObjects addObject:[[ModelObject alloc] init]];
 [observersaddObject:[[Observer alloc] init]];
}

// Register observers:

NSDate* startDate = [NSDate date];
for(NSUInteger i=0; icount; i++)
{
ModelObject* modelObject = [modelObjects objectAtIndex:i];
Observer* observer   = [observersobjectAtIndex:i];
[modelObject addObserver:observer
  forKeyPath:@title
			 options:NSKeyValueObservingOptionNew |  
NSKeyValueObservingOptionOld

 context:observer];

}
	NSLog(@time to add %d observers: %f s, count, -[startDate  
timeIntervalSinceNow]);	

}



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

addObservers(10);
addObservers(100);
addObservers(1000);
addObservers(1);
[pool release];
}

In my test case an observer does always observe only one object and  
each observed object is only observed by one observer. I think this is  
a common use case.


I have results for Snow Leopard too, but I think I'm not allowed to  
post them on this mailing list. Here are the results for Leopard:


I tested this with different build settings (with/without GC and  
32/64bit)


Machine: iMac 2.4 GHz Intel Core 2 Duo

Leopard (10.5.7/9J61):

32Bit:

With GC:

time to add10 observers: 0.001008 s
time to add   100 observers: 0.001796 s
time to add  1000 observers: 0.174864 s
time to add 1 observers: 10.746330 s

Without GC:

time to add10 observers: 0.000920 s
time to add   100 observers: 0.000956 s
time to add  1000 observers: 0.056894 s
time to add 1 observers: 4.615175 s

64Bit:

With GC:

time to add10 observers: 0.001340 s
time to add   100 observers: 0.001533 s
time to add  1000 observers: 0.125700 s
time to add 1 observers: 7.545702 s

Without GC:

time to add10 observers: 0.001058 s
time to add   100 observers: 0.000831 s
time to add  1000 observers: 0.053189 s
time to add 1 observers: 4.006754 s

Notes:

If you know a workaround for this bottleneck please drop me an email.


___

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

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

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

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


Re: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Alastair Houghton

On 3 Aug 2009, at 12:45, Graham Cox wrote:

The reason it's not supported by default is that a view might not be  
the final target for a contextual menu - the view may have many  
objects any of which could be the menu's target


I think the reason (that it isn't supported) is much simpler than  
that.  The end user can't find the shortcuts because they're hidden  
away in a contextual menu that they might never see (particularly if  
they don't know about Control-click and have their mouse set to one- 
button mode).


If the options in question are useful enough to merit a keyboard  
shortcut, then they're useful enough to appear in the application's  
main menu hierarchy.  If not, then they aren't.


Kind regards,

Alastair.

--
http://alastairs-place.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: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Alexander Bokovikov


On 03.08.2009, at 19:00, Graham Cox wrote:


There's much more to life than controls.


Completely agree. But I don't like to say that _every_ popup menu  
_must_ have keyboard shortcuts. I'd just like to say, that it would be  
good to give such possibility to the coder.


But back to your question - feel free to implement it if you feel it  
does make sense in your app.


But it would be _not_ a _popup_menu_ shortcuts, but just a keyboard  
events handling by the view, if I understand it correctly. In any case  
we can close this discussion unless it will not transform itself into  
a pure flood... :)


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


Non-blocking custom event loop?

2009-08-03 Thread Daniel Furrer
I have my own event-loop where I call nextEventMatchingMask: repeatedly.
Many examples I found just pass a untilDate of [NSDate distantPast] to get
this behaviour as stated in the documentation but this doesn't seem to work
for me - even in a very simple setting.
Can anyone see what's wrong?

int main(int argc, char **args){
NSRect frame = NSMakeRect(100, 100, 500, 400);

NSApplication *application = [NSApplication sharedApplication];
NSWindow* window  = [[NSWindow alloc] initWithContentRect:frame

styleMask:NSBorderlessWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
backing:NSBackingStoreBuffered
defer:NO];


// Start the main event loop:
[application finishLaunching];
while(true) {
NSEvent *event;
while ( event =
[application
nextEventMatchingMask:NSAnyEventMask
untilDate: [NSDate distantPast] // nil
inMode:NSDefaultRunLoopMode
dequeue:YES] )
{
NSLog(@Event: %@, (id)event);
[application sendEvent:event];
[application updateWindows];
}
}

return 0;
}
___

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

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

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

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


Re: Table view data source methods order?

2009-08-03 Thread Chase Meadors
No, both delegate and data source are connected, and they are all  
getting called. This is why I believe the order is the problem.


On Aug 3, 2009, at 12:16 AM, Quincey Morris wrote:


On Aug 2, 2009, at 22:04, Chase Meadors wrote:

I'm having a bit of trouble here with table view data source  
methods. I have implemented. I have these three:


1) - (NSCell *)tableView:(NSTableView *)sender  
dataCellForTableColumn:(NSTableColumn *)tableColumn row: 
(NSInteger)row;
2) - (id)tableView:(NSTableView *)sender objectValueForTableColumn: 
(NSTableColumn *)tableColumn row:(NSInteger)row;
3) - (void)tableView:(NSTableView *)sender willDisplayCell:(id)cell  
forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex;


#1 and #3 are delegate methods, not data source methods. If the  
table view's delegate outlet isn't connected, or is connected to a  
different object, you'd expect to see something like the problem  
you're having.



___

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

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

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

This email sent to c.ed.m...@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: Table view data source methods order?

2009-08-03 Thread Andy Lee

On Aug 3, 2009, at 1:04 AM, Chase Meadors wrote:

I'm having a bit of trouble here with table view data source  
methods. I have implemented. I have these three:


1) - (NSCell *)tableView:(NSTableView *)sender  
dataCellForTableColumn:(NSTableColumn *)tableColumn row: 
(NSInteger)row;
2) - (id)tableView:(NSTableView *)sender objectValueForTableColumn: 
(NSTableColumn *)tableColumn row:(NSInteger)row;
3) - (void)tableView:(NSTableView *)sender willDisplayCell:(id)cell  
forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex;


I'm having trouble implementing what I want to implement. One column  
in my table view has some popup cells that have unique items to  
select from. In method 1) I'm returning a generic NSPopUpButtonCell  
if appropriate.


In method 2), I return an index based on a string in the list of  
values for that row.


In method 3), if the cell is one of my popups, I set it's menu to  
the list of values for that row.


Here's the problem. I'm returning the correct index for an object  
value in 2), but all of my popups have index 0 selected (with the  
correct list). The only reason I can think of is that cocoa follows  
this order:


1) call -objectValueFor...

2) THEN set the object value while the cell doesn't have it's list,

3) THEN call willDisplayCell...

Is there some way to implement this? They could simplify things by  
just giving direct access to the cell in the objectValueFor...  
method.'


If you put NSLogs at the beginning of each of the three methods, what  
order are they called in?


Is there any reason not to assign the menu in method 1)?

--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: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Alexander Bokovikov


On 03.08.2009, at 20:58, Alastair Houghton wrote:

If the options in question are useful enough to merit a keyboard  
shortcut, then they're useful enough to appear in the application's  
main menu hierarchy.  If not, then they aren't.


I'm sorry, but as I can see now, main menu shortcuts are also gray...  
I can delete them but I can't assign them. Why? I've created  
controller actions and have connected actions of menu items with the  
controller.


Thanks.
___

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

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

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

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


Re: Table view data source methods order?

2009-08-03 Thread Quincey Morris

On Aug 3, 2009, at 1:04 AM, Chase Meadors wrote:

I'm having a bit of trouble here with table view data source  
methods. I have implemented. I have these three:


1) - (NSCell *)tableView:(NSTableView *)sender  
dataCellForTableColumn:(NSTableColumn *)tableColumn row: 
(NSInteger)row;
2) - (id)tableView:(NSTableView *)sender objectValueForTableColumn: 
(NSTableColumn *)tableColumn row:(NSInteger)row;
3) - (void)tableView:(NSTableView *)sender willDisplayCell:(id)cell  
forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex;


I think you're making a mistake in expecting an order to be guaranteed  
amongst mixed data source and delegate methods. Whatever order you see  
now isn't guaranteed and could change in the future.


Your #2 is correctly implemented, so forget about it from the point of  
view of the delegate methods.


Since you only have one NSPopUpButtonCell, you don't need both #1 and  
#3. And since you apparently do need #1, you can get rid of #3, as  
Andy suggested.


Wherever you decide to set the menu for the current row, *that* method  
should also set the selected item index in the menu. Then it doesn't  
matter whether #2 is called before or after or at all. There's no  
reason for the delegate method to rely on the data source method to do  
its work for it.


You're not worrying about whether it's inefficient to recompute the  
selected menu item index, are you? If so, you can be sure a posse is  
going to be after you for premature optimization. :)



___

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

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

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

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


NSSound play often fails

2009-08-03 Thread James Walker
I'm having trouble getting sounds to play reliably.  When it happens, 
-[NSSound play] returns YES, but I hear nothing, and the 
sound:didFinishPlaying: delegate method is not called.  The sound in 
question is an AIFF file with a duration of about half a second.  It 
seems like whether it fails depends on how much other computation is 
going on after the play call, like maybe if it can't get enough CPU time 
right away, it gives up.



Here's my sound playing code.


@interface PlayDelegate : NSObject
- (id) init;
- (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)finishedPlaying;
@end

@implementation PlayDelegate

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

- (void)sound:(NSSound *)sound
didFinishPlaying:(BOOL)finishedPlaying
{
[sound setDelegate: nil];
[sound release];

#if LOG_PLAY
NSLog( @Finished sound play %s,
finishedPlaying? successfully : unsuccessfully );
#endif
}

@end

static PlayDelegate*sPlayDelegate = nil;


voidPlayNamedSound( CFStringRef inSoundName )
{
NSSound*theSound = [NSSound soundNamed: (NSString*) inSoundName 
];

if (theSound != nil)
{
[theSound retain];

if (sPlayDelegate == nil)
{
sPlayDelegate = [[PlayDelegate alloc] init];
}

[theSound setDelegate: sPlayDelegate];

BOOL startedPlay = [theSound play];

#if LOG_PLAY
NSLog( @Started sound play %s,
startedPlay? successfully : unsuccessfully );
#endif
}
else
{
NSLog(@Missing sound resource %...@., (NSString*) inSoundName 
);
}
}

--
  James W. Walker, Innoventive Software LLC
  http://www.frameforge3d.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


addSubview: and positioning at the bottom of a NSWindow

2009-08-03 Thread Stefano Pigozzi

Hello,

I'm trying to do something simple, I have a NSWindow containing a  
NSTableView that resizes with the with the window. When I click on one  
element I want to display additional information in a subView that I'm  
adding with [[theWindow contentView] addSubview:infoView];
The problem is when I do this the infoView is overlapped with the  
scrollView. How can I make it appear below the other views in the  
window? (maybe making the window grow in size). Some code examples or  
pointers would be great. (http://i31.tinypic.com/2wf1f95.jpg this is  
what it should look like after adding the subview)


Thank you for your time.
stefano
___

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

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

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

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


Re: Table view data source methods order?

2009-08-03 Thread Chase Meadors




From: Chase Meadors c.ed.m...@gmail.com
Date: August 3, 2009 1:27:26 PM CDT
To: Andy Lee ag...@mac.com
Subject: Re: Table view data source methods order?

This is beginning to frustrate me. I tried assigning the menu in the  
-dataCellFor... method and eliminating -willDisplay... altogether.  
But STILL all of my popups have index 0 selected. I'm returning a  
correct and valid NSNumber representing the index I want to select  
in the objectValue method.


On Aug 3, 2009, at 12:38 PM, Andy Lee wrote:


On Aug 3, 2009, at 1:04 AM, Chase Meadors wrote:

I'm having a bit of trouble here with table view data source  
methods. I have implemented. I have these three:


1) - (NSCell *)tableView:(NSTableView *)sender  
dataCellForTableColumn:(NSTableColumn *)tableColumn row: 
(NSInteger)row;
2) - (id)tableView:(NSTableView *)sender objectValueForTableColumn: 
(NSTableColumn *)tableColumn row:(NSInteger)row;
3) - (void)tableView:(NSTableView *)sender willDisplayCell: 
(id)cell forTableColumn:(NSTableColumn *)tableColumn row: 
(NSInteger)rowIndex;


I'm having trouble implementing what I want to implement. One  
column in my table view has some popup cells that have unique  
items to select from. In method 1) I'm returning a generic  
NSPopUpButtonCell if appropriate.


In method 2), I return an index based on a string in the list of  
values for that row.


In method 3), if the cell is one of my popups, I set it's menu to  
the list of values for that row.


Here's the problem. I'm returning the correct index for an object  
value in 2), but all of my popups have index 0 selected (with the  
correct list). The only reason I can think of is that cocoa  
follows this order:


1) call -objectValueFor...

2) THEN set the object value while the cell doesn't have it's list,

3) THEN call willDisplayCell...

Is there some way to implement this? They could simplify things by  
just giving direct access to the cell in the objectValueFor...  
method.'


If you put NSLogs at the beginning of each of the three methods,  
what order are they called in?


Is there any reason not to assign the menu in method 1)?

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


Fwd: Table view data source methods order?

2009-08-03 Thread Chase Meadors





From: Chase Meadors c.ed.m...@gmail.com
Date: August 3, 2009 2:01:57 PM CDT
To: Quincey Morris quinceymor...@earthlink.net
Subject: Re: Table view data source methods order?

Actually, and I forgot to mention this, I need number 1 because my  
second column contains a mix of text cells and popup cells depending  
on the data type.


And see my message I just forwarded to the list (I keep forgetting  
to change the address to cocoa-dev when replying to people).


On Aug 3, 2009, at 1:27 PM, Quincey Morris wrote:


On Aug 3, 2009, at 1:04 AM, Chase Meadors wrote:

I'm having a bit of trouble here with table view data source  
methods. I have implemented. I have these three:


1) - (NSCell *)tableView:(NSTableView *)sender  
dataCellForTableColumn:(NSTableColumn *)tableColumn row: 
(NSInteger)row;
2) - (id)tableView:(NSTableView *)sender objectValueForTableColumn: 
(NSTableColumn *)tableColumn row:(NSInteger)row;
3) - (void)tableView:(NSTableView *)sender willDisplayCell: 
(id)cell forTableColumn:(NSTableColumn *)tableColumn row: 
(NSInteger)rowIndex;


I think you're making a mistake in expecting an order to be  
guaranteed amongst mixed data source and delegate methods. Whatever  
order you see now isn't guaranteed and could change in the future.


Your #2 is correctly implemented, so forget about it from the point  
of view of the delegate methods.


Since you only have one NSPopUpButtonCell, you don't need both #1  
and #3. And since you apparently do need #1, you can get rid of #3,  
as Andy suggested.


Wherever you decide to set the menu for the current row, *that*  
method should also set the selected item index in the menu. Then it  
doesn't matter whether #2 is called before or after or at all.  
There's no reason for the delegate method to rely on the data  
source method to do its work for it.


You're not worrying about whether it's inefficient to recompute the  
selected menu item index, are you? If so, you can be sure a posse  
is going to be after you for premature optimization. :)



___

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

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

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


This email sent to c.ed.m...@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: addSubview: and positioning at the bottom of a NSWindow

2009-08-03 Thread Chase Meadors
Consider using NSDrawer. It can contain a content view (i.e. your info  
view) and can be attached to any side of a parent window, and be shown  
or hidden.


If you don't want to use this, however, just grab the content view's  
frame,


NSRect r = [[window contentView] frame]

and then call:

[[window contentView] setFrame:NSMakeRect(r.origin.x, r.origin.y,  
r.size.width, r.size.height + *however much you need*)];


Then set the frame of your subview and add it.

On Aug 3, 2009, at 1:51 PM, Stefano Pigozzi wrote:


Hello,

I'm trying to do something simple, I have a NSWindow containing a  
NSTableView that resizes with the with the window. When I click on  
one element I want to display additional information in a subView  
that I'm adding with [[theWindow contentView] addSubview:infoView];
The problem is when I do this the infoView is overlapped with the  
scrollView. How can I make it appear below the other views in the  
window? (maybe making the window grow in size). Some code examples  
or pointers would be great. (http://i31.tinypic.com/2wf1f95.jpg this  
is what it should look like after adding the subview)


Thank you for your time.
stefano
___

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

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

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

This email sent to c.ed.m...@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


Extending Undo Group with delay creates invalid state -- Why?

2009-08-03 Thread Jerry Krinock
In my Core Data document-based app, I'm trying to group undo  
registrations so that the user does not have to hit Undo more than  
once to undo a single action.


Some of this is caused by the logic in my setters.  For example,  
changing the 'name' attribute of an object in a collection posts a  
coalesced notification which causes the 'timeUnsorted' attribute of my  
document's 'configuration' object to be changed to the current time.   
(The logic is that changing the name of the object may change its  
position in the lexical order of objects sorted by name).


But, apparently because I coalesced this into a notification for  
efficiency, the 'timeUnsorted' change gets stacked into a different  
undo group.  The result is that the user needs to click Undo twice to  
undo a name change.


So I replaced the document's undo managed with my own subclass [1]  
which overrides -endUndoGrouping such that it performs after a delay  
of 0.0.  This fixes the double-undo problem, but creates a new problem  
-- that upon Undo it complains of an invalid state...


When I edit an object's name...
2009-08-03 11:27:10.073 MyApp[3775:10b] 470: Beginning Undo Grouping
2009-08-03 11:27:10.274 MyApp[3775:10b] 1053 Ending Undo Grouping

When I subsequently Undo...
2009-08-03 11:27:15.871 MyApp[3775:10b] 470: Beginning Undo Grouping
2009-08-03 11:27:15.984 MyApp[3775:10b] 1053 Ending Undo Grouping
2009-08-03 11:27:15.986 MyApp[3775:10b] endUndoGrouping:  
SSYUndoManager 0x15f24c00 is in invalid state, endUndoGrouping called  
with no matching begin


But why?  As you can see there ^was^ a matching begin.  1-1=0.

By the way, I presume that this undo grouping created during undo is  
actually a redo grouping.


Sincerely,

Jerry Krinock


[1]

@interface SSYUndoManager : NSUndoManager {}
@end


@implementation SSYUndoManager

- (void)beginUndoGrouping
{
NSLog(@470: Beginning Undo Grouping) ;
[super beginUndoGrouping] ;
[self setActionName:@] ;
}

- (void)endUndoGrouping
{
[self performSelector:@selector(reallyEndUndoGrouping)
   withObject:nil
   afterDelay:0.1] ;
}

- (void)reallyEndUndoGrouping
{
NSLog(@1053 Ending Undo Grouping) ;
[super endUndoGrouping] ;
}

@end

___

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

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

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

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


Screen savers on Snow Leopard

2009-08-03 Thread Jim O'Connor

The sample screen saver doesn't work on Leopard.

Are there new requirements for Snow Leopard and screen savers which  
must be met?



Thanks,
Jim O'Connor
___

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

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

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

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


Re: Screen savers on Snow Leopard

2009-08-03 Thread I. Savant

On Aug 3, 2009, at 4:09 PM, Jim O'Connor wrote:

Are there new requirements for Snow Leopard and screen savers which  
must be met?


  Snow Leopard is still under non-disclosure agreement and cannot be  
discussed on this list. Use the developer forums at the Apple  
Developer Connection site.


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


Memory efficient way to get image metadata?

2009-08-03 Thread kentozier
Hi 


I wrote an image catalog application that scans files on a Windows server, 
extracts certain image file info (like mod date, name, width, height and color 
mode) and writes this info to a database. During testing, in a real 
environment, the app started crashing and I narrowed the problem down to the 
following line of code: 




NSImage  *image  = [[NSImage alloc] initWithContentsOfFile: inPath]; 




If I comment that out, the app never crashes, but I also never get the width, 
height and color info. I used the instruments app to watch memory and during 
an initial scan of a directory tree, my app does use a lot of memory (50-60 mb) 
but no where near the Machine's limit of 2 gb. It seems like the OS can't keep 
up with all the image loading and freeing, and just thrashes memory so badly 
that at a certain point, it just refuses to allocate any more.  




I set a breakpoint at  malloc_error_break as the run log suggested, but it 
always leads back to the method containing the above line. 




Is there some way (other than rolling my own image readers) to just get the 
metadata from a file rather than having to load the entire thing? A third party 
class that would be something like NSImageInfo (if Apple had written such a 
class) 




Any help greatly appreciated. 










If I comment that out, the app never crashes, but it also never gets the image 
info I need. 
___

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

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

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

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


Re: Memory efficient way to get image metadata?

2009-08-03 Thread John Calhoun

On Aug 3, 2009, at 1:23 PM, kentoz...@comcast.net wrote:
Is there some way (other than rolling my own image readers) to just  
get the metadata from a file rather than having to load the entire  
thing? A third party class that would be something like  
NSImageInfo (if Apple had written such a class)


Look into ImageIO on the OS.  It is not a Cocoa class library but  
rather a C-level framework.  You can get the properties from an image  
probably a good deal more efficiently than via NSImage.  And you could  
easily wrap it all in your own ImageInfo Objective-C class if you  
want.


John Calhoun—___

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

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

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

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


Re: NSSound play often fails

2009-08-03 Thread Jerry Krinock


On 2009 Aug 03, at 11:28, James Walker wrote:

I'm having trouble getting sounds to play reliably.  When it  
happens, -[NSSound play] returns YES, but I hear nothing, and the  
sound:didFinishPlaying: delegate method is not called.  The sound in  
question is an AIFF file with a duration of about half a second.


Maybe it depends on whether a sound has already been played since the  
run loop last cycled?  If that might be the case, read this...


http://www.cocoabuilder.com/archive/message/cocoa/2009/3/29/233317

Since this was not critical for me at the time, I just accepted  
Michael's assertion and haven't done any more investigation.
 
___


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

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

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

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


Re: Screen savers on Snow Leopard

2009-08-03 Thread Kyle Sluder
Snow Leopard is under NDA. You can't talk about it here, but you can  
at http://devforums.apple.com.


--Kyle Sluder
___

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

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

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

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


Re: Table view data source methods order?

2009-08-03 Thread Quincey Morris

On Aug 3, 2009, at 13:24, Chase Meadors wrote:

Maybe I'm missing what you mean here, but if I do that, then what  
should I do in the objectValueFor... method?


On Aug 3, 2009, at 2:13 PM, Quincey Morris wrote:

Yes, but according to that message you *didn't* set the correct  
selection index in #1. I really think that's what you need to do.


The objectValue... method should return the index of the selected menu  
item, because that's what the value is for that column.


I'm going to change my earlier answer on the other part.

When you don't implement tableView:datCellForTableColumn:row:, the  
table view obviously has to set the object value of the (shared) cell  
it knows about for each row, and it would do that by calling the  
objectValue... data source method *after* it has found the cell to  
use. My *expectation* would be that it'd do the same thing for the  
result of dataCell..., but the documentation doesn't say anything  
about that one way or the other.


So I would still try having dataCell... retrieve the selected menu  
item index (possibly by calling objectValue... directly) and see if  
setting it solves the problem. If so, then answer is apparently that  
dataCell... is required to set up the desired object value. If not,  
this is a false trail.



___

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

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

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

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


Re: NSSound play often fails

2009-08-03 Thread James Walker

Jerry Krinock wrote:


On 2009 Aug 03, at 11:28, James Walker wrote:

I'm having trouble getting sounds to play reliably.  When it happens, 
-[NSSound play] returns YES, but I hear nothing, and the 
sound:didFinishPlaying: delegate method is not called.  The sound in 
question is an AIFF file with a duration of about half a second.


Maybe it depends on whether a sound has already been played since the 
run loop last cycled?  If that might be the case, read this...


http://www.cocoabuilder.com/archive/message/cocoa/2009/3/29/233317

Since this was not critical for me at the time, I just accepted 
Michael's assertion and haven't done any more investigation.


No, I definitely wasn't playing more than one sound per trip through the 
event loop.


I rewrote my sound playing function to use SystemSoundPlay instead of 
NSSound, and now it seems to work every time.  Of course, using 
SystemSoundPlay means that the sound won't play if the user unchecks 
play user interface sound effects in the Sound preference panel, but 
that may actually be appropriate in my case.

--
  James W. Walker, Innoventive Software LLC
  http://www.frameforge3d.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


unlockFocus called too many time console message

2009-08-03 Thread James Walker
When a modeless Cocoa window is closed by clicking the close widget, I 
see a console message saying unlockFocus called too many time. (sic). 
 It doesn't happen if the window is closed using the File:Close menu 
item.  I set a breakpoint on NSLog, and saw a stack starting like this:


NSLog
-[NSView unlockFocus]
-[NSControl mouseDown]
-[_NSThemeWidget mouseDown]
-[NSWindow sendEvent:]
carbonAppWindowMouseHandler

(none of which is my code)  Does this look like an OS bug?  (10.5.7)
--
  James W. Walker, Innoventive Software LLC
  http://www.frameforge3d.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: Memory efficient way to get image metadata?

2009-08-03 Thread kentozier


Thanks John. 




I looked at the documentation but there doesn't seem to be any obvious way to 
get the info. The only  CGImageSourceCreateWithURL  creation constants are: 




CFStringRef kCGImageSourceTypeIdentifierHint ; CFStringRef 
kCGImageSourceShouldAllowFloat ; CFStringRef kCGImageSourceShouldCache ; 
CFStringRef kCGImageSourceCreateThumbnailFromImageIfAbsent ; CFStringRef 
kCGImageSourceCreateThumbnailFromImageAlways ; CFStringRef 
kCGImageSourceThumbnailMaxPixelSize ; CFStringRef 
kCGImageSourceCreateThumbnailWithTransform Nothing there I need to do. And the 
CGImageSourceCopyProperties function only returns a single key  FileSize. 
Here's what I came up with. What else do I nee to add to not load the file but 
only read the metadata? 

NSURL                   *url         = [ NSURL fileURLWithPath : inPath]; 

     

CGImageSourceRef         img         = CGImageSourceCreateWithURL (( CFURLRef ) 
url, NULL ); 

     

NSDictionary             *props       = ( NSDictionary *) 
CGImageSourceCopyProperties (img, NULL ); 

     

CFRelease (img); 

     

NSLog ( @props: %@, path: %@ , props, inPath); 




P.S. I very rarely use the C interfaces, do I have to also run CFRelease on the 
result of the  CGImageSourceCopyProperties call? 

- Original Message - 
From: John Calhoun calho...@apple.com 
To: Cocoa Developers cocoa-dev@lists.apple.com 
Sent: Monday, August 3, 2009 4:33:51 PM GMT -05:00 US/Canada Eastern 
Subject: Re: Memory efficient way to get image metadata? 

On Aug 3, 2009, at 1:23 PM, kentoz...@comcast.net wrote: 
 Is there some way (other than rolling my own image readers) to just   
 get the metadata from a file rather than having to load the entire   
 thing? A third party class that would be something like   
 NSImageInfo (if Apple had written such a class) 

Look into ImageIO on the OS.  It is not a Cocoa class library but   
rather a C-level framework.  You can get the properties from an image   
probably a good deal more efficiently than via NSImage.  And you could   
easily wrap it all in your own ImageInfo Objective-C class if you   
want. 

John Calhoun—___ 

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

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

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

This email sent to kentoz...@comcast.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: Memory efficient way to get image metadata?

2009-08-03 Thread Dave Keck
 P.S. I very rarely use the C interfaces, do I have to also run CFRelease on 
 the result of the  CGImageSourceCopyProperties call?

Yes, you should. See 'The Create Rule':
http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029.

Or, if you're using Garbage Collection, you should call
CFMakeCollectable() on it.

Or you could cast it to id and autorelease it, which I find particularly handy.
___

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

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

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

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


NSUndoManager vs @synthesize

2009-08-03 Thread Houdah - ML Pierre Bernard

Hi!

Do I still need to write my own accessors in order to perform  
NSUndoManager registration?


Could my model objects observe themselves and register undoable  
changes in observeValueForKeyPath:ofObject:change:context:  ?


How does CoreData go about registering changes with the undo manager?  
Is this done by @synthesize setter or by the NSManagedObjectContext  
watching the model objects?


Pierre
___

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

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

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

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


Re: Table view data source methods order?

2009-08-03 Thread Chase Meadors
I think this isn't working either. Let me post the relevant code and  
see if you notice anything off the bat.


- (NSCell *)tableView:(NSTableView *)sender dataCellForTableColumn: 
(NSTableColumn *)tableColumn row:(NSInteger)row {


//cut: judge column and row...

	NSPopUpButtonCell *cell = [[NSPopUpButtonCell alloc] initTextCell:@  
pullsDown:YES];

[cell removeAllItems];
[cell addItemsWithTitles:[self listForColumn:tableColumn row:row]];
	//[cell setObjectValue:[NSNumber numberWithInt:15]]; (adding in this  
line appears to have no effect)


return cell;

//cut...

}

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


//cut: judge row and column...

	//find the index of a string in the list of strings for this  
particular row (which should be the popup cell's menu for this row)	
	int index = [[self listForColumn:tableColumn row:row] indexOfObject: 
[model objectForEntry:currentEntry handler:row]];

NSLog(@row %d --- %d, row, index); //reports correct

return [NSNumber numberWithInt:index];

//cut...

}

Adding the line in the first method that should set it's object value  
doesn't appear to do anything. Index 0 is still selected.


On Aug 3, 2009, at 4:05 PM, Quincey Morris wrote:


On Aug 3, 2009, at 13:24, Chase Meadors wrote:

Maybe I'm missing what you mean here, but if I do that, then what  
should I do in the objectValueFor... method?


On Aug 3, 2009, at 2:13 PM, Quincey Morris wrote:

Yes, but according to that message you *didn't* set the correct  
selection index in #1. I really think that's what you need to do.


The objectValue... method should return the index of the selected  
menu item, because that's what the value is for that column.


I'm going to change my earlier answer on the other part.

When you don't implement tableView:datCellForTableColumn:row:, the  
table view obviously has to set the object value of the (shared)  
cell it knows about for each row, and it would do that by calling  
the objectValue... data source method *after* it has found the cell  
to use. My *expectation* would be that it'd do the same thing for  
the result of dataCell..., but the documentation doesn't say  
anything about that one way or the other.


So I would still try having dataCell... retrieve the selected menu  
item index (possibly by calling objectValue... directly) and see if  
setting it solves the problem. If so, then answer is apparently that  
dataCell... is required to set up the desired object value. If not,  
this is a false trail.



___

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

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

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

This email sent to c.ed.m...@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: Table view data source methods order?

2009-08-03 Thread Quincey Morris

On Aug 3, 2009, at 15:16, Chase Meadors wrote:

	NSPopUpButtonCell *cell = [[NSPopUpButtonCell alloc]  
initTextCell:@ pullsDown:YES];


You want a popup menu, not a pull-down menu.


___

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

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

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

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


Re: Table view data source methods order?

2009-08-03 Thread Chase Meadors

...What the...?? That fixed it!...

I thought that was just a preference... come to think of it, why in  
the world DOES that make difference??


On Aug 3, 2009, at 5:49 PM, Quincey Morris wrote:


On Aug 3, 2009, at 15:16, Chase Meadors wrote:

	NSPopUpButtonCell *cell = [[NSPopUpButtonCell alloc]  
initTextCell:@ pullsDown:YES];


You want a popup menu, not a pull-down menu.


___

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

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

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

This email sent to c.ed.m...@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: Table view data source methods order?

2009-08-03 Thread Nick Zitzmann


On Aug 3, 2009, at 4:54 PM, Chase Meadors wrote:

I thought that was just a preference... come to think of it, why in  
the world DOES that make difference??


In a pop-up menu, the selected item is the displayed item. In a pull- 
down menu, the displayed item is always the very first item, but all  
enabled items in the menu can be selected except for the first one.  
Those action menus you see in apps like Mail are pull-downs.


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

___

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

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

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

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


Avoiding KVO in dealloc?

2009-08-03 Thread Todd Heberlein
While working through Beginning iPhone 3 Development I've seen the  
following a lot, and it seems like a general Cocoa issue.


In -viewDidUnload methods the code has the form:
self.foo = nil;

Whereas in -dealloc methods the code has the form:
[foo release];

Both methods seem to me to do the same thing (releasing foo), but I  
presume the first one would trigger any KVO observers where as the  
second wouldn't. Is that why the simple release is used instead of a  
setter in the dealloc methods, to avoid KVO? Is this a general Cocoa  
pattern?


Thanks,

Todd

___

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

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

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

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


Re: Avoiding KVO in dealloc?

2009-08-03 Thread Kyle Sluder
On Mon, Aug 3, 2009 at 4:35 PM, Todd Heberleintodd_heberl...@mac.com wrote:
 Both methods seem to me to do the same thing (releasing foo), but I presume
 the first one would trigger any KVO observers where as the second wouldn't.
 Is that why the simple release is used instead of a setter in the dealloc
 methods, to avoid KVO? Is this a general Cocoa pattern?

Yes, it's a general pattern.  Not just to avoid KVO, but any custom
accessor/mutator behavior.

The rule of thumb is never use your accessors/mutators inside -init or
-dealloc, and always use them elsewhere.

--Kyle Sluder
___

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

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

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

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


Re: Avoiding KVO in dealloc?

2009-08-03 Thread Kiel Gillard


On 04/08/2009, at 9:46 AM, Kyle Sluder wrote:

On Mon, Aug 3, 2009 at 4:35 PM, Todd  
Heberleintodd_heberl...@mac.com wrote:
Both methods seem to me to do the same thing (releasing foo), but I  
presume
the first one would trigger any KVO observers where as the second  
wouldn't.
Is that why the simple release is used instead of a setter in the  
dealloc

methods, to avoid KVO? Is this a general Cocoa pattern?


Yes, it's a general pattern.  Not just to avoid KVO, but any custom
accessor/mutator behavior.

The rule of thumb is never use your accessors/mutators inside -init or
-dealloc, and always use them elsewhere.


Unless, of course, you have code in your setter method that handles  
changes to and from nil. For example, you may add or remove self as an  
observer for keypaths of an different object value. This would save  
repeating the change handling code in your init, setter and dealloc  
methods.


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: Avoiding KVO in dealloc?

2009-08-03 Thread Kyle Sluder

On Aug 3, 2009, at 5:03 PM, Kiel Gillard kiel.gill...@gmail.com wrote:
Unless, of course, you have code in your setter method that handles  
changes to and from nil. For example, you may add or remove self as  
an observer for keypaths of an different object value. This would  
save repeating the change handling code in your init, setter and  
dealloc methods.


No, this is precisely what you should not do. -init and -dealloc  
should not invoke accessor methods, because the object is in a  
partially constructed state that subclasses (including the dynamically  
created ones KVO makes) often can't handle.


--Kyle Sluder
___

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

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

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

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


Re: Avoiding KVO in dealloc?

2009-08-03 Thread Kiel Gillard

On 04/08/2009, at 10:26 AM, Kyle Sluder wrote:

On Aug 3, 2009, at 5:03 PM, Kiel Gillard kiel.gill...@gmail.com  
wrote:
Unless, of course, you have code in your setter method that handles  
changes to and from nil. For example, you may add or remove self as  
an observer for keypaths of an different object value. This would  
save repeating the change handling code in your init, setter and  
dealloc methods.


No, this is precisely what you should not do. -init and -dealloc  
should not invoke accessor methods, because the object is in a  
partially constructed state that subclasses (including the  
dynamically created ones KVO makes) often can't handle.


Do you have a documentation reference for that? I would have expected  
the isa swizzling to be an implementation detail of the runtime that  
is handled before my subclass inits. Of course, what I expect and what  
happens in reality do not always match ;-)


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: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Graham Cox


On 04/08/2009, at 3:52 AM, Alexander Bokovikov wrote:

I'm sorry, but as I can see now, main menu shortcuts are also  
gray... I can delete them but I can't assign them. Why? I've created  
controller actions and have connected actions of menu items with the  
controller.



Just the keyboard items are grey, but the menu items are not? Or all  
grey?


Check out NSMenuItemValidation (-validateMenuItem:)  -most apps will  
want to explicitly validate their menu items which controls whether  
they are grey or not. The default of validating using - 
respondsToSelector: is usually too simplistic for real apps.


--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: Avoiding KVO in dealloc?

2009-08-03 Thread Kyle Sluder
On Mon, Aug 3, 2009 at 5:47 PM, Kiel Gillardkiel.gill...@gmail.com wrote:
 Do you have a documentation reference for that? I would have expected the
 isa swizzling to be an implementation detail of the runtime that is handled
 before my subclass inits. Of course, what I expect and what happens in
 reality do not always match ;-)

The Objective-C 2.0 Programming Guide prescribes the use of direct
ivar access inside an initializer[1] and inside dealloc[2].

As far as your point about when swizzling occurs, it can only happen
at the point of a KVO observer registration: the runtime can't predict
the future.

--Kyle Sluder

[1] 
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html#//apple_ref/doc/uid/TP30001163-CH22-SW14
[2] 
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW16
___

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

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

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

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


Re: Avoiding KVO in dealloc?

2009-08-03 Thread Kiel Gillard

On 04/08/2009, at 10:59 AM, Kyle Sluder wrote:

On Mon, Aug 3, 2009 at 5:47 PM, Kiel Gillardkiel.gill...@gmail.com  
wrote:
Do you have a documentation reference for that? I would have  
expected the
isa swizzling to be an implementation detail of the runtime that is  
handled
before my subclass inits. Of course, what I expect and what happens  
in

reality do not always match ;-)


The Objective-C 2.0 Programming Guide prescribes the use of direct
ivar access inside an initializer[1] and inside dealloc[2].

[1] http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html#/ 
/apple_ref/doc/uid/TP30001163-CH22-SW14
[2] http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html#/ 
/apple_ref/doc/uid/TP30001163-CH17-SW16


Thanks for these - much appreciated. The -dealloc commentary was very  
helpful. For the OP, this means care should be taken to unobserve key  
paths before dealloc. One way this could be done by observing  
NSApplicationWillTerminateNotification.


The constraints and conventions commentary for the init method seems  
to be more about coding style (consistency in style during  
initialisation and deallocation) as one could argue the side affects  
of a custom accessor are desired (such as registering a new object  
value of an instance variable for KVO notifications).



As far as your point about when swizzling occurs, it can only happen
at the point of a KVO observer registration: the runtime can't predict
the future.


When if I observe some property of Foo *bar at some point in time, KVO  
swizzles the isa to KVONotifying_Foo. Then, if I observe a different  
property of the same object at some other point in time, are you  
suggesting KVO swizzles the isa to KVONotifying_Foo2 which in turn  
can often break future KVO notifications?


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: Avoiding KVO in dealloc?

2009-08-03 Thread Kyle Sluder
On Mon, Aug 3, 2009 at 6:32 PM, Kiel Gillardkiel.gill...@gmail.com wrote:
 When if I observe some property of Foo *bar at some point in time, KVO
 swizzles the isa to KVONotifying_Foo. Then, if I observe a different
 property of the same object at some other point in time, are you suggesting
 KVO swizzles the isa to KVONotifying_Foo2 which in turn can often break
 future KVO notifications?

No, I wasn't trying to imply anything about the actual behavior of
KVO-generated subclasses.  I was referring to the fact that it doesn't
know about your implementation, and if you use accessors in your
-dealloc you might run afoul of the expected behavior of any subclass,
including those generated by KVO.

--Kyle Sluder
___

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

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

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

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


Re: text control for keyboard shortcut input?

2009-08-03 Thread aaron smith
Thanks!

Quick question. I've got the source, I'm getting problems building it.
The problem I see is that I don't have the
InterfaceBuilder.framework. What's strange is that I can't seem to
find that framework. The default xcode project for shortcut recorder
is trying to reference the framework in
/System/Library/Frameworks/InterfaceBuilder.framework. Which it's not
there. So I've been snooping through the SDK and the only place I see
interface builder framework is in
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/

I seem to be missing an InterfaceBuilder.framework for 10.5 Any ideas?

Thanks
-A



On Mon, Aug 3, 2009 at 3:45 AM, I. Savantidiotsavant2...@gmail.com wrote:
 On Aug 3, 2009, at 4:07 AM, aaron smith wrote:

 Does anyone know of any prebuilt views for something like this:
 http://tinyurl.com/mggdtd - I've been snooping around google for a
 while but can't seem to get the right keywords to bring anything up.
 Any ideas? Thanks much!

  I believe this is what you're looking for:

 Shortcut Recorder
 http://code.google.com/p/shortcutrecorder/

  The project contains more than the control - it contains some good code for
 managing shortcuts (including global).

 --
 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: Avoiding KVO in dealloc?

2009-08-03 Thread Dave Camp

On Aug 3, 2009, at 6:32 PM, Kiel Gillard wrote:

On 04/08/2009, at 10:59 AM, Kyle Sluder wrote:
On Mon, Aug 3, 2009 at 5:47 PM, Kiel Gillardkiel.gill...@gmail.com  
wrote:
Do you have a documentation reference for that? I would have  
expected the
isa swizzling to be an implementation detail of the runtime that  
is handled
before my subclass inits. Of course, what I expect and what  
happens in

reality do not always match ;-)


The Objective-C 2.0 Programming Guide prescribes the use of direct
ivar access inside an initializer[1] and inside dealloc[2].

[1] http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html#/ 
/apple_ref/doc/uid/TP30001163-CH22-SW14
[2] http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html#/ 
/apple_ref/doc/uid/TP30001163-CH17-SW16


Thanks for these - much appreciated. The -dealloc commentary was  
very helpful. For the OP, this means care should be taken to  
unobserve key paths before dealloc. One way this could be done by  
observing NSApplicationWillTerminateNotification.


Assuming the objects you were observing lasted as long as the app,  
yes. For anything shorter term (e.g. document data), you still need to  
know when the object will be dealloced and stop observing before then.


Dave

___

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

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

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

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


Re: NSString and regular expressions

2009-08-03 Thread BareFeet

Hi All,

RegexKitLite looks promising. It claims to only require you to add  
the .h and .m file to your project and link to the libicucore.dylib  
library.


I managed to incorporate RegexKitLite fairly easily once I found in  
the documentation the steps to link to the libicucore.dylib library.


Thanks for all your comments about ICU vs PCRE. I've thrown a couple  
of fairly involved regexes at it that I've previously used in Perl  
(therefore PCRE) and haven't had to make any adjustments at all.


I've wrapped it in a test Cocoa app that shows capture in an outline  
view, with each group showing as a child item of its capture. It's  
working very well so far. The essence of my use of RegexKitLite here is:


- (IBAction)update:(id)sender
{
NSString * regexString = [regexField string];
NSString * inputString = [inputField string];

	[outputArray release]; // already defined as an instance variable in  
the .h file

NSError * myError = nil;
NSRange myRange = NSMakeRange(0, [inputString length]);
	outputArray = [inputString  
arrayOfCaptureComponentsMatchedByRegex:regexString  
options:RKLNoOptions range:myRange error:myError];

[outputArray retain];
[outputOutline reloadData];
}
@end

I'm new to Cocoa and Objective-C. So please tell me gently of any  
glaring errors above


Now to use it in my real project, I need to port over my routines that  
parsed SQL statements. I have been doing this by:


1. Using regex to replace quoted items (eg bounded by  or ' or a  
comment bounded by /* */ or -- \n) with placeholders.


2. Using regex to parse the SQL (now containing placeholders) into  
desired SQL components


3. Replacing placeholders with original text.

Before I go ahead and port this same method across, is there any built  
in functionality in Cocoa that will facilitate this (or part of it)  
directly?


Thanks,
Tom
BareFeet

___

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

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

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

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


AGRegex (was: NSString and regular expressions)

2009-08-03 Thread BareFeet

Hi all,

Has anyone got procedure for getting AGRegex to work in their project?

Thanks,
Tom
BareFeet

 
From: BareFeet list.develo...@tandb.com.au
Date: 31 July 2009 9:03:20 AM AEST
To: Cocoa Dev Cocoa-dev@lists.apple.com
Subject: Re: NSString and regular expressions

Hi Rob,


I personally just compile the files directly into my project.

You need AGRegex.h and AGRegex.m but you should only compile the  
following files from the pcre distribution:


pcre_chartables.c
pcre_compile.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_info.c
pcre_ord2utf8.c
pcre_tables.c
pcre_try_flipped.c
pcre_ucp_searchfuncs.c
pcre_valid_utf8.c
pcre_xclass.c


Thanks. I tried that, but get 436 fails during compile, starting with  
pcre.h: No such file or directory.


So I copied pcre.h across to my project too but then get more errors  
starting with pcre_internal.h No such file or directory.


If I add all the header files, I still get compile errors, starting  
with:


pcre_ucp_searchfuncs.c:48:54:
 error: ucptable.c: No such file or directory

So I copied ucptable.c but I get the error:

ucptable.c:4:
 error: expected '=', ',', ';', 'asm' or '__attribute__' before  
'ucp_table'


Can you please clue me in as to how to get AGRegex to work?

Thanks,
Tom
BareFeet

 
From: BareFeet list.develo...@tandb.com.au
Date: 30 July 2009 2:51:59 PM AEST
To: Cocoa-dev cocoa-dev@lists.apple.com
Subject: Re: NSString and regular expressions

Hi Rob  all,

On 28/07/2009, at 11:02 AM, Rob Keniger wrote:

You might want to look at AGRegex which is very compact (one class)  
and which uses PCRE:


http://colloquy.info/project/browser/trunk/Frameworks/AGRegex


Thanks for the tip. Have you been able to get this to work?

Do we add the framework or the AGRegex files (and PCRE folder) to our  
own project? I've tried both and can't get it to work. I can't find  
any instructions in the documentation on adding it correctly to your  
own project.


Thanks,
Tom
BareFeet
___

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

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

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

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


Strange result from Address Book

2009-08-03 Thread Graham Cox

I'm using the following code from Uli's UKCrashReporter:

	ABMultiValue*	emailAddresses = [[[ABAddressBook sharedAddressBook]  
me] valueForProperty: kABEmailProperty];
	NSString*	emailAddr =  
NSLocalizedStringFromTable 
(@MISSING_EMAIL_ADDRESS,@UKCrashReporter,@);


if( emailAddresses )
{
NSString*   defaultKey = [emailAddresses 
primaryIdentifier];
if( defaultKey )
{
			unsigned int	defaultIndex = [emailAddresses indexForIdentifier:  
defaultKey];

if( defaultIndex != NSNotFound )
emailAddr = [emailAddresses valueAtIndex: 
defaultIndex];
}
}

defaultKey comes back as a reasonable looking UUID string.
defaultIndex comes back as 0.
emailAddr comes back as @0x17C726C0 which is clearly bogus. I've  
checked my own entry in the Address Book app and it's fine. The  
initial missing email address is loaded correctly, but gets  
overwritten by the hex string.


Anyone any idea what's going on?

--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: AGRegex (was: NSString and regular expressions)

2009-08-03 Thread Rick Mann
I gave up on AGRegex and used RegexKit, which was very easy to get to  
work.


On Aug 3, 2009, at 20:15:18, BareFeet wrote:


Hi all,

Has anyone got procedure for getting AGRegex to work in their project?

Thanks,
Tom
BareFeet


From: BareFeet list.develo...@tandb.com.au
Date: 31 July 2009 9:03:20 AM AEST
To: Cocoa Dev Cocoa-dev@lists.apple.com
Subject: Re: NSString and regular expressions

Hi Rob,


I personally just compile the files directly into my project.

You need AGRegex.h and AGRegex.m but you should only compile the  
following files from the pcre distribution:


pcre_chartables.c
pcre_compile.c
pcre_exec.c
pcre_fullinfo.c
pcre_get.c
pcre_globals.c
pcre_info.c
pcre_ord2utf8.c
pcre_tables.c
pcre_try_flipped.c
pcre_ucp_searchfuncs.c
pcre_valid_utf8.c
pcre_xclass.c


Thanks. I tried that, but get 436 fails during compile, starting  
with pcre.h: No such file or directory.


So I copied pcre.h across to my project too but then get more errors  
starting with pcre_internal.h No such file or directory.


If I add all the header files, I still get compile errors, starting  
with:


pcre_ucp_searchfuncs.c:48:54:
error: ucptable.c: No such file or directory

So I copied ucptable.c but I get the error:

ucptable.c:4:
error: expected '=', ',', ';', 'asm' or '__attribute__' before  
'ucp_table'


Can you please clue me in as to how to get AGRegex to work?

Thanks,
Tom
BareFeet


From: BareFeet list.develo...@tandb.com.au
Date: 30 July 2009 2:51:59 PM AEST
To: Cocoa-dev cocoa-dev@lists.apple.com
Subject: Re: NSString and regular expressions

Hi Rob  all,

On 28/07/2009, at 11:02 AM, Rob Keniger wrote:

You might want to look at AGRegex which is very compact (one class)  
and which uses PCRE:


http://colloquy.info/project/browser/trunk/Frameworks/AGRegex


Thanks for the tip. Have you been able to get this to work?

Do we add the framework or the AGRegex files (and PCRE folder) to  
our own project? I've tried both and can't get it to work. I can't  
find any instructions in the documentation on adding it correctly to  
your own project.


Thanks,
Tom
BareFeet
___

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

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

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

This email sent to rm...@latencyzero.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: Strange result from Address Book

2009-08-03 Thread Graham Cox


On 04/08/2009, at 1:17 PM, Graham Cox wrote:


I'm using the following code from Uli's UKCrashReporter:

	ABMultiValue*	emailAddresses = [[[ABAddressBook sharedAddressBook]  
me] valueForProperty: kABEmailProperty];
	NSString*	emailAddr =  
NSLocalizedStringFromTable 
(@MISSING_EMAIL_ADDRESS,@UKCrashReporter,@);


if( emailAddresses )
{
NSString*   defaultKey = [emailAddresses 
primaryIdentifier];
if( defaultKey )
{
			unsigned int	defaultIndex = [emailAddresses indexForIdentifier:  
defaultKey];

if( defaultIndex != NSNotFound )
emailAddr = [emailAddresses valueAtIndex: 
defaultIndex];
}
}

defaultKey comes back as a reasonable looking UUID string.
defaultIndex comes back as 0.
emailAddr comes back as @0x17C726C0 which is clearly bogus. I've  
checked my own entry in the Address Book app and it's fine. The  
initial missing email address is loaded correctly, but gets  
overwritten by the hex string.


Anyone any idea what's going on?



More info:

If I do 'po emailAdresses' I get:

{
*  home  0x17C726C0
   home  0x172A3D70
}


and if I do 'po 0x17C726C0' I get:

ABCDEmailAddress: 0x17C726C0  (entity: ABCDEmailAddress; id:  
0x18e2e1a0 x-coredata://5886BF42-F5AE-4627-A66F-1A562205BD07/ABCDEmailAddress/p13 
 ; data: {

address = 0x17C726C0;
addressNormalized = xxx@.com;
distributionListConfigs = relationship fault: 0x19a801d0  
'distributionListConfigs';

isPrimary = 1;
isPrivate = nil;
label = _$!Home!$_;
orderingIndex = 0;
owner = 0x164e6c40 x-coredata://5886BF42-F5AE-4627-A66F-1A562205BD07/ABCDContact/p15 
;

uniqueId = 9D4F1D76-4859-11D7-A1BB-00039353556E;
})

(I've obscured the email address as an anti-spam measure).

The ABPropertyType comes back as 257 which is kABMultiValueMask |  
kABStringProperty, but the actual value looks like a Core Data entity  
of some sort, not a string.


Is this a bug in ABMultiValue's -valueAtIndex: method? Again, just  
what is going on?



--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: AGRegex (was: NSString and regular expressions)

2009-08-03 Thread Adam R. Maxwell


On Aug 3, 2009, at 8:15 PM, BareFeet wrote:


Has anyone got procedure for getting AGRegex to work in their project?


I've used AGRegex.framework in a number of projects, but it's been so  
long that I've no idea what steps I went through to set it up.  The  
copy here


https://tcobrowser.svn.sourceforge.net/svnroot/tcobrowser/trunk/bibdesk/vendorsrc/agkit_sourceforge/agregex

should work as-is, provided you set up Xcode's prefs with a separate  
directory for built products and intermediate files.  It also has a  
few bug fixes.  General framework compilation problems are probably  
better addressed on the xcode-users list.


--
Adam



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

Re: Code Signing for development

2009-08-03 Thread Kyle Sluder
This question is probably better-suited to Xcode-users or the iPhone  
dev forums at devforums.apple.com.


--Kyle Sluder
___

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

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

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

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