Re: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive

2009-07-02 Thread Jerry Krinock


On 2009 Jul 02, at 22:53, Jim Correia wrote:


Do you have a sample app & data combo which demonstrates the crash?


Yes, if you take the TEST CODE at the bottom of my original post and  
revert to Apple's method by commenting out the +[NSKeyedUnarchiver  
load] method in there, it will crash.


If you have no exception handler in place, the program will  
terminate. But that isn't due to a bug in NSKeyedUnarchiver - it is  
just working as advertised - whether or not you like the advertised  
behavior.


Indeed, if I enclose it in a @try block, then it will not crash.  But  
I think it's error-prone and inconvenient to have to enclose it in a  
@try block.


Is that what you mean by "exception handler in place"?  --  enclose it  
in a @try block ?


___

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

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

Help/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: documenting bindings (was: Re: Dynamically loading a part of a Window in Cocoa)

2009-07-02 Thread Jonathan Hendry


On Jul 3, 2009, at 00:25 AM, Jeff Johnson wrote:


This is why I tell people nibs are no good.

Also bindings. ;-)


Bindings are definitely the worst-case scenario for nibs. They tend to  
proliferate, and they are burrowed deep in the IB UI making them hard  
to miss if you don't check every widget on every tab view, etc.


Where I work, we implement experiments as loadable bundles. Since the  
experiments tend to be very similar but specific to a student's  
particular line of research, we have a tool that clones an existing  
experiment project into a new project folder. It modifies class, ivar,  
and constant identifier prefixes, removing a lot of drudge work, but  
can't get into the nibs to change the bindings to refer to the new  
keys. So we have to go through the nibs, track down all the bindings,  
and make sure they're updated with keys that use the new project's  
prefix string rather than the old one.


Some kind of bindings editing tool would be very much appreciated.  
Maybe a table listing a nib's keys that are bound in the first column,  
with additional info in additional columns, such as the associated UI  
objects.


That at least would let you sort alphabetically, which would catch  
stragglers, and would let you more easily check for missing keys.

___

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

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

Help/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: Dynamically loading a part of a Window in Cocoa

2009-07-02 Thread Chris Hanson

On Jul 1, 2009, at 8:18 PM, Marco S Hyman wrote:


On Jul 1, 2009, at 6:50 PM, Adam R. Maxwell wrote:

Well, I generally avoid bindings, since I can't comment nib/xib  
files, and it takes too long to reverse engineer my own (or worse,  
someone else's) bindings when I'm doing maintenance work.  With  
that perspective, the minor glue code to swap views is no big  
deal :).


Warning: subject creep.

That leads directly to something I've been thinking about as one new  
to cocoa:
how do you document your bindings?   Any preferred formats other  
than a text

file stuck somewhere in a project?


You can document bindings, as well as target-action and outlet  
connections, by writing unit tests to specify them.  You can even do  
test-driven development of your xib files this way.


This can be as simple as writing tests that say “the value of the  
table’s name column is bound to the Employees array controller’s  
‘arrangedObjects.name’ property” and the creating the appropriate  
bindings to make this test pass.


All of the information you need to test bindings can be easily found  
using the -infoForBinding: method on any view or controller that  
supports bindings.  I’ve written some weblog posts on the topic:


	Unit testing Cocoa user interfaces: Target-Action 
	Unit testing Cocoa user interfaces: Cocoa Bindings 


These show how you might actually write some code to specify a  
binding, or a target-action connection, in your application or  
framework’s unit tests.


  — Chris

___

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

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

Help/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: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive

2009-07-02 Thread Jim Correia
On Thu, Jul 2, 2009 at 11:17 PM, Jerry Krinock  wrote:

If -[NSKeyedUnarchiver unarchiveObjectWithData:] is handed a corrupt
> archive, it raises an exception AND crashes the program.


Do you have a sample app & data combo which demonstrates the crash?

+[NSKeyedUnarchiver unarchiveObjectWithData:] is documented to raise an
exception when feed an incomprehensible archive.

If you have no exception handler in place, the program will terminate. But
that isn't due to a bug in NSKeyedUnarchiver - it is just working as
advertised - whether or not you like the advertised behavior.

- Jim
___

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

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

Help/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: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive

2009-07-02 Thread Jerry Krinock


On 2009 Jul 02, at 21:11, Michael Ash wrote:


Is there a reason you can't just implement a new method in a category
and not replace the existing one? It will be just as safe in your
code, just as easy to use,


I'd considered doing that and yes it could be done.  But then it would  
have a different method name that I'd have to remember to use instead  
of -unarchiveObjectWithData:.


Replacing a Cocoa method seems like it should only be done if the  
original method shipped by Apple is buggy.  I believe that's the case  
here.  The only behavior I'm losing is a potential crash.


I suppose Method Replacement has disadvantages too.  I have to  
remember to include this method replacement file in any new project I  
start, or else I'll get the old crashy behavior, since I'll be out of  
the habit of using try/catch.


and it won't run the potential risk of screwing up code that you  
don't control.


Interesting -- but the only "screwing up" I'm doing is allowing it to  
execute beyond a point where it otherwise would have crashed.  I  
suppose that if someone is using this crashing "feature" of - 
unarchiveObjectWithData: as some kind of self-destruct security  
mechanism, I could be introducing a security hole  :))


Anyhow, I get your point.

Thanks, Michael.

___

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

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

Help/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: Determining OS at Runtime

2009-07-02 Thread Andrew Farmer

On 2 Jul 2009, at 16:29, Steve Christensen wrote:
If you want to make sure that you don't include any "old" code in  
your executable when you decide to make 10.5 (for example) your base  
OS version, you could arrange your code like this:


#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
   if (SomeLeopardFunction == NULL)
   TigerFunction();
   else
#endif
   SomeLeopardFunction();


Preprocessor directives take effect at compile time, not at runtime.
___

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

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

Help/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: Sorting on a table view of a managed object - debugger throws exception

2009-07-02 Thread Quincey Morris

On Jul 2, 2009, at 19:51, Steve Cronin wrote:


SortDescriptor is, of course, an NSArray - which is also named 'code'.


Huh? Does the matching name mean something about the MyEntity "code"  
property?


Furthermore this all works peachy in a Release build on either Tiger  
or Leopard.

Clicking on tableColumn headers sort just as expected.

But not in Debug build - In Debug if I click on table column header  
I get thrown into an error:
Error setting value for key path value of object 0x852600> (from bound object 0x3cbe30>[entity:MyEntity, number of selected objects: 1](null)): [<  
MyAppDelegate  0x852600> setValue:forUndefinedKey:]:


When debugging weird bindings errors, I found it impossibly confusing  
if the property names weren't unique. It might be worthwhile, if you  
want to track this problem down, to change the app delegate "code" to  
something else. Also note that there's a property named "value"  
mentioned in the error message. Is there really a property of that name?


Possibly your best strategy at this point would be put a  
setValue:forUndefinedKey override in your app delegate, that calls  
super, just so you can set a breakpoint there and look at the  
backtrace when things go wrong.



___

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

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

Help/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: documenting bindings (was: Re: Dynamically loading a part of a Window in Cocoa)

2009-07-02 Thread Jeff Johnson

On Jul 2, 2009, at 4:25 PM, Andy Lee wrote:

On Thursday, July 02, 2009, at 11:39AM, "Michael Ash" > wrote:

On Wed, Jul 1, 2009 at 11:18 PM, Marco S Hyman wrote:

[...]
That leads directly to something I've been thinking about as one  
new to

cocoa:
how do you document your bindings?   Any preferred formats other  
than a text

file stuck somewhere in a project?


If you're going to stick your bindings in a text file, why not stick
them in a text file which happens to end in .m, and document them  
in a

format that the compiler can understand? In other words, why not just
make your bindings in code? Then you can easily see them, you can
comment them to your heart's content, you can search for them, and  
all

the other benefits of having stuff not be in your nib.


My first reaction was: "Elegantly put!"  But then I thought, isn't  
*not* generating this kind of code one of the reasons we tell people  
nibs are good?  Wouldn't a .m be a good place to "document" targets  
and actions as well?  And delegates and other outlets?  Or do you  
think there's something about bindings that makes them subtle enough  
that for *them*, in some cases, it might make sense to "document"  
them by coding them?


--Andy


This is why I tell people nibs are no good.

Also bindings. ;-)

-Jeff

___

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

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

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

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


Re: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive

2009-07-02 Thread Michael Ash
On Thu, Jul 2, 2009 at 11:17 PM, Jerry Krinock wrote:
> If -[NSKeyedUnarchiver unarchiveObjectWithData:] is handed a corrupt
> archive, it raises an exception AND crashes the program.  I find this to be
> very annoying since, almost always, archives come from files or network
> sources where corruption is possible.  Therefore, I have always protected
> this invocation in a try/catch block.
>
> As I was about to do this for about the fifth time this year, I decided to
> use the Method Replacement feature of Leopard to replace this method, once
> and for all, with one that wouldn't crash.  I understand that Method
> Replacement should not be done casually because any plug-in code and even
> Cocoa itself will use the replaced method.  However, I can't think of any
> usage where  a crash would be required behavior.
>
> It seems to work fine, after 10 minutes of testing.  Does anyone see any
> problem with this?

Is there a reason you can't just implement a new method in a category
and not replace the existing one? It will be just as safe in your
code, just as easy to use, and it won't run the potential risk of
screwing up code that you don't control.

Mike
___

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

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

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

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


Re: documenting bindings (was: Re: Dynamically loading a part of a Window in Cocoa)

2009-07-02 Thread Michael Ash
On Thu, Jul 2, 2009 at 5:25 PM, Andy Lee wrote:
> On Thursday, July 02, 2009, at 11:39AM, "Michael Ash"  
> wrote:
>>On Wed, Jul 1, 2009 at 11:18 PM, Marco S Hyman wrote:
> [...]
>>> That leads directly to something I've been thinking about as one new to
>>> cocoa:
>>> how do you document your bindings?   Any preferred formats other than a text
>>> file stuck somewhere in a project?
>>
>>If you're going to stick your bindings in a text file, why not stick
>>them in a text file which happens to end in .m, and document them in a
>>format that the compiler can understand? In other words, why not just
>>make your bindings in code? Then you can easily see them, you can
>>comment them to your heart's content, you can search for them, and all
>>the other benefits of having stuff not be in your nib.
>
> My first reaction was: "Elegantly put!"  But then I thought, isn't *not* 
> generating this kind of code one of the reasons we tell people nibs are good? 
>  Wouldn't a .m be a good place to "document" targets and actions as well?  
> And delegates and other outlets?  Or do you think there's something about 
> bindings that makes them subtle enough that for *them*, in some cases, it 
> might make sense to "document" them by coding them?

Sure, that would be a fine place to document them. And yes, I don't
think anybody ever does. Why not? Well, I don't think they document
them *anywhere else* either. Target/actions and outlets and such are
simple enough that people don't seem to feel the need to document them
at all.

If for some reason you *did* feel the need to document those, setting
them up in code would be a fine way to go.

Mike
___

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

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

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

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


Re: Windows on main thread always only sometimes?

2009-07-02 Thread Michael Ash
On Thu, Jul 2, 2009 at 2:16 PM, Jack Repenning wrote:
> I've always been taught that one must only create and run AppKit objects on
> the main thread. Recently, though, over in objc-language,
>
>  http://lists.apple.com/archives/Objc-language/2009/Jul/msg2.html
>
> it was pointed out that the threading Programming Guide seems to say
> otherwise:
>
>>
>> 
>> says:
>> "You can create a window on a secondary thread. The Application Kit
>> ensures that the data structures associated with a window are deallocated on
>> the main thread to avoid race conditions. There is some possibility that
>> window objects may leak in an application that deals with a lot of windows
>> concurrently. You can create a modal window on a secondary thread. The
>> Application Kit blocks the calling secondary thread while the main thread
>> runs the modal loop."
>
> But now I notice this only says you can *create* windows from secondary
> threads; it doesn't explicitly allow any other action, and it even refers to
> several automatic insurances that other things happen on the main thread.
>
> So what *are* the rules? Is the Thread Safety Summary implicitly strict,
> "you can create a window, but absolutely nothing else"? Or is there some set
> of other operations that are permitted from the secondary (and where do I
> learn those)?

The ironclad rule of thread safety is that if it's not *explicitly*
documented to be thread safe, then it's not.

Thus, all of these other things that the docs don't explicitly refer
to aren't safe to do.

Mike
___

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

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

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

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


Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive

2009-07-02 Thread Jerry Krinock
If -[NSKeyedUnarchiver unarchiveObjectWithData:] is handed a corrupt  
archive, it raises an exception AND crashes the program.  I find this  
to be very annoying since, almost always, archives come from files or  
network sources where corruption is possible.  Therefore, I have  
always protected this invocation in a try/catch block.


As I was about to do this for about the fifth time this year, I  
decided to use the Method Replacement feature of Leopard to replace  
this method, once and for all, with one that wouldn't crash.  I  
understand that Method Replacement should not be done casually because  
any plug-in code and even Cocoa itself will use the replaced method.   
However, I can't think of any usage where  a crash would be required  
behavior.


It seems to work fine, after 10 minutes of testing.  Does anyone see  
any problem with this?


Sincerely,

Jerry Krinock


#import 


/*!
 @briefImprovements to NSKeyedUnarchiver

 @details  Method +unarchiveObjectWithData: has been replaced so that
 instead of raising an exception and crashing if given a corrupt  
archive,

 it just returns nil.  Also, another method has been added which
 returns the exception.
*/
@interface NSKeyedUnarchiver (CatchExceptions)

/*!
 @briefLike unarchiveObjectWithData:, except it returns the
 exception by reference.

 @paramexception_p  Pointer which will, upon return, if an
 exception occurred and said pointer is not NULL, point to said
 NSException.
 */
+ (id)unarchiveObjectWithData:(NSData*)data
  exception_p:(NSException**)exception_p ;

@end

#import "NSKeyedUnarchiver+CatchExceptions.h"
#import 

@implementation NSKeyedUnarchiver (CatchExceptions)

+ (id)unarchiveObjectWithData:(NSData*)data
  exception_p:(NSException**)exception_p {
id object = nil ;

@try {
// Note: Since methods were swapped, this is invoking the  
original method
object = [NSKeyedUnarchiver  
replacement_unarchiveObjectWithData:data] ;

}
@catch (NSException* exception) {
if (exception_p) {
*exception_p = exception ;
}
}
@finally{
}

return object ;
}

+ (void)load {
// Swap the implementations of +unarchiveObjectWithData: and  
+replacement_unarchiveObjectWithData:.
// When the +unarchiveObjectWithData: message is sent to the  
NSKeyedUnarchiver class object,
// +replacement_unarchiveObjectWithData: will be invoked  
instead.  Conversely,
// +replacement_unarchiveObjectWithData: will invoke  
+unarchiveObjectWithData:.
Method originalMethod = class_getClassMethod(self,  
@selector(unarchiveObjectWithData:)) ;
Method replacedMethod = class_getClassMethod(self,  
@selector(replacement_unarchiveObjectWithData:)) ;

method_exchangeImplementations(originalMethod, replacedMethod) ;
}

+ (id)replacement_unarchiveObjectWithData:(NSData*)data {
return [self unarchiveObjectWithData:data
 exception_p:NULL] ;
}

@end


TEST CODE:

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

// Try to unarchive your bash profile
// This ain't gonna be able to unarchive
NSData* data = [NSData dataWithContentsOfFile:[NSHomeDirectory()  
stringByAppendingPathComponent:@".bash_profile"]] ;

NSLog(@"Your bash profile data is %d bytes.", [data length]) ;

id whatever ;

// Try it using the normal method
whatever = [NSKeyedUnarchiver unarchiveObjectWithData:data] ;
NSLog(@"1.  unarchived whatever = %@", whatever) ;

// Try it using the improved method that returns the exception:
NSException** exception ;
whatever = [NSKeyedUnarchiver unarchiveObjectWithData:data
  exception_p:&exception] ;
NSLog(@"2.  unarchived whatever = %@", whatever) ;
NSLog(@"exception = %@", exception) ;

[pool release] ;
}



___

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

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

Help/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: Sorting on a table view of a managed object - debugger throws exception

2009-07-02 Thread Steve Cronin

Quincey;

Do you in fact have a "code" property? On the app delegate? What's
does it's @property (or accessor prototype) look like?

The 'code' property is declared on an entity: MyEntity.
The accessors were created by XCode itself using the 'Copy Method  
Declaration/Implementation to Clipboard'


- (NSString *)code {
   NSString * tmpValue;
   [self willAccessValueForKey: @"code"];
   tmpValue = [self primitiveValueForKey: @"code"];
   [self didAccessValueForKey: @"code"];
   return tmpValue;
}

- (void)setCode:(NSString *)value {
   [self willChangeValueForKey: @"code"];
   [self setPrimitiveValue: value forKey: @"code"];
   [self didChangeValueForKey: @"code"];
}

The accessors work because the table is sorted when first presented.
Sorted according to the sortDescriptor which is declared in  
MyAppDelegate and bound using IB to MyArrayController.

SortDescriptor is, of course, an NSArray - which is also named 'code'.
Furthermore this all works peachy in a Release build on either Tiger  
or Leopard.

Clicking on tableColumn headers sort just as expected.

But not in Debug build - In Debug if I click on table column header I  
get thrown into an error:
Error setting value for key path value of object 0x852600> (from bound object 0x3cbe30>[entity:MyEntity, number of selected objects: 1](null)): [<  
MyAppDelegate  0x852600> setValue:forUndefinedKey:]:


Steve
___

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

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

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

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


Possible NSPredicateEditor bug

2009-07-02 Thread Tom

Hi everyone,

I'm either doing something wrong, or I've found a bug in  
NSPredicateEditor.


Whenever I use setObjectValue: on the NSPredicateEditor, it displays  
the new predicate, but if I change a couple of the operators (is,  
contains, begins with, etc) the text fields on the rows disappear.


Screenshot: http://www.tomdalling.com/wp-content/Picture-1.png
Demo project: http://www.tomdalling.com/wp-content/PredicateEditorBug.zip

Here is the relevant code:

-(IBAction) setPredicateEditorObjectValue:(id)sender
{

	NSPredicate* single = [NSPredicate predicateWithFormat:@"name ==  
'test'"];


NSMutableArray* subpredicates = [NSMutableArray array];
[subpredicates addObject:[[single copy] autorelease]];
[subpredicates addObject:[[single copy] autorelease]];
[subpredicates addObject:[[single copy] autorelease]];
[subpredicates addObject:[[single copy] autorelease]];  

	NSPredicate* compound = [NSCompoundPredicate  
orPredicateWithSubpredicates:subpredicates];


[m_predicateEditor setObjectValue:compound];

}

Am I doing something wrong?

--Tom
___

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

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

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

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


Re: User interface validation doesn't work, right?

2009-07-02 Thread Andy Lee
On Thursday, July 02, 2009, at 07:33PM, "Quincey Morris" 
 wrote:
>I really all makes sense, I think,

I think it makes the most sense if you figure out the validateMenuItem: 
mechanism, then figure out the validateToolbarItem: mechanism, then see they're 
closely related (no surprise, since menus and toolbars are supposed to echo 
each other), then come across validateUserInterfaceItem: as an attempt at a 
Unifying Theory as well as a fallback.

> although you could possibly argue  
>that the whole validation architecture is a bit whacked, and certain  
>argue that the documentation is royally whacked.

I remain optimistic that a cleaner, less confusing narrative can be told around 
validation.


On Thursday, July 02, 2009, at 08:38PM, "Quincey Morris" 
 wrote:
>We know that not every menu is validated all the time,

I think menus are validated (assuming autoenablesItems) when they are pulled 
down.  I forget where I get this from.

Toolbars are trickier, because they're visible all the time.  I think someone 
else referred to performance issues because this means toolbars have to be 
checked more often.

--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: Why Applespell.service fail to launch?

2009-07-02 Thread Dave Keck
This code works just fine for me:

NSLog(@"%@", NSStringFromRange([[NSSpellChecker
sharedSpellChecker] checkSpellingOfString: @"hello, hwo are you
today?" startingAt: 0]));

Which prints '{7, 3}', as expected. I'll go out on a limb and guess
that you're trying to access the spell checker from an atypical
context. Is this code failing in a bread-and-butter Cocoa app launched
from the Finder? Or are you doing something fancy like, say, writing a
launchd daemon or agent or something other than a 'normal' Cocoa app?

David
___

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

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

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

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


Why Applespell.service fail to launch?

2009-07-02 Thread shuang qin
Our application use Mac OS X spell checker service to do spell check.
here is sample code . [[NSSpellChecker sharedSpellChecker]
checkSpellingOfString:@"hello" startingAt:0];
But the problem is AppleSpell.service can not launch automatically by this
code, so there is always an alert: couldn't contact spell checker!
I try other applications (Openoffice.org, textEdit ) and they both can
launch AppleSpell.service automatically, I think it means, nothing wrong on
my machine.
Who can tell me how to force AppleSpell.service to launch? or is there a way
to check why AppleSpell.service fail to launch?
Thanks in advance!
___

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

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

Help/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: Determining OS at Runtime

2009-07-02 Thread Clark Cox
On Thu, Jul 2, 2009 at 4:33 PM, Dave DeLong wrote:
> One way that I've seen used is to do this:
>
> BOOL isLeopardOrBetter = YES;
> Class gcClass = NSClassFromString(@"NSGarbageCollector");
> if (gcClass == nil) { isLeopardOrBetter = NO; }

Don't do that. Check for the specific feature that you want to use.
I.e. this code is fine if you want to check for the presence of
NSGarbageCollector, however, that's exceeding unlikely, as you already
know whether or not your code supports GC at compile time.

-- 
Clark S. Cox III
clarkc...@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: User interface validation doesn't work, right?

2009-07-02 Thread Quincey Morris

Er, sorry about all the typos in the previous post on this subject.

On Jul 2, 2009, at 16:33, Quincey Morris wrote:

Something (presumabl[y] NSApp) presumabl[y] calls 'update' for the  
main NSMenu, and the 'update' calls trickle down to the NSMenuItems,  
which then initiate their own validation.


A similar thing presumably happens starting from a window[']s  
NSToolbar. The example laid out in this document pretty much  
explains how it's implemented, and it suggests you could add similar  
functionality to other classes by adding 'update' to them via a  
category.


On further reflection, neither of these statements can be exactly true.

We know that not every menu is validated all the time, so either the  
initiator of the validation process (NSApp? we don't know) filters out  
menus and menu items that don't currently need validating, or 'update'  
figures it out on a case-by-case basis.


Neither NSToolbar nor NSToolbarItem has an 'update' method, but they  
have 'validateVisibleItems' and 'validate' respectively, which seem to  
perform much the same role. It's curious that the strategy that the  
documentation explains (as an example) for automatic toolbar item  
validation *isn't* what toolbars actually use.


It remains totally mysterious what's going to cause individual  
validatable interface items to trigger their own validation. Perhaps  
there's no automatic general mechanism at all, and each interface item  
class has to solve the problem for itself. Or, the documentation could  
be construed to imply, any object in the responder chain that  
implements 'update' will be have its 'update' called automatically  
(when?), but that's more speculation than anything else.



___

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

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

Help/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: Determining OS at Runtime

2009-07-02 Thread Steve Christensen

On Jul 2, 2009, at 4:29 PM, Steve Christensen wrote:


On Jul 1, 2009, at 5:22 PM, Sherm Pendley wrote:

On Wed, Jul 1, 2009 at 7:24 PM,  
iseecolors wrote:
I need to support 10.4 in my application, but it uses some Carbon  
APIs that
are deprecated in 10.5 and I am using some new 10.5 APIs that  
require the

10.5 SDK.

I am sure I have seen this before, but I have been unable to find  
it in the
Archive.  How do I determine at runtime which OS version I am  
running on?


Just check for the presence of the function you want to call. In
Xcode, set your deployment target to 10.4, so that Leopard-only
symbols will be weak-linked. Then just check the symbol for NULL
before calling it:

if (SomeLeopardFunction != NULL) {
SomeLeopardFunction();
} else {
TigerFunction();
}


If you want to make sure that you don't include any "old" code in  
your executable when you decide to make 10.5 (for example) your  
base OS version, you could arrange your code like this:


#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
if (SomeLeopardFunction == NULL)
TigerFunction();
else
#endif
SomeLeopardFunction();

...then the compiler will take care of sorting out the details for  
you. If you use that sequence in several places, it might even be  
worthwhile to create an inline wrapper function in a header file so  
the OS-specific details are kept in one place:


inline void SomeFunction()
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
if (SomeLeopardFunction == NULL)
TigerFunction();
else
#endif
SomeLeopardFunction();
}


After I sent the message, I realized that a better situation for your  
case would be to use


#ifndef NSAppKitVersionNumber10_5
#define NSAppKitVersionNumber10_5 949
#endif

if (NSAppKitVersionNumber < NSAppKitVersionNumber10_5)
...

since it will only use the Tiger method on Tiger.

steve

___

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

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

Help/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 and writing rtf(d) files

2009-07-02 Thread Ali Ozer
TextEdit sources in /Developer/Examples/AppKit/TextEdit may be  
useful.  TextEdit's document types are set up to read/write RTF and  
RTFD, in addition to a number of other types.

Ali


On Jul 2, 2009, at 14:04 , Ian Piper wrote:


bump bump :-)

Ian.
--
ianpi...@mac.com
07590 685840 | 01926 811383


Begin forwarded message:


From: Ian Piper 
Date: 1 July 2009 3:53:52 pmBST
To: Cocoa-dev@lists.apple.com
Subject: Reading and writing rtf(d) files

Hi all,

I have a question about reading and writing file types. I have been  
following an old Apple text editor example (http://developer.apple.com/documentation/Cocoa/Conceptual/TextArchitecture/Tasks/TextEditor.html 
), and want to extend it to allow me to read and write rtf files.  
At least, I want it to be able to round-trip rich text files with  
TextEdit. From the example:


"At this stage of its development, your editor opens and saves  
documents only with an extension of . To enable your  
application to save and open documents with a recognized file type,  
you need to use Xcode to configure the application’s document types  
settings as described in “Storing Document Types Information in the  
Application's Property List” in Document-Based Applications  
Overview. For complete details about application property lists,  
see Runtime Configuration Guidelines."


I read the documents, and an example from 2001 by Mike Beam () and  
also looked at the settings for the TextEdit example. I ended up  
setting it like so:


Creator: ttxt

Name: DocumentType
Extensions: rtfd
MIME Types: text/rtfd
OS Types: rtfd

My program writes files with rich content and reads them OK. But it  
won't read rtfd files that I have created elsewhere (I can select  
such files but they just don't open - nothing happens). Also,  
TextEdit will read files that I have created using my editor, but  
they are in plain text with lots of tutti-frutti.


Can anyone point me to an example that describes how I am supposed  
to tell my application that it should read and write rtf (or rtfd)  
files?


Ian.
--
ianpi...@mac.com
07590 685840 | 01926 811383


___

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

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

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

This email sent to ao...@apple.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: Private copy not working correctly

2009-07-02 Thread Adam R. Maxwell


On Jul 2, 2009, at 12:05 PM, Joe Turner wrote:

I'm trying to create a private copy of an object, but yet when the  
original changes, my copy changes too.
I have an array of dictionaries called spacesData. Then, when I do:  
NSDictionary *backup = [[spacesData objectAtIndex:index] copy];  
everything is fine, and this one looks as it should. Then, when I  
change something in spacesData objectAtIndex:index], this private  
copy changes too. Doesn't "copy" create a private copy, or am I  
doing something wrong?


Copying a collection makes a shallow copy, so only the collection  
itself is copied, not the values that it contains.  If you want to  
copy values, check out -[NSDictionary initWithDictionary:copyItems:],  
or CFPropertyListCreateDeepCopy().


--
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: disabling grammar checking

2009-07-02 Thread kvic...@pobox.com

At 6:57 PM -0700 6/29/09, Martin Wierschin wrote:
i'm not happy that the framework is changing the name of my menu 
item from "Show SpellingS" (as i've specified in IB) to "Show 
Spelling and Grammar". is there some way to globally "fix" this? (i 
know i can provide my overrides of showGuessPanel: and 
validateMenuItem: in specific field editors, etc., but i'm hoping 
for something that doesn't require me to provide a custom field 
editor only to fix this.)


I think the best solution is to change the menu item's action to a 
selector only you know about, eg: "showKensSpellingPanel:". You 
could add a category to NSTextView that simply forwards the action 
to the normal "showGuessPanel:". Validation wouldn't work though, 
unless you want to swizzle the validator method for NSTextView.


Perhaps it would be best to have something higher up the responder 
chain exclusively pick up your custom action, say an NSApplication 
delegate. That could inspect the first responder and do validation 
as necessary.


this worked fine.
thanx,
ken



It's an unfortunately messy thing any way you do it, especially for 
such a trifle.


agreed! :-(



~Martin



___

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

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

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

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


Re: User interface validation doesn't work, right?

2009-07-02 Thread Quincey Morris

On Jul 2, 2009, at 14:05, Andy Lee wrote:

Hm, you know what, it seems odd to me that the  
NSValidatedUserInterfaceItem protocol doesn't include setEnabled: or  
some such.  The doc says, "If no responder returns YES, the item is  
disabled."  But how can the application know it *can* disable the  
item, much less *how*, unless the item is guaranteed to implement  
setEnabled:?


The answer to this is [obscurely] in the documentation:

	http://developer.apple.com/documentation/Cocoa/Conceptual/UIValidation/Articles/implementingValidation.html#/ 
/apple_ref/doc/uid/TP40006268


"Before it is displayed, a user interface item checks to see if its  
target implements validateUserInterfaceItem:. If it does, then the  
enabled status of the item is determined by the return value of the  
method. You can therefore conditionally enable or disable an item by  
implementing validateUserInterfaceItem: in the target  
object." [quote #1]


IOW, it's intended that the object conforming to  
NSValidatedUserInterfaceItem should initiate its own validation by  
calling validateUnserInferfaceItem. It enables or disables itself by  
examining the return value, so it doesn't need an "enabled" property  
that can be set externally to it.


If the above is true, then I think it pretty much clears up a lot of  
the confusion generated in this thread.


However, there's more. Both of the protocol reference documents say  
this:


	http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSValidatedUserInterfaceItem_Protocol/Reference/Reference.html#/ 
/apple_ref/doc/uid/2467


By conforming to this protocol, your control can participate in this  
validation mechanism. To validate a control, the application calls  
validateUserInterfaceItem: for each item in the responder chain,  
starting with the first responder. If no responder returns YES, the  
item is disabled. For example, a menu item that sends the copy:  
action message would disable itself if no responder in the responder  
chain can be copied. [quote #2]


If "the application calls validateUserInterfaceItem: for each item in  
the responder chain" is understood to mean that something (e.g. NSApp)  
makes all the calls from a loop, then it clearly contradicts quote #1.


In fact, the answer can be deduced from:

	http://developer.apple.com/documentation/Cocoa/Conceptual/UIValidation/Articles/ValidatingObjects.html#/ 
/apple_ref/doc/uid/2745


Menus and menu items respond to an "update" method that triggers the  
validation process. Something (presumable NSApp) presumable calls  
'update' for the main NSMenu, and the 'update' calls trickle down to  
the NSMenuItems, which then initiate their own validation.


A similar thing presumably happens starting from a windows NSToolbar.  
The example laid out in this document pretty much explains how it's  
implemented, and it suggests you could add similar functionality to  
other classes by adding 'update' to them via a category.


IOW, quote #2 is plain wrong -- nothing directly calls  
validateUserInterfaceItem: for each item in the responder chain.  
Probably, something calls 'update' for everything in the responder  
chain that implements 'update', but we don't really know how that works.


I really all makes sense, I think, although you could possibly argue  
that the whole validation architecture is a bit whacked, and certain  
argue that the documentation is royally whacked.



___

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

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

Help/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: Determining OS at Runtime

2009-07-02 Thread Dave DeLong

One way that I've seen used is to do this:

BOOL isLeopardOrBetter = YES;
Class gcClass = NSClassFromString(@"NSGarbageCollector");
if (gcClass == nil) { isLeopardOrBetter = NO; }

Cheers,

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: Determining OS at Runtime

2009-07-02 Thread Steve Christensen

On Jul 1, 2009, at 5:22 PM, Sherm Pendley wrote:

On Wed, Jul 1, 2009 at 7:24 PM,  
iseecolors wrote:
I need to support 10.4 in my application, but it uses some Carbon  
APIs that
are deprecated in 10.5 and I am using some new 10.5 APIs that  
require the

10.5 SDK.

I am sure I have seen this before, but I have been unable to find  
it in the
Archive.  How do I determine at runtime which OS version I am  
running on?


Just check for the presence of the function you want to call. In
Xcode, set your deployment target to 10.4, so that Leopard-only
symbols will be weak-linked. Then just check the symbol for NULL
before calling it:

if (SomeLeopardFunction != NULL) {
SomeLeopardFunction();
} else {
TigerFunction();
}


If you want to make sure that you don't include any "old" code in  
your executable when you decide to make 10.5 (for example) your base  
OS version, you could arrange your code like this:


#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
if (SomeLeopardFunction == NULL)
TigerFunction();
else
#endif
SomeLeopardFunction();

...then the compiler will take care of sorting out the details for  
you. If you use that sequence in several places, it might even be  
worthwhile to create an inline wrapper function in a header file so  
the OS-specific details are kept in one place:


inline void SomeFunction()
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
if (SomeLeopardFunction == NULL)
TigerFunction();
else
#endif
SomeLeopardFunction();
}


steve

___

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

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

Help/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: Changing content of object inside NSMutableArray

2009-07-02 Thread Nick Zitzmann


On Jul 2, 2009, at 4:36 PM, Agha Khan wrote:


This works, but this is not changing the content inside the GameArray.

How this can be done.



Use -replaceObjectAtIndex:withObject:. You are responsible for  
maintaining your own arrays; changing a pointer will not change the  
contents of the array.


Nick Zitzmann


___

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

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

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

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


Re: documenting bindings (was: Re: Dynamically loading a part of a Window in Cocoa)

2009-07-02 Thread Kyle Sluder
On Thu, Jul 2, 2009 at 2:25 PM, Andy Lee wrote:
> My first reaction was: "Elegantly put!"  But then I thought, isn't *not* 
> generating this kind of code one of the reasons we tell people nibs are good? 
>  Wouldn't a .m be a good place to "document" targets and actions as well?  
> And delegates and other outlets?  Or do you think there's something about 
> bindings that makes them subtle enough that for *them*, in some cases, it 
> might make sense to "document" them by coding them?

If you've decided that it will be better for the long-term health of
your application to document your bindings, it really isn't that hard
to do it in code rather than a text file.  I mean how is this:

nameTextField.value -> [Array Controller].arrangedObjects.name
|- Value Transformer: CapitalizeTransformer
|- Null Placeholder: 
|- Multiple values placeholder: 

all that different from this:

- (void)awakeFromNib {
  [nameTextField bind:@"value" toObject:arrayController
withKeyPath:@"arrangedObjects.name" options:
[NSDictionary dictionaryWithObjectsAndKeys:
  @"CapitalizeTransformer", NSValueTransformerNameBindingOption,
  @"", NSNullPlaceholderBindingOption,
  @"", NSMultipleValuesPlaceholderBindingOption, nil]];
}

The important point is that your binding setup needs to get
complicated enough to warrant documentation in the first place -- from
there the extra effort required to get your documentation to compile
is trivial compared to the effort of documentation in the first place.
 Target-action setups rarely get this complicated; most of the time
you just wire up your controls to First Responder.

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


Changing content of object inside NSMutableArray

2009-07-02 Thread Agha Khan

HI

I have saved some objects inside GameArray (type NSMutableArray) and I  
would like to change of content of an object inside that array.


GameObj is type of UIView so it has a frame.

GameObj* p = [GameArray objectAtIndex:0];
p.frame = frame;

This works, but this is not changing the content inside the GameArray.

How this can be done.

Any help will be very much appreciated.

Best regards
-Agha
___

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

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

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

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


probablem with NSView redisplay.

2009-07-02 Thread Mac First
I have an NSWindowController driving a window, with a view, with  
subviews.  One of the subviews is an NSView *imageParentView. This  
view's only purpose is to provide a frame, a "bounding box" inside  
which its subview will be held.  It's one and only subview is  
NSImageView *imageView.


The purpose is for imageView -- which displays a 1700x800 image -- to  
move around inside of imageParentView, which limits things to a  
"peephole" view of a 100x100 area.  Thus, I create a flip-book style  
animation from a larger image.  Elsewhere in the main view, I have a  
slider and some controls to move "next/prev", etc.


Below is the code I call after my animationFrame variable has been  
updated (say, by the NEXT or PREV buttons.)  My problem is: SOME OF  
THE TIMES, it all works, and works perfectly.  But SOMETIMES, I'll run  
the app, and I'll see the 1st image but, after advancing the counter,  
subsequent images do not redraw.  This works/does-not-work dichotomy  
does not require code or xib changes -- sometimes I just give up on it  
for a day, come back the next day, and everything works fine.


My animationFrameLabel -- the thing that tells me which  
"frame" (column/row of the bigger image) should be displaying --  
updates, so I know all the code is happening.


On the times when the updates are not visible, even covering and  
uncovering the window (hoping to force a redraw) does not help.


...But sometimes the program just works flawlessly.

Am I missing some key call?  What's going on?

Thanks!

--- Code ---

 - (void)displayAnimationFrame {
int xx = (animationFrame % animationColumns);
int yy = (animationFrame / animationColumns);

[animationFrameLabel setStringValue:[NSString  
stringWithFormat:@"{ %d, %d }", xx, yy]];


[self adjustAnimationSlider];

// Move imageView within imageParentView
NSRect iParentViewFrame = imageParentView.frame;
CGFloat xStart = iParentViewFrame.size.width  * xx;
CGFloat yStart = iParentViewFrame.size.height * yy;

NSRect imageViewBounds = imageView.bounds;
imageViewBounds.origin.x = xStart;
imageViewBounds.origin.y = yStart;
NSLog(@"origin: %0.1f,%0.1f", imageViewBounds.origin.x,  
imageViewBounds.origin.y);
NSLog(@"..size: %0.1fx%0.1f", imageViewBounds.size.width,  
imageViewBounds.size.height);

[imageView setBounds:imageViewBounds];

[imageView setNeedsDisplay];
[imageParentView setNeedsDisplay:YES];
 }


--- Log output ---

2009-07-02 15:09:49.756 app[35064:10b] origin: 100.0,0.0
2009-07-02 15:09:49.757 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:50.267 app[35064:10b] origin: 200.0,0.0
2009-07-02 15:09:50.268 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:50.533 app[35064:10b] origin: 300.0,0.0
2009-07-02 15:09:50.533 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:50.715 app[35064:10b] origin: 400.0,0.0
2009-07-02 15:09:50.715 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:50.907 app[35064:10b] origin: 500.0,0.0
2009-07-02 15:09:50.907 app[35064:10b] ..size: 1699.8x799.9
2009-07-02 15:09:51.093 app[35064:10b] origin: 600.0,0.0
2009-07-02 15:09:51.093 app[35064:10b] ..size: 1699.8x799.9

___

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

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

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

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


documenting bindings (was: Re: Dynamically loading a part of a Window in Cocoa)

2009-07-02 Thread Andy Lee
On Thursday, July 02, 2009, at 11:39AM, "Michael Ash"  
wrote:
>On Wed, Jul 1, 2009 at 11:18 PM, Marco S Hyman wrote:
[...]
>> That leads directly to something I've been thinking about as one new to
>> cocoa:
>> how do you document your bindings?   Any preferred formats other than a text
>> file stuck somewhere in a project?
>
>If you're going to stick your bindings in a text file, why not stick
>them in a text file which happens to end in .m, and document them in a
>format that the compiler can understand? In other words, why not just
>make your bindings in code? Then you can easily see them, you can
>comment them to your heart's content, you can search for them, and all
>the other benefits of having stuff not be in your nib.

My first reaction was: "Elegantly put!"  But then I thought, isn't *not* 
generating this kind of code one of the reasons we tell people nibs are good?  
Wouldn't a .m be a good place to "document" targets and actions as well?  And 
delegates and other outlets?  Or do you think there's something about bindings 
that makes them subtle enough that for *them*, in some cases, it might make 
sense to "document" them by coding them?

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


screen lock events?

2009-07-02 Thread Carl Harris
Are there events that I can observe that indicate when the screen lock  
has activated/deactivated?  I have a background agent that should  
really be disabled when the screen is locked...


Thanks for any pointers...

--
Carl Harris
cehar...@vt.edu
___

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

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

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

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


Re: User interface validation doesn't work, right?

2009-07-02 Thread Andy Lee
On Thursday, July 02, 2009, at 01:52PM, "Bill Cheeseman"  
wrote:
>On Jul 2, 2009, at 12:24 PM, Keary Suska wrote:
>
>> Because the two protocols in question are formal protocols, the  
>> @interface declaration must specify conformance. If it doesn't, then  
>> no assumption of conformance should be made. Pure and simple. Also,  
>> protocol conformance is not inheritable in Objective-C.
>
>1. Taking that last point first, the Objective-C 2.0 Programming  
>Language document says this: "A class is said to conform to a formal  
>protocol if it adopts the protocol or inherits from another class that  
>adopts it." I believe, without checking, that this was true in 1.0,  
>also. I take that to mean that protocol conformance is in fact  
>inherited.

You are right on this one.  Besides being what one would expect (what I would 
expect, anyway), sending conformsToProtocol: to the subclass easily confirms it.

>Now here's my question for you: In my controller's implementation of - 
>validateUserInterfaceItem:, I can either limit the items that I enable/ 
>disable by checking whether their class is NSButton (which I know  
>responds to -action and -setEnabled:, and I can confirm that  
>programmatically). Or, instead, I can limit the items by checking  
>whether they conform to the NSValidatedUserInterfaceItem protocol.

If I may chime in (despite the fact that the question was for Keary): as you go 
on to point out, this brings us right back to "What does it mean to conform?"  
All the evidence indicates that Cocoa sends a conformsToProtocol: message.  
Note that NSButton returns NO for this despite implementing the methods in 
question.  This distinction matters because a protocol is slightly more than "a 
promise that certain methods are implemented" -- it's also a way of stamping a 
class such that you can ask at runtime, "Does class X have 'Y' stamped on it?"  
You could have a protocol with no methods for this very purpose.  (I feel like 
there is a common example of this in Cocoa but I can't think of it offhand, so 
I might be wrong.)

To look at it another way: suppose you wanted NSButton to implement -action and 
-tag methods for some other reason, but *not* be validated by this mechanism.  
The way to do it would be precisely what Apple's done: go ahead and implement 
the methods, but don't "stamp" NSButton as an NSValidatedUserInterfaceItem.

Getting back to your problem -- I personally would check whether the class is 
NSButton.  Although at first glance I would have rejected this as a kludge, it 
is not only the simplest solution that achieves your goals and expresses your 
intent, it is what you would be doing anyway by creating the NSButton subclass. 
 Instead of having code that checks for NSButtons at runtime, you would be 
manually picking out the instances of NSButton in your nib.

>But NSControl does not implement - 
>setEnabled:

Hm, you know what, it seems odd to me that the NSValidatedUserInterfaceItem 
protocol doesn't include setEnabled: or some such.  The doc says, "If no 
responder returns YES, the item is disabled."  But how can the application know 
it *can* disable the item, much less *how*, unless the item is guaranteed to 
implement setEnabled:?

Bill, although I think you are clearly wrong on some technical points, I agree 
wholeheartedly that the docs on validation need significant improvement, and I 
hope anyone else who agrees will file a Radar so it isn't just you and me.

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


Reading and writing rtf(d) files

2009-07-02 Thread Ian Piper

bump bump :-)

Ian.
--
ianpi...@mac.com
07590 685840 | 01926 811383


Begin forwarded message:


From: Ian Piper 
Date: 1 July 2009 3:53:52 pmBST
To: Cocoa-dev@lists.apple.com
Subject: Reading and writing rtf(d) files

Hi all,

I have a question about reading and writing file types. I have been  
following an old Apple text editor example (http://developer.apple.com/documentation/Cocoa/Conceptual/TextArchitecture/Tasks/TextEditor.html 
), and want to extend it to allow me to read and write rtf files. At  
least, I want it to be able to round-trip rich text files with  
TextEdit. From the example:


"At this stage of its development, your editor opens and saves  
documents only with an extension of . To enable your application  
to save and open documents with a recognized file type, you need to  
use Xcode to configure the application’s document types settings as  
described in “Storing Document Types Information in the  
Application's Property List” in Document-Based Applications  
Overview. For complete details about application property lists, see  
Runtime Configuration Guidelines."


I read the documents, and an example from 2001 by Mike Beam () and  
also looked at the settings for the TextEdit example. I ended up  
setting it like so:


Creator: ttxt

Name: DocumentType
Extensions: rtfd
MIME Types: text/rtfd
OS Types: rtfd

My program writes files with rich content and reads them OK. But it  
won't read rtfd files that I have created elsewhere (I can select  
such files but they just don't open - nothing happens). Also,  
TextEdit will read files that I have created using my editor, but  
they are in plain text with lots of tutti-frutti.


Can anyone point me to an example that describes how I am supposed  
to tell my application that it should read and write rtf (or rtfd)  
files?


Ian.
--
ianpi...@mac.com
07590 685840 | 01926 811383


___

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

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

Help/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: Debugging NSService

2009-07-02 Thread Laurent Cerveau

Hi Peter

Thanks for the tips. I ended up finding that yes the Service was  
appearing but in Finder only. I think the main confusion was between  
the steps of having the service appear in the menu and the service  
menu item being enabled or not.  It looks like a trick to simply  
appear is, for some apps (like in Pasteboard Peeker example) to  
declare NSStringPboardType.


Best

laurent

On Jun 25, 2009, at 11:40 PM, Peter Ammon wrote:


Hi Laurent,

There are a number of reasons why your Service may not appear in the  
menu.  Off the top of my head:


1) Your send and receive types may not be handleable by anything in  
the app.  In particular, NSFilenamesPboardType is not vended by  
NSTextView, so I would expect your Service to appear in the Finder,  
but not other places.  Did you check in the Finder?


2) Your Info.plist may be malformed.  On Leopard, I don't think  
there's any indication of this - it will just silently fail.  plutil  
can check for syntax errors, but I don't think there's any way to  
look for e.g. a dictionary where there should be an array, on Leopard.


3) LaunchServices may be picking up a different version of your app  
than you expect.  If multiple apps with the same bundle ID all try  
to vend Services, only one will win.  Ensure there's no other copies  
of your app on the boot volume.


4) Your app may not have been found by LaunchServices at all.   
Launching it from the Finder will ensure it gets registered.


5) pbs may not have run.  Logging out and back in should make it run  
again.


As Malcolm says, if you have access to the SnowLeopard seed, you'll  
find that Services easier to debug, with the 10.6 version of  
Services documentation describing debugging techniques.



On Jun 25, 2009, at 11:49 AM, Laurent Cerveau wrote:

Simply retrying to see if there could be any idea on this one as I  
still have trouble getting success


Thanks for the help

laurent





___

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

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

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

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


Re: How a subview can inform to the controler that an event has happened?

2009-07-02 Thread WT

On Jul 2, 2009, at 9:40 PM, Agha Khan wrote:

I am looking the sample Dragging views (The iPhone Developer's  
Cookbook) where the are N subviews (flowers) are floating inside  
UIViewController.


The subviews are not "floating inside" the view controller. Views are  
subviews only to other views, forming what is called the View  
Hierarchy. The view controllers are not part of the view hierarchy.


how subview can inform to UIViewController that the dragging (an  
event) has finished?


Implement the method

- (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event

in the view's view controller. The view controller participates in the  
Responder Chain and touch events that are not consumed by the view are  
passed to the view's view controller for processing.


Wagner
___

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

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

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

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


How a subview can inform to the controler that an event has happened?

2009-07-02 Thread Agha Khan
I am looking the sample Dragging views (The iPhone Developer's  
Cookbook) where the are N subviews (flowers) are floating inside  
UIViewController.
It is a sample and working, but how subview can inform to  
UIViewController that the dragging (an event) has finished?


-Agha 
___


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

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

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

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


Private copy not working correctly

2009-07-02 Thread Joe Turner

Hello,

I'm trying to create a private copy of an object, but yet when the  
original changes, my copy changes too.
I have an array of dictionaries called spacesData. Then, when I do:  
NSDictionary *backup = [[spacesData objectAtIndex:index] copy];  
everything is fine, and this one looks as it should. Then, when I  
change something in spacesData objectAtIndex:index], this private copy  
changes too. Doesn't "copy" create a private copy, or am I doing  
something wrong?


Any help would be appreciated,

Joe
___

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

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

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

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


Re: NSTableView bug?

2009-07-02 Thread Tito Ciuro

On 2 Jul 2009, at 11:10 AM, Greg Guerin wrote:

Hold down the Option key and drag the thumb.  It should "micro  
scroll" for as long as Option remains down.  This scroller gesture  
modifier has been around for a while.


Wow. Never heard about this one before. I wonder how many people know  
about this rather obscure feature?


-- Tito
___

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

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

Help/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: NSDocument's -close method calls itself?

2009-07-02 Thread Quincey Morris

On Jul 2, 2009, at 10:34, Sean McBride wrote:


I'm trying to find somewhere to undo what was done in my NSDocument
subclass' initializer.  Specifically, to start/stop KVO  
observation.  It

seemed like 'close' would be a good place.


'close' isn't a good place, because it isn't necessarily called. If  
you look at the Leopard Developer Release Notes:


http://developer.apple.com/releasenotes/Cocoa/AppKit.html

in the section entitled "Advice for Overriders of Methods that Follow  
the delegate:didSomethingSelector:contextInfo: Pattern", you'll find a  
nice little code snippet that happens to show you where to place code  
that should execute just before a document closes:



if (shouldClose) {
		// Here we can do all sorts of things with this document that's  
about to be closed.

}


Does that help?


___

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

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

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

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


Windows on main thread always only sometimes?

2009-07-02 Thread Jack Repenning
I've always been taught that one must only create and run AppKit  
objects on the main thread. Recently, though, over in objc-language,


  http://lists.apple.com/archives/Objc-language/2009/Jul/msg2.html

it was pointed out that the threading Programming Guide seems to say  
otherwise:


 says:
"You can create a window on a secondary thread. The Application Kit  
ensures that the data structures associated with a window are  
deallocated on the main thread to avoid race conditions. There is  
some possibility that window objects may leak in an application that  
deals with a lot of windows concurrently. You can create a modal  
window on a secondary thread. The Application Kit blocks the calling  
secondary thread while the main thread runs the modal loop."
But now I notice this only says you can *create* windows from  
secondary threads; it doesn't explicitly allow any other action, and  
it even refers to several automatic insurances that other things  
happen on the main thread.


So what *are* the rules? Is the Thread Safety Summary implicitly  
strict, "you can create a window, but absolutely nothing else"? Or is  
there some set of other operations that are permitted from the  
secondary (and where do I learn those)?


(This may already have been discussed on this list ... surely ... I  
tried to search it out first, but unfortunately every message in the  
archives matches "thread," due to the navigation links! If so, sorry.)


-==-
Jack Repenning
jackrepenn...@tigris.org
Project Owner
SCPlugin
http://scplugin.tigris.org
"Subversion for the rest of OS X"


___

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

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

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

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


CoreData - $FETCH_SOURCE and fetched properties (coredata newby)

2009-07-02 Thread Jose P.

Hi everybody


Here, a CoreData novice, stumped at a fairly simple issue, a bit under- 
documented by apple (Apple under-documenting? uh?).

If anyone can give me a hint, I'll be much in debt.

Well, the thing is about $FETCH_SOURCE and a Fetched property in Core  
Data.


I create two entities (xA and xB), and I want one of them to be linked  
as a fetched property of the other (xB has the fetched propery fXA).  
In the model builder, I create a fetched property with the type/ 
destination of the other (fXA is of type xA). One of them has an  
indexed number property (xA has xAitemId property, indexed), so fXA  
should have a predicate containing xAitemId. Then xB has a property  
that refers to xA: it should find its matching xA by looking at  
itself, as it contains a property  xAitemIdinXB, with the same format  
as xAitemId and it is known that xAitemIdinB has a corresponding  
xAitemId, existing at least one xA managed object instance with  
xAitemId = xAitemIdinB.


Well, as far as I know, the fetched property of destination xA called  
fXA built in xB shoul contain the predicate (Expression):

xAitemId == $FETCH_SOURCE.xAitemIdinB
Not even writing the referral directly: xAitemId = 435345. The object  
NSLog always lists the property fXA in a xB instance as

fXA = "";

Am I wrong at the predicates?

Thanks for reading, everyone.
Regards,
Jose
___

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

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

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

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


Drag and Drop UI

2009-07-02 Thread Jay Kickliter
I've been working on some ground station software for controlling  
amateur UAV's. I have the basic functionality working, but I'd like to  
make it more generic so other people can configure it without having  
to recompile.


My thoughts are to have a palette of UI elements, suck as dials,  
artificial horizons, sliders, that the user can drop in the screen and  
bind to telemetry variables. Is there are any open-source code  
demonstrating anything similar to this, not for telemetry per se, but  
dynamic UI elements that can be dragged around?


thanks,

Jay
___

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

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

Help/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: Sorting on a table view of a managed object - debugger throws exception

2009-07-02 Thread Quincey Morris

On Jul 2, 2009, at 09:41, Steve Cronin wrote:


BUT it is not what is happening in this case.


Do you in fact have a "code" property? On the app delegate? What's  
does it's @property (or accessor prototype) look like?



___

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

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

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

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


Why I have to set position at the middle?

2009-07-02 Thread Agha Khan

Hi
I am new to Apple programming.

I have UIView and it has CALayer (numberLayer). I would like to write  
something at the middle of that layer.


So in my

- (id)initWithFrame:(CGRect)frame function I write somthing like this.

CGRect viewRect = [self bounds];
		CGPoint center = CGPointMake(viewRect.size.width / 2.0,  
viewRect.size.height / 2.0);

numberLayer = [[NumberLayer alloc] init];
		numberLayer.position = center; // I think it should be  
CGPointMake(0,0);

numberLayer.bounds = viewRect;
[self.layer addSublayer: numberLayer];

Well for so good.

In my layer
-(void) drawInContext:(CGContextRef)ctx
{
CGRect rect = [self bounds];

 CGContextSaveGState(ctx);

CGContextTranslateCTM(ctx, 0.0, rect.size.height);
CGContextScaleCTM(ctx,1.0, -1.0);

CGContextClearRect(ctx, rect);
	CGPoint center = CGPointMake(rect.size.width / 2.0,  
rect.size.height / 2.0);

//  CGPoint center = CGPointMake(0,0.0);
CGContextSelectFont(ctx, "Times New Roman", 16, kCGEncodingMacRoman);
	CGContextShowTextAtPoint(ctx, center.x, center.y, "Hello",  
strlen("Hello"));

CGContextRestoreGState(ctx);
}
The text is at right position.
It works fine, but why I have to set position at the middle?

Best regards
-Agha

___

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

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

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

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


Re: NSTableView bug?

2009-07-02 Thread Greg Guerin

Tito Ciuro wrote:

Not to mention that dragging the scroll thumb one pixel will result  
in thousands of rows scrolled at once. Simply useless.
Hold down the Option key and drag the thumb.  It should "micro  
scroll" for as long as Option remains down.  This scroller gesture  
modifier has been around for a while.


I still agree with the basic criticism: a huge scrolling table of hex  
isn't a great view.  I don't think option-modified micro-scrolling  
greatly improves it, either.  At best, it prevents the scroll thumb  
from being useless.  Damning by faint praise.


  -- GG
___

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

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

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

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


Re: User interface validation doesn't work, right?

2009-07-02 Thread Bill Cheeseman

On Jul 2, 2009, at 12:24 PM, Keary Suska wrote:

Because the two protocols in question are formal protocols, the  
@interface declaration must specify conformance. If it doesn't, then  
no assumption of conformance should be made. Pure and simple. Also,  
protocol conformance is not inheritable in Objective-C.


1. Taking that last point first, the Objective-C 2.0 Programming  
Language document says this: "A class is said to conform to a formal  
protocol if it adopts the protocol or inherits from another class that  
adopts it." I believe, without checking, that this was true in 1.0,  
also. I take that to mean that protocol conformance is in fact  
inherited. That makes sense, because a protocol is simply a promise  
that certain methods are implemented, and implemented methods are  
inherited by subclasses.


2. The key question for me is your first point.

The way I work around the lack of automatic validation for buttons is  
this: In my window controller, I implement -validateUserInterfaceItem:  
and declare that my controller conforms to the  
NSUserInterfaceValidations protocol. That's exactly what NSDocument  
does, as I understand it. Since user interface items are not  
automatically validated, I force validation by implementing NSWindow's  
-windowDidUpdate: delegate method so that it loops through all  
subviews of the window calling my controller's - 
validateUserInterfaceItem: protocol method. (I could use something  
other than -windowDidUpdate: to trigger the protocol method if  
efficiency becomes an issue, but at this point doing it every time the  
window updates works just fine. I am aware that Apple is struggling  
with efficiency concerns in automatic validation of toolbar items.)


Now here's my question for you: In my controller's implementation of - 
validateUserInterfaceItem:, I can either limit the items that I enable/ 
disable by checking whether their class is NSButton (which I know  
responds to -action and -setEnabled:, and I can confirm that  
programmatically). Or, instead, I can limit the items by checking  
whether they conform to the NSValidatedUserInterfaceItem protocol. If  
I do the latter, I have to declare a subclass of NSButton and declare  
that it conforms to the protocol because NSButton does not itself  
declare conformance, and of course I have to set the type of my  
buttons to my subclass type in Interface Builder. Either technique  
works (I know because I've already done it), but testing for  
compliance with the NSValidatedUserInterfaceItem protocol somehow  
seems purer to me.


But then, as you point out, I am arrogating to myself the decision  
whether NSButton conforms to the protocol. It clearly does, in my  
view, because it inherits -action and -tag methods from NSControl, and  
I know they work. Therefore I don't have to reimplement them in my  
subclass of NSButton, although I am perfectly entitled under the rules  
of the language to re-implement them myself if I choose to do so. If I  
did re-implement them in my subclass, I would have every right to  
declare that my subclass conforms to the protocol, because I own my  
subclass. Implementing those two methods is all that conformance  
requires. Objecting to this approach if I simply rely on inheriting  
NSControl's implementations of -action and -tag seems like it's  
elevating form over function. In other words, I view NSButton's  
failure to declare conformance to be a bug.


Now, by my logic, NSControl also conforms, because that's where - 
action and -tag are declared. But NSControl does not implement - 
setEnabled:, so it wouldn't make any sense as a practical matter.  
That's just another way of saying that the  
NSValidatedUserInterfaceItem protocol is itself faulty, because it  
does not promise that a conforming class can actually enable/disable  
itself. (The problem is that different user controls that can be  
enabled/disabled use methods with different signatures, such as  
segmented controls. Therefore, to make my approach foolproof, I have  
to check not only for an item's conformance to the protocol, but also  
whether it responds to the -setEnabled: selector and any other  
selector that I know enables/disables a user control I care about.)


Where would you come out on this question? From your comments, I  
assume you would say I should not subclass NSButton and declare it as  
conforming. Then I would have to simply check whether the class of an  
item is the NSButton class. You might also insist that I should not  
name my validation method -validateUserInterfaceItem:, but something  
else such as -updateWindow, because I risk confusing people about what  
my controller really does. In that case, I'm back where most Cocoa  
applications were before Cocoa bindings were invented, declaring a  
custom -updateWindow method and calling it from -windowDidUpdate or  
whatever.


I would prefer to do things the NSUserInterfaceValidations way, so  
that I'm ready when Apple gets

NSDocument's -close method calls itself?

2009-07-02 Thread Sean McBride
Hi all,

I'm trying to find somewhere to undo what was done in my NSDocument
subclass' initializer.  Specifically, to start/stop KVO observation.  It
seemed like 'close' would be a good place.

First, should/must one call super in one's 'close' implementation?  It
seems so.

After trying this, I've found a problem.  My document has several window
controllers and I've discovered that if I have several windows open then
close the main document window, that I end up in my 'close' method twice:

#0 -[MyProjectDocument close] // <---
#1 -[NSWindowController _windowDidClose] ()
#2 -[NSDocument close] ()
#3 -[MyProjectDocument close] // <---
#4 -[NSWindowController _windowDidClose] ()
#5 -[NSDocument _closeAlertSheet:wasPresentedWithResult:inContext:] ()
#6 -[NSAlert didEndSheet:returnCode:contextInfo:] ()
#7 -[NSApplication endSheet:returnCode:] ()

- (void)close
{
[controller removeObserver:];

[super close];
}

Frame 3 is as I expect. I call removeObserver, then call super (frame
2).  Then AppKit brings me back to my close method (frame 0) and I
proceed to call removeObserver again, which throws an exception.

So where can I tear down what was done in init?  (Note: I can't use
dealloc because this is a GC app.)

Thanks,

--

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


___

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

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

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

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


Re: NSTableView bug?

2009-07-02 Thread Scott Andrew
I was going to recommend 0xED is a good one too. Very fast and he  
appears to be using a custom view of somesort.


Scott

On Jul 2, 2009, at 10:21 AM, Jean-Daniel Dupas wrote:

I've created a simple application with an NSTableView. I have  
written a delegate for this table,  
numberOfRowsInTableView:objectValueForTableColumn:row:, that  
returns the number of rows in the table when requested.


My application uses the table view to display hexadecimal data on a  
flash memory chip, with 16 bytes displayed per row. As a test, I  
tried returning a large number for the number of rows, 0x100.  
When I scroll through the table, everything looks okay for the  
first 14 million rows or so, after which the gray horizonal cell  
separator disappears and the row data begins to shift by a pixel  
per row, until it eventually is superimposed on the row above it.  
This seems like a bug with the NSTableView class, but perhaps I'm  
doing something wrong. Has anyone else run into this problem?


My 2 cents,

If you're looking for a (very) efficient and clean way to display  
large amount of binary data, have a look at HexFiend. This is the  
fastest hex editor I know. It's able to handle multi Gbytes files  
smoothly and without problem (and it's distributed under modified  
BSD license).


http://ridiculousfish.com/hexfiend/


___

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

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

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

This email sent to scottand...@roadrunner.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: NSTableView bug?

2009-07-02 Thread Jean-Daniel Dupas
I've created a simple application with an NSTableView. I have  
written a delegate for this table,  
numberOfRowsInTableView:objectValueForTableColumn:row:, that returns  
the number of rows in the table when requested.


My application uses the table view to display hexadecimal data on a  
flash memory chip, with 16 bytes displayed per row. As a test, I  
tried returning a large number for the number of rows, 0x100.  
When I scroll through the table, everything looks okay for the first  
14 million rows or so, after which the gray horizonal cell separator  
disappears and the row data begins to shift by a pixel per row,  
until it eventually is superimposed on the row above it. This seems  
like a bug with the NSTableView class, but perhaps I'm doing  
something wrong. Has anyone else run into this problem?


My 2 cents,

If you're looking for a (very) efficient and clean way to display  
large amount of binary data, have a look at HexFiend. This is the  
fastest hex editor I know. It's able to handle multi Gbytes files  
smoothly and without problem (and it's distributed under modified BSD  
license).


http://ridiculousfish.com/hexfiend/


___

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

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

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

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


Re: NSTableView bug?

2009-07-02 Thread I. Savant

On Jul 2, 2009, at 1:11 PM, Tito Ciuro wrote:

I totally agree. I would never present anywhere that much info to  
the user. It's overwhelming and difficult to navigate through. My  
comment referred to a bad approach in design: I was adding another  
argument as to why displaying 14 million rows in a table view is a  
bad, bad idea. I don't see this as a limitation of NSTableView at all.



  Ah, very good. (takes finger off poo-flinging machine's launch  
button) ;-)


--
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: NSTableView bug?

2009-07-02 Thread Tito Ciuro

On 2 Jul 2009, at 9:56 AM, I. Savant wrote:


On Jul 2, 2009, at 12:52 PM, Tito Ciuro wrote:

Not to mention that dragging the scroll thumb one pixel will result  
in thousands of rows scrolled at once. Simply useless.


 Well, yes, but the only real way to avoid that is to design your  
application to limit the amount of data presented to the user. It's  
not an argument against the table view / scroll view mechanism so  
much as an argument against an overall UI approach that relies on  
that mechanism to display thousands and thousands of rows of data,  
which is rarely useful in itself ...


--
I.S.


I totally agree. I would never present anywhere that much info to the  
user. It's overwhelming and difficult to navigate through. My comment  
referred to a bad approach in design: I was adding another argument as  
to why displaying 14 million rows in a table view is a bad, bad idea.  
I don't see this as a limitation of NSTableView at all.


-- Tito
___

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

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

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

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


Re: NSTableView bug?

2009-07-02 Thread I. Savant

On Jul 2, 2009, at 12:52 PM, Tito Ciuro wrote:

Not to mention that dragging the scroll thumb one pixel will result  
in thousands of rows scrolled at once. Simply useless.


  Well, yes, but the only real way to avoid that is to design your  
application to limit the amount of data presented to the user. It's  
not an argument against the table view / scroll view mechanism so much  
as an argument against an overall UI approach that relies on that  
mechanism to display thousands and thousands of rows of data, which is  
rarely useful in itself ...


--
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: NSTableView bug?

2009-07-02 Thread Tito Ciuro

On 2 Jul 2009, at 9:36 AM, Shawn Erickson wrote:

On Thu, Jul 2, 2009 at 8:37 AM, Michael Ash  
wrote:
On Thu, Jul 2, 2009 at 10:51 AM, Chris Carson  
wrote:


Hello,

I've created a simple application with an NSTableView. I have  
written a delegate for this table,  
numberOfRowsInTableView:objectValueForTableColumn:row:, that  
returns the number of rows in the table when requested.


My application uses the table view to display hexadecimal data on  
a flash memory chip, with 16 bytes displayed per row. As a test, I  
tried returning a large number for the number of rows, 0x100.  
When I scroll through the table, everything looks okay for the  
first 14 million rows or so, after which the gray horizonal cell  
separator disappears and the row data begins to shift by a pixel  
per row, until it eventually is superimposed on the row above it.  
This seems like a bug with the NSTableView class, but perhaps I'm  
doing something wrong. Has anyone else run into this problem?


Known problem:

http://www.google.com/search?client=safari&rls=en-us&q=nstableview+14+million&ie=UTF-8&oe=UTF-8

Either restrict your app to running in 64-bit mode (which will cause
the graphics system to use doubles instead of floats) or write a
custom control.


...or seriously reconsider the utility (expectation) of having
millions of row in a table view.

Do users really want to scroll thru that many rows? Can users work
with that much data? etc.

In other words will this really be a problem without first causing
usability problems for your users.


Not to mention that dragging the scroll thumb one pixel will result in  
thousands of rows scrolled at once. Simply useless.


-- Tito
___

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

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

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

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


Re: User interface validation doesn't work, right?

2009-07-02 Thread Michael Ash
On Thu, Jul 2, 2009 at 3:48 AM, Bill Cheeseman wrote:
> I did find it confusing when I read the NSMenuItem and NSToolbarItem Class
> Reference documents, which say that they conform to the other protocol, the
> NSValidatedUserInterface protocol. But this tends to suggest that NSButton
> will work, too, since NSControl, from which NSButton inherits, also conforms
> to the NSValidatedUserInterface protocol. It doesn't say so, but Apple's
> documentation has a long history of neglecting to mention all the protocols
> that a class conforms to. I was able to confirm from the NSControl Class
> Reference document, and you can too, that NSControl does implement the
> -action and -tag methods required by the NSValidatedUserInterface protocol.
> So, again, I don't understand why you say it doesn't.

Because it doesn't.

You seem to think that protocol conformance is simply a matter of
having declared the proper methods. That's not how it works. If you
check with -conformsToProtocol:, it will return NO. If you try to
assign to a pointer of type id  the compiler
will warn you.

Protocol conformance is a matter of having the declaration in the
header. Nothing else counts. Especially here, where the protocol is
obviously being used as a way to claim a particular behavior, not just
an ability to respond to certain selectors.

As proof, I submit NSObject and NSCopying. NSCopying contains a single
method, -copyWithZone:. NSObject implements this method. And yet,
NSObject does not conform to NSCopying, and if you try to copy one it
will fail.

Mike
___

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

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

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

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


Re: Sorting on a table view of a managed object - debugger throws exception

2009-07-02 Thread Steve Cronin

Quincy;

Hey thanks for some useful data!

BUT it is not what is happening in this case.
I have a base class MyManagedObject that all entities are derived from.
MyManagedObject has the - setNilValueForKey: method defined.
I set a breakpoint there and a log message as well.  Neither are ever  
called.


I have an array controller whose sort descriptors are bound in IB.
This appears to work because the initial display of the table is  
ordered accordingly.

There is no sort key nor selector specified in IB for the table column.
The table column value is bound in IB to the array controller.
Below is the full trace when I click on the table column header...

Thanks for your time!
Steve


#0  0x93b63e17 in objc_exception_throw
#1  0x9577bbd1 in -[NSException raise]
#2  0x91b0abb0 in _NSSetValueAndNotifyForUndefinedKey
#3  0x919f98c7 in _NSSetUsingKeyValueSetter
#4  0x919f935e in -[NSObject(NSKeyValueCoding) setValue:forKey:]
#5  0x91a7df81 in -[NSObject(NSKeyValueCoding) setValue:forKeyPath:]
#6	0x9453332d in -[NSBinder  
_setValue:forKeyPath:ofObject:mode:validateImmediately:raisesForNotApplicableKeys:error 
:]

#7  0x945330de in -[NSBinder setValue:forBinding:error:]
#8	0x9455c8e6 in -[NSControllerConfigurationBinder  
controller:didChangeToSortDescriptors:]
#9	0x9455c7ff in -[_NSBindingAdaptor  
controller:didChangeToSortDescriptors:]

#10 0x94543aa5 in -[NSArrayController setSortDescriptors:]
#11 0x919f935e in -[NSObject(NSKeyValueCoding) setValue:forKey:]
#12 0x91a7df81 in -[NSObject(NSKeyValueCoding) setValue:forKeyPath:]
#13	0x9453332d in -[NSBinder  
_setValue:forKeyPath:ofObject:mode:validateImmediately:raisesForNotApplicableKeys:error 
:]

#14 0x945330de in -[NSBinder setValue:forBinding:error:]
#15 0x94544670 in -[NSTableBinder tableView:didChangeToSortDescriptors:]
#16	0x945445c8 in -[_NSBindingAdaptor  
tableView:didChangeToSortDescriptors:]

#17 0x944a0804 in -[NSTableView setSortDescriptors:]
#18 0x9481a561 in -[NSTableView _changeSortDescriptorsForClickOnColumn:]
#19	0x9455332a in -[NSTableHeaderView  
_trackAndModifySelectionWithEvent:onColumn:stopOnReorderGesture:]

#20 0x94552b47 in -[NSTableHeaderView mouseDown:]
#21 0x94365133 in -[NSWindow sendEvent:]
#22 0x94331cd9 in -[NSApplication sendEvent:]
#23 0x9428f62f in -[NSApplication run]
#24 0x9425c834 in NSApplicationMain


___

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

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

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

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


Re: NSTableView bug?

2009-07-02 Thread Shawn Erickson
On Thu, Jul 2, 2009 at 8:37 AM, Michael Ash wrote:
> On Thu, Jul 2, 2009 at 10:51 AM, Chris Carson wrote:
>>
>> Hello,
>>
>> I've created a simple application with an NSTableView. I have written a 
>> delegate for this table, 
>> numberOfRowsInTableView:objectValueForTableColumn:row:, that returns the 
>> number of rows in the table when requested.
>>
>> My application uses the table view to display hexadecimal data on a flash 
>> memory chip, with 16 bytes displayed per row. As a test, I tried returning a 
>> large number for the number of rows, 0x100. When I scroll through the 
>> table, everything looks okay for the first 14 million rows or so, after 
>> which the gray horizonal cell separator disappears and the row data begins 
>> to shift by a pixel per row, until it eventually is superimposed on the row 
>> above it. This seems like a bug with the NSTableView class, but perhaps I'm 
>> doing something wrong. Has anyone else run into this problem?
>
> Known problem:
>
> http://www.google.com/search?client=safari&rls=en-us&q=nstableview+14+million&ie=UTF-8&oe=UTF-8
>
> Either restrict your app to running in 64-bit mode (which will cause
> the graphics system to use doubles instead of floats) or write a
> custom control.

...or seriously reconsider the utility (expectation) of having
millions of row in a table view.

Do users really want to scroll thru that many rows? Can users work
with that much data? etc.

In other words will this really be a problem without first causing
usability problems for your users.

-Shawn
___

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

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

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

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


Re: Setting a document's icon and default app

2009-07-02 Thread Kyle Sluder
On Thu, Jul 2, 2009 at 7:06 AM, Michael
Domino wrote:
> I¹ve set up my app with a document type (see below), moved the app to
> Applications, logged out, logged back in, created a document of this type,
> but the setting the doc¹s icon and association with my app does not occur
> automatically, only when I manually do Get Info and set it. What am I
> missing here? Is there a function I should be calling to make this happen
> when the file is created?

Where are your UTI definitions?

--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: UIImageView source

2009-07-02 Thread Tan E-Liang
You could try this if you're lazy... Just call the  
presentImagePickerWithSource and choose your source type (camera or  
photo library)


- (void)presentImagePickerWithSource: 
(UIImagePickerControllerSourceType)sourceType {

pickerController = [[UIImagePickerController alloc]init];
pickerController.delegate = self;
pickerController.sourceType = sourceType;
[self presentModalViewController:pickerController animated:YES];
}


- (void)imagePickerController:(UIImagePickerController *)picker  
didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary  
*)editingInfo {

imageView.image = image;
[picker dismissModalViewControllerAnimated:YES];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController  
*)picker {

[picker dismissModalViewControllerAnimated:YES];
}

E-Liang

On Jul 2, 2009, at 11:33 PM, Development wrote:

I need to create a filebrowser of sorts that allows a user to select  
an image from the iPhone/iPod images directory. The same one that  
iPhone camera images are saved to preferably. Is there s built in  
method of doing this or perhaps some guidance I could get on how to  
select and set images from this directory?



April.
___

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

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

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

This email sent to gnaileli...@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: warning:assignment from distinct Objective-C type

2009-07-02 Thread Kyle Sluder
On Thu, Jul 2, 2009 at 7:06 AM, Mac First wrote:
> Note that, if you want a mutable array, you can wrapper the return-result in
>  [NSMutableArray arrayWithArray: ... ]

Or use the -mutableCopy method.

--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: User interface validation doesn't work, right?

2009-07-02 Thread Keary Suska

On Jul 2, 2009, at 1:48 AM, Bill Cheeseman wrote:

I'm not "assuming" that it works with all user controls. The  
document I quoted from says it does, explicitly and in detail,  
without qualification. All I asked in my original post is whether  
I'm correct in concluding that in fact buttons don't work that way.  
I understand that you've all confirmed that I'm correct in my  
conclusion. Thanks.


You have to confess that the docs don't say, "all user interface items  
conform to the NSValidatedUserInterfaceItem protocol and therefore  
support validation." That is the only true *detailed* and *explicit*  
statement that would indicate such. Anything else is an inference,  
although a reasonable and understandable inference, considering the  
docs in isolation.


Your argument seems to make the case that the problem is precisely how  
the docs are *not* explicit, and therefore allow or encourage an  
incorrect inference. I agree, conditionally.


It doesn't help to refer me to the NSUserInterfaceValidations and  
NSValidatedUserInterface protocol documents, because that's where I  
started. They are ambiguous, and they're very short on explanation.  
In fact, I turned to the User Interface Validation document  
precisely because I was seeking clarification of the protocol  
documents. Telling me to go back and look at the protocol documents  
doesn't help.



Well, looking at the methods that both protocols does shed light on  
their purpose, as was explained by Andy Lee.


In trying to pin down whether buttons also do so, I looked at the  
NSButton Class Reference document and found that it expressly  
conforms to the NSUserInterfaceValidations protocol. I don't  
understand why you say it doesn't.


I defer to Andy's explanation.

I did find it confusing when I read the NSMenuItem and NSToolbarItem  
Class Reference documents, which say that they conform to the other  
protocol, the NSValidatedUserInterface protocol. But this tends to  
suggest that NSButton will work, too, since NSControl, from which  
NSButton inherits, also conforms to the NSValidatedUserInterface  
protocol. It doesn't say so, but Apple's documentation has a long  
history of neglecting to mention all the protocols that a class  
conforms to. I was able to confirm from the NSControl Class  
Reference document, and you can too, that NSControl does implement  
the -action and -tag methods required by the  
NSValidatedUserInterface protocol. So, again, I don't understand why  
you say it doesn't.


It's not a matter of docs, although it would be preferable that the  
docs *do* indicate every protocol. Because the two protocols in  
question are formal protocols, the @interface declaration must specify  
conformance. If it doesn't, then no assumption of conformance should  
be made. Pure and simple. Also, protocol conformance is not  
inheritable in Objective-C. Therefore, neither NSControl, nor  
NSButton, conform to the NSValidatedUserInterface protocol.


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

___

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

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

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

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


Re: User interface validation doesn't work, right?

2009-07-02 Thread Andy Lee
On Thursday, July 02, 2009, at 03:48AM, "Bill Cheeseman"  
wrote:
>I'm not "assuming" that it works with all user controls. The document  
>I quoted from says it does, explicitly and in detail, without  
>qualification.

This is why in my Radar I suggested the "validated item" terminology to 
indicate there is a special class of user interface items.  It seems obvious to 
me to follow the tradition of English terms matching Objective-C names very 
naturally: an NSTableView is a table view, an NSTextField is a text field, and 
an NSValidatedUserInterfaceItem should be a validated (user interface) item.

>The protocol documents say, as you noted, that they "work together" to  
>implement user interface validation. They go on to state that "The  
>NSMenuItem and NSToolbar Item classes take advantage of these  
>protocols." Grammatically, that sentence is written as if these are  
>simply two examples of classes that do so; it does not state that they  
>are the ONLY classes that do so.

And it doesn't point out that they don't *always* do so (depending on the 
autoenablesItems and autovalidates flags).  I'm not saying that doc should 
repeat the details of menu enabling and toolbar validation, but I do think it 
would be worth adding links to the "Enabling Menu Items" and "Validating 
Toolbar Items" sections to provide some hint that there is a larger story.  I 
just submitted bottom-of-the-page feedback to this effect.

>In trying to pin down whether buttons also do so, I looked at the  
>NSButton Class Reference document and found that it expressly conforms  
>to the NSUserInterfaceValidations protocol.

This is true but irrelevant.  NSUserInterfaceValidations is for the object that 
validates, not the one that is validated.  What this means is that if you have 
a menu item with an NSButton as its target, the button gets to decide whether 
the menu item is enabled.  But we don't know what logic it uses to do this, 
because NSButton's implementation of validateUserInterfaceItem: is not 
documented.  I would love to hazard a guess, but one doesn't come to mind 
offhand.

>I did find it confusing when I read the NSMenuItem and NSToolbarItem  
>Class Reference documents, which say that they conform to the other  
>protocol, the NSValidatedUserInterface protocol. But this tends to  
>suggest that NSButton will work, too, since NSControl, from which  
>NSButton inherits, also conforms to the NSValidatedUserInterface  
>protocol.

Well, it implements the methods, but since NSValidatedUserInterfaceItem is a 
formal protocol, I would say NSButton doesn't conform to it in the sense of 
[NSButton conformsToProtocol:@protocol(NSValidatedUserInterfaceItem)].  I agree 
it's very easy to be confused, because the implementation of item validation 
might or might not care whether the validated item conforms formally to the 
protocol, and this seems a natural thing for a button to do.

Since the docs in question are relatively small, very fundamental, and IMO 
potentially very confusing, it seems to me this is low-hanging fruit for 
Apple's doc team and worth addressing sooner rather than later.

--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: NSTableView bug?

2009-07-02 Thread Scott Andrew
I had this problem but it had to do with calculating the height for  
the row and returning a float value. When i made sure i returned an  
int this went away. Not sure if you doing that.


Scott


On Jul 2, 2009, at 7:51 AM, Chris Carson wrote:



Hello,

I've created a simple application with an NSTableView. I have  
written a delegate for this table,  
numberOfRowsInTableView:objectValueForTableColumn:row:, that returns  
the number of rows in the table when requested.


My application uses the table view to display hexadecimal data on a  
flash memory chip, with 16 bytes displayed per row. As a test, I  
tried returning a large number for the number of rows, 0x100.  
When I scroll through the table, everything looks okay for the first  
14 million rows or so, after which the gray horizonal cell separator  
disappears and the row data begins to shift by a pixel per row,  
until it eventually is superimposed on the row above it. This seems  
like a bug with the NSTableView class, but perhaps I'm doing  
something wrong. Has anyone else run into this problem?


Chris





___

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

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

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

This email sent to scottand...@roadrunner.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: Drawing the background of a single row in NSTableView

2009-07-02 Thread Michael Ash
On Wed, Jul 1, 2009 at 8:09 PM, Peter
Zegelin wrote:
>
> On 01/07/2009, at 6:55 PM, Dado Colussi wrote:
>
>> Subclass NSTableView and implement your special drawing in -
>> (void)drawBackgroundInClipRect:(NSRect)clipRect.
>>
>> /Dado
>
> Problem with this is there is no obvious concordance ( that I can see)
> between a row and its rectangle.

Doesn't need to be obvious, because Apple figured it out for you
already. To go from a location to a row:

- (NSInteger)rowAtPoint:(NSPoint)point;

And to go from a row to a rectangle:

- (NSRect)rectOfRow:(NSInteger)row;

> Wouldn't scrolling affect all this?

No. Scrolling is accomplished by applying a transform to the table's
superview. Coordinates within the scrolled view itself are not
affected at all.

Mike
___

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

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

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

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


Re: Dynamically loading a part of a Window in Cocoa

2009-07-02 Thread Michael Ash
On Wed, Jul 1, 2009 at 11:18 PM, Marco S Hyman wrote:
> On Jul 1, 2009, at 6:50 PM, Adam R. Maxwell wrote:
>
>> Well, I generally avoid bindings, since I can't comment nib/xib files, and
>> it takes too long to reverse engineer my own (or worse, someone else's)
>> bindings when I'm doing maintenance work.  With that perspective, the minor
>> glue code to swap views is no big deal :).
>
> Warning: subject creep.
>
> That leads directly to something I've been thinking about as one new to
> cocoa:
> how do you document your bindings?   Any preferred formats other than a text
> file stuck somewhere in a project?

If you're going to stick your bindings in a text file, why not stick
them in a text file which happens to end in .m, and document them in a
format that the compiler can understand? In other words, why not just
make your bindings in code? Then you can easily see them, you can
comment them to your heart's content, you can search for them, and all
the other benefits of having stuff not be in your nib.

Mike
___

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

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

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

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


Re: UIImageView source

2009-07-02 Thread Luke the Hiesterman
Creating your own file browser for photos on the phone is not  
supported. An excellent one has already been written for you, though.  
See UIImagePickerController.


http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

Luke

On Jul 2, 2009, at 8:33 AM, Development wrote:

I need to create a filebrowser of sorts that allows a user to select  
an image from the iPhone/iPod images directory. The same one that  
iPhone camera images are saved to preferably. Is there s built in  
method of doing this or perhaps some guidance I could get on how to  
select and set images from this directory?



April.
___

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

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

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

This email sent to luket...@apple.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: UIImageView source

2009-07-02 Thread Dave DeLong

Check out the UIImagePickerController class.

Dave

On Jul 2, 2009, at 9:33 AM, Development wrote:

I need to create a filebrowser of sorts that allows a user to select  
an image from the iPhone/iPod images directory. The same one that  
iPhone camera images are saved to preferably. Is there s built in  
method of doing this or perhaps some guidance I could get on how to  
select and set images from this directory?



April.

___

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

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

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

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


Re: NSTableView bug?

2009-07-02 Thread Michael Ash
On Thu, Jul 2, 2009 at 10:51 AM, Chris Carson wrote:
>
> Hello,
>
> I've created a simple application with an NSTableView. I have written a 
> delegate for this table, 
> numberOfRowsInTableView:objectValueForTableColumn:row:, that returns the 
> number of rows in the table when requested.
>
> My application uses the table view to display hexadecimal data on a flash 
> memory chip, with 16 bytes displayed per row. As a test, I tried returning a 
> large number for the number of rows, 0x100. When I scroll through the 
> table, everything looks okay for the first 14 million rows or so, after which 
> the gray horizonal cell separator disappears and the row data begins to shift 
> by a pixel per row, until it eventually is superimposed on the row above it. 
> This seems like a bug with the NSTableView class, but perhaps I'm doing 
> something wrong. Has anyone else run into this problem?

Known problem:

http://www.google.com/search?client=safari&rls=en-us&q=nstableview+14+million&ie=UTF-8&oe=UTF-8

Either restrict your app to running in 64-bit mode (which will cause
the graphics system to use doubles instead of floats) or write a
custom control.

Mike
___

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

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

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

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


UIImageView source

2009-07-02 Thread Development
I need to create a filebrowser of sorts that allows a user to select  
an image from the iPhone/iPod images directory. The same one that  
iPhone camera images are saved to preferably. Is there s built in  
method of doing this or perhaps some guidance I could get on how to  
select and set images from this directory?



April.
___

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

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

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

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


NSTableView bug?

2009-07-02 Thread Chris Carson

Hello,

I've created a simple application with an NSTableView. I have written a 
delegate for this table, 
numberOfRowsInTableView:objectValueForTableColumn:row:, that returns the number 
of rows in the table when requested.

My application uses the table view to display hexadecimal data on a flash 
memory chip, with 16 bytes displayed per row. As a test, I tried returning a 
large number for the number of rows, 0x100. When I scroll through the 
table, everything looks okay for the first 14 million rows or so, after which 
the gray horizonal cell separator disappears and the row data begins to shift 
by a pixel per row, until it eventually is superimposed on the row above it. 
This seems like a bug with the NSTableView class, but perhaps I'm doing 
something wrong. Has anyone else run into this problem?

Chris



  

___

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

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

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

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


Setting a document's icon and default app

2009-07-02 Thread Michael Domino
Hi,

I¹ve set up my app with a document type (see below), moved the app to
Applications, logged out, logged back in, created a document of this type,
but the setting the doc¹s icon and association with my app does not occur
automatically, only when I manually do Get Info and set it. What am I
missing here? Is there a function I should be calling to make this happen
when the file is created?

I do changeFileAttributes to set the classic HFS file type and creator code,
but it does not seem to have any effect (I guess I did not expect it to, but
you never know)

NSDictionary* attributes = [NSDictionary
dictionaryWithObjectsAndKeys:
@"IDFV", NSFileHFSTypeCode,
@"IDFD", NSFileHFSCreatorCode,
nil];
NSString* path = // set the path here
BOOL changedOK = [[NSFileManager defaultManager]
changeFileAttributes:attributes atPath:path];

Thanks for your advice,
Michael


http://www.apple.com/DTDs/PropertyList-1.0.dtd";>



CFBundleTypeExtensions

idfvault

CFBundleTypeIconFile
idfvault.icns
CFBundleTypeMIMETypes

application/idfvault

CFBundleTypeName
Identity Finder File Vault
CFBundleTypeOSTypes

fold
IDFV

CFBundleTypeRole
Editor
LSItemContentTypes


com.identityfinder.identityfinderenterpriseedition.idfvault

LSTypeIsPackage

NSPersistentStoreTypeKey
Binary




-- 
Michael Domino
michael.dom...@identityfinder.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: warning:assignment from distinct Objective-C type

2009-07-02 Thread Mac First


On Jul 1, 2009, at 9:34 AM, Ken Thomases wrote:

On Jul 1, 2009, at 11:26 AM, David Blanton wrote:

in .h file

NSMutableArray *m_sources;
[...]
	m_sources = [volumes stringsByAppendingPaths:[defaultManager  
directoryContentsAtPath:volumes]];


-stringsByAppendingPaths: returns an NSArray*.  That is not an  
NSMutableArray*.  (NSMutableArray is-a NSArray, though, of course.)


Note that, if you want a mutable array, you can wrapper the return- 
result in  [NSMutableArray arrayWithArray: ... ]


___

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

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

Help/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: Extract the names of all the files in some folder

2009-07-02 Thread Clint Shryock
http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/enumeratorAtPath
:
In the above example's if statement inside the while loop, switch the
extension to .mov.  then if it matches I would add that file's name, path,
whatever you want, to a NSMutableArray or similar and then bind your table
view to that array.

+Clint

2009/7/2 Bright 

> Hi all,
>   Suppose that all of the files are .mov file in a folder. Now in my App, I
> want to realize that it can
> extract the names of all the movie files in the folder. At the same time,
> it displays the names in the table
> view of my application when the application launches every time.
>   Could anyone give some directions about it ?  Both the basic principle
> and the key methods are important
> for me.
> Thx.
> Bright
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/cts3e1%40gmail.com
>
> This email sent to cts...@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


Extract the names of all the files in some folder

2009-07-02 Thread Bright
Hi all,
   Suppose that all of the files are .mov file in a folder. Now in my App, I 
want to realize that it can 
extract the names of all the movie files in the folder. At the same time, it 
displays the names in the table
view of my application when the application launches every time.
   Could anyone give some directions about it ?  Both the basic principle and 
the key methods are important
for me. 
Thx.
Bright

___

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

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

Help/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: Programmatically adding to one big Finder selection ?

2009-07-02 Thread André Berg


On a related sidenote, I saw that the Finder AppleScript dictionary has 
a couple of properties for its folder type that seem to deal with list 
views:



"completely expanded", which has the description of:

"(NOT AVAILABLE YET) Are the container and all of its children opened as 
outlines? (can only be set for containers viewed as lists)"


"expanded":

"(NOT AVAILABLE YET) Is the container opened as an outline? (can only be 
set for containers viewed as lists)"


"expandable":

"(NOT AVAILABLE YET) Is the container capable of being expanded as an 
outline?"



So, it seems I may have a shot at this again if and when these 
properties are fully implemented


Cheers,

André
___

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

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

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

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


Re: Drawing the background of a single row in NSTableView

2009-07-02 Thread Peter Zegelin


On 02/07/2009, at 11:57 AM, Adam R. Maxwell wrote:



On Jul 1, 2009, at 6:40 PM, Graham Cox wrote:



On 02/07/2009, at 10:09 AM, Peter Zegelin wrote:

Problem with this is there is no obvious concordance ( that I can  
see) between a row and its rectangle.

Wouldn't scrolling affect all this?



I wonder if the delegate method:

- (void)tableView:(NSTableView *)aTableView willDisplayCell: 
(id)aCell forTableColumn:(NSTableColumn *)aTableColumnrow: 
(NSInteger)rowIndex



would be better for your needs? It gives you the row and column so  
you know where you are, and is called as part of the drawing loop  
of the table, you can just go ahead and draw. Use -rectOfRow to get  
the row and paint the background. I just tried the code below and  
it works fine:


ISTR having problems with this, possibly due to intercell spacing,  
back when we had to draw alternating row colors manually.


Another alternative is to subclass NSTableView and override - 
drawRow:clipRect: which might be considered less of a hack than  
using the delegate method to draw.


I took that route, using an additional datasource method that I've  
defined as tableView:backgroundColorForRow:, and it seems to work  
fairly well.


- (void)drawRow:(NSInteger)row clipRect:(NSRect)clipRect;
{
   NSColor *color = [[self dataSource] tableView:self  
backgroundColorForRow:row];

   // ignore any background color if the row is selected
   if (color && [self isRowSelected:row] == NO) {
   [NSGraphicsContext saveGraphicsState];
   NSRectClip(clipRect);
   NSRect rowRect = [self rectOfRow:row];
   // draw over the alternating row color
   [[NSColor whiteColor] setFill];
   NSRectFill(NSIntersectionRect(rowRect, clipRect));
   // draw with rounded end caps
   CGFloat radius = NSHeight(rowRect) / 2.0;
   NSBezierPath *p = [NSBezierPath  
bezierPathWithRoundedRect:NSInsetRect(rowRect, 1.0, 0.0)  
xRadius:radius yRadius:radius];

   [color setFill];
   [p fill];
   [NSGraphicsContext restoreGraphicsState];
   }
   // draw cells on top of the new row background
   [super drawRow:row clipRect:clipRect];
}



Thank you Adam,

	I have implemented your suggestion and it is working great. My  
delegate just sends a message to the Tableview letting it know which  
is the new row to hilite the special way.


cheers,

Peter
www.fracturedsoftware.com/rondo/  - MIDI for your mac
www.fracturedsoftware.com/macsimavr/
___

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

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

Help/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: Programmatically adding to one big Finder selection ?

2009-07-02 Thread André Berg


Thanks everyone for your input.

Interesting to see that I was wrong about selecting multiple files in 
the finder being a common task.


Maybe a little background will shed some light on why I was trying to 
write this program:


Currently I am primarily doing visual effects (digital compositing) 
related work or sometimes I am working as web worker.
In both of these occupations we often deal with large repositories of 
files with names that have no common basename or no common name extension.


In the past I had no problems of course doing all that file lifting, 
moving, deleting, archiving, etc with the shell directly, but then I saw 
Path Finder's selection feature, which also selects files nested in list 
views, but doesn't allow one to enter regular expressions.


That's why I decided in order to boost my hobbyist programming knowledge 
I'd try to code a little tool like that, which would allow me to select 
arbitrarily files based on a regex (I know this question has been raised 
before, a search on lists.apple.com shows there is some minor use for it 
but not much and it never deals with list views).


When I got it working all fine I saw it as a challenge to also let it 
work on expandable list views ofc not knowing that it would be indeed so 
hard to accomplish. Now that I know I am thinking about ditching the 
effort alltogether.


Again, I would like to thank everyone for taking their valuable time and 
replying to my question :)



Cheers,

André


--- Original Nachricht ---
Absender: André Berg
Datum: 01.07.2009 6:54 Uhr

Hi,

I have an NSArray of NSString's representing valid POSIX paths.

How can I loop through that array and make one big selection of all 
the items in one Finder window running in list-view mode?


I know about

[[NSWorkspace sharedWorkspace] selectFile:@"/some/path" 
inFileViewerRootedAtPath:@""]


but it only let's me select one file at a time and it will spawn many 
Finder windows during the loop, even if the frontmost Finder window is 
in list view (aka NSOutlineView with expanded subfolders).


Thank you so much for reading my question!

Cheers,

André
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/andre.berg%40email.de

This email sent to andre.b...@email.de


___

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

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

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

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


Re: Sorting on a table view of a managed object - debugger throws exception

2009-07-02 Thread Quincey Morris

On Jul 2, 2009, at 01:10, Steve Cronin wrote:


10.5.7 - 10.5 SDK - target 10.4
I have a managed core data entity working pretty nicely.
I can display values in a tableView blah-blah
Clicking on table column headers does as expected IN RELEASE  
versions for both Tiger and Leopard.


However, in the debugger a click on table column header causes an  
objc-exception.

If I step thru eventually I can survive and proceed

Error setting value for key path value of object 0x852600> (from bound object [entity:  
MyEntity, number of selected objects: 1](null)): [< MyAppDelegate  
0x852600> setValue:forUndefinedKey:]: this class is not key value  
coding-compliant for the key code.


I know, I know stop hitting yourself on the head with a hammer

It just bugs me - why?
Have I done something wrong somewhere?
Is this a known bug?



I love this error message because it is clearly packed with  
information, yet it is practically impossible to interpret without  
some hints.


What happened is that something tried to set MyEntity's 'code'  
property to nil, but the property has a scalar value type, so  
setNilValueForKey: was called instead of the usual automatic object-to- 
scalar transformation. You haven't implemented setNilValueForKey:, so  
the default behavior is to call setValue:forUndefinedKey: instead,  
which threw the exception you saw.


This is discussed a little bit in here:

	http://developer.apple.com/documentation/Cocoa/Conceptual/CoreDataUtilityTutorial/Articles/06_runClass.html#/ 
/apple_ref/doc/uid/TP40001800-CH234-SW1


but I can't find a better explanation, although I thought there was  
one somewhere.


The answer is to implement setNilValueForKey: for managed object  
subclasses that have scalar accessors, using the pattern shown in the  
above tutorial.


If you actually do this, you can set a breakpoint there where it  
detects this key, and you might even find out why something is trying  
to set your property to nil. One reason it can happen is that when an  
object is deleted or faulted out, it can have all its properties  
forced to nil. But not always.



___

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

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

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

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


Sorting on a table view of a managed object - debugger throws exception

2009-07-02 Thread Steve Cronin

Folks;

10.5.7 - 10.5 SDK - target 10.4
I have a managed core data entity working pretty nicely.
I can display values in a tableView blah-blah
Clicking on table column headers does as expected IN RELEASE versions  
for both Tiger and Leopard.


However, in the debugger a click on table column header causes an objc- 
exception.

If I step thru eventually I can survive and proceed

Error setting value for key path value of object 0x852600> (from bound object [entity:  
MyEntity, number of selected objects: 1](null)): [< MyAppDelegate  
0x852600> setValue:forUndefinedKey:]: this class is not key value  
coding-compliant for the key code.


I know, I know stop hitting yourself on the head with a hammer

It just bugs me - why?
Have I done something wrong somewhere?
Is this a known bug?

Steve

___

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

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

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

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


Re: User interface validation doesn't work, right?

2009-07-02 Thread Bill Cheeseman

On Jul 1, 2009, at 9:15 PM, Keary Suska wrote:

So I think you are claiming this works because the documentation  
says so. I'm saying the documentation is wrong because it doesn't  
work. I would love to see a project proving me wrong. Can you show  
me one?



No, I am saying that it works as advertised for objects that it  
works for. NSButton is not one of them, and never has been. You seem  
to assume that all user interface items should, but they don't, and  
never have, and the documentation has never said that they did. The  
documentation is explicit:


"The protocols NSUserInterfaceValidations and  
NSValidatedUserInterfaceItem provide a standard way to validate user  
interface items—that is, to set their state as appropriate for the  
current application context"


Validation is not a function of user interface items, it is a  
function of the protocol(s) listed. Neither NSButton, nor any of its  
parents conforms to the protocol, so none of them support validation  
of this kind. Look at NSMenuItem, and you will see that it does, and  
that your validation method will always be called.


I'm not "assuming" that it works with all user controls. The document  
I quoted from says it does, explicitly and in detail, without  
qualification. All I asked in my original post is whether I'm correct  
in concluding that in fact buttons don't work that way. I understand  
that you've all confirmed that I'm correct in my conclusion. Thanks.


I must say, though, that I enjoyed your defense of the document. You  
said, in so many words, that it is true only for those user interface  
items for which it is true. That captures my complaint perfectly. When  
a general statement has substantial qualifications, the document  
should express those qualifications. Otherwise, as in this case, it  
fails to serve its purpose of educating people who aren't already in  
the know.


The document not only fails to disclose the qualifications; it  
affirmatively misleads by giving a detailed narrative description of  
how to do it in the general case. I followed the explanation in my own  
code precisely, and it simply doesn't work. In the "The Target Object"  
section, the document describes how to implement user interface  
validation in the case of a "controller" that implements an "action  
method." It says that the controller should also implement - 
validateUserInterfaceItem: in order to enable or disable a user  
interface item. It says, for example, that if the method returns NO,  
"the user interface item is disabled." Nothing in the document  
suggests that this is limited to menu items or toolbar items; instead,  
it refers repeatedly to "user interface items." It goes on to give a  
code example for a subclass of NSDocument. The code sample works only  
because NSDocument is written to make it work (as some other document  
explains; I've forgotten which), but this document doesn't explain  
that rather important qualification. NSWindowController is not written  
that way, and it doesn't work, contrary to the "The Target Object"  
section's assertion that it does work for "controllers" and "user  
interface items" in general.


It doesn't help to refer me to the NSUserInterfaceValidations and  
NSValidatedUserInterface protocol documents, because that's where I  
started. They are ambiguous, and they're very short on explanation. In  
fact, I turned to the User Interface Validation document precisely  
because I was seeking clarification of the protocol documents. Telling  
me to go back and look at the protocol documents doesn't help.


The protocol documents say, as you noted, that they "work together" to  
implement user interface validation. They go on to state that "The  
NSMenuItem and NSToolbar Item classes take advantage of these  
protocols." Grammatically, that sentence is written as if these are  
simply two examples of classes that do so; it does not state that they  
are the ONLY classes that do so. And the User Interface Validation  
document says that NSMenuItem is "one example."


In trying to pin down whether buttons also do so, I looked at the  
NSButton Class Reference document and found that it expressly conforms  
to the NSUserInterfaceValidations protocol. I don't understand why you  
say it doesn't.


I did find it confusing when I read the NSMenuItem and NSToolbarItem  
Class Reference documents, which say that they conform to the other  
protocol, the NSValidatedUserInterface protocol. But this tends to  
suggest that NSButton will work, too, since NSControl, from which  
NSButton inherits, also conforms to the NSValidatedUserInterface  
protocol. It doesn't say so, but Apple's documentation has a long  
history of neglecting to mention all the protocols that a class  
conforms to. I was able to confirm from the NSControl Class Reference  
document, and you can too, that NSControl does implement the -action  
and -tag methods required by the NSValidatedUserInterface protocol.  
So, 

Re: Alternative to NSGraphicsContext graphicsContextWithGraphicsPort:flipped:

2009-07-02 Thread Duncan McGregor
On Wed, Jul 1, 2009 at 11:20 PM, Scott Thompson wrote:

> If I understand... you're going all the way to NSGraphicsContext just to flip 
> the coordinate system?  That's a long row to hoe :-).

It would be, but I'm actually going to NSGraphicsContext so that I can
draw NSImages and NSStrings on the PDF without having to bang my head
against Quartz, especially in its font handling.

Duncan
___

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

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

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

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


Re: User interface validation doesn't work, right?

2009-07-02 Thread Bill Cheeseman

On Jul 2, 2009, at 12:02 AM, mmalc Crawford wrote:


On Jul 1, 2009, at 4:33 PM, Bill Cheeseman wrote:
But it doesn't work at all for user controls in general, and the  
docs are misleading (i.e., wrong) about that.




although I'm not sure I'd agree with Bill that the docs are *wrong*,  
they certainly could be more helpful in making it clear what the  
limitations are, so I'd still suggest filing an enhancement request.


Read my detailed response to Keary Suska, in which I trace out the  
documents. I can't see any way to avoid concluding that the document  
in question is "wrong," pure and simple, and always has been.


(Hmm, or appending to ' UIValidation: Need a  
bit more context', which is easily old enough to go to Summer Camp  
this year...)


I still have 9 or 10 bugs open from 2002
___

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

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

Help/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: NSComparisonResult and equality

2009-07-02 Thread Martin Wierschin
Since NSComparisonResult is an ordered enum typedef, I'd like to  
know if it's safe to write

the following code to test for 'greater or equal to':

// This would cover both NSOrderAscending and NSOrderSame
if ([obj1 compare:obj2] < NSOrderDescending) {


I'd just use "isGreaterThanOrEqualTo:", which should work for any  
NSObject that implements "compare:". See:


	


Why that's some odd protocol tied to scripting I wouldn't know.

~Martin

___

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

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

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

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