Re: string convertion: converting getter name to setter

2008-09-04 Thread Steve Weller


On Sep 4, 2008, at 6:37 PM, Phil wrote:


On Fri, Sep 5, 2008 at 1:27 PM, Andrew Merenbach
<[EMAIL PROTECTED]> wrote:

SEL getterSel = @selector(balloonColor);
NSString *getterName = NSStringFromSelector(getterSel);
NSString *setterName = [@"set" stringByAppendingString:getterName];
SEL setterSel = NSSelectorFromString(setterName);





Selector's are case-sensitive, so you'll have to do...

setterName = [@"set stringByAppendingString:[getterName  
capitalizedString]];


Phil


From memory I think that does not work: capitalizedString also  
decapitalizes all but the first character, so capitalizedString will  
become setCapitalizedstring instead of setCapitalizedString.




___

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

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

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

This email sent to [EMAIL PROTECTED]


Steve Weller   [EMAIL PROTECTED]
Technical Writing, Editing, Developer Guides, and a little Cocoa



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSMutableDictionary autorelease chrashes application

2008-07-18 Thread Steve Weller


On Jul 18, 2008, at 1:55 PM, Hamish Allan wrote:


On Fri, Jul 18, 2008 at 9:21 PM, Andy Lee <[EMAIL PROTECTED]> wrote:


What would you use for adjectives -- "owned" and "unowned"?


How about "retained" and "unretained"? As in: "this method returns an
unretained object".



How about "dependent" and "independent".

It it's dependent, they you have a responsibility for it, maybe many  
times over. If it is independent, then you don't.


This also talks in terms of the relationship, not the means to  
establishing that relationship.



Steve Weller   [EMAIL PROTECTED]
Technical Writing, Editing, Developer Guides, and a little Cocoa



___

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

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

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

This email sent to [EMAIL PROTECTED]


Protocol-conforming object does not include retain?

2008-07-11 Thread Steve Weller


I have a protocol and an object that conforms to that protocol  
referenced by an ivar:


@protocol FKPointArraySourcing
-(NSInteger)fooMethod;
@end

@interface FKObject : NSObject  {
 id  mGrid; 
}

If I attempt to retain the ivar like this:

[mGrid retain];

then I get a warning that "-retain was not found in protocol(s)".

If I change the protocol definition to:

@protocol FKPointArraySourcing 
-(NSInteger)foo;
@end

then the warning goes away.

If I remove the protocol conformance and just use a naked id, then the  
warning goes away as well.


Or if I cast mGrid to id the warning goes away.

Why is this addition needed? I don't see it used in other code. It's  
as though the compiler believes that conformance to a protocol implies  
that it exclusively provides those methods, which is not the idea of  
protocol conformance at all.





Steve Weller   [EMAIL PROTECTED]
Technical Writing, Editing, Developer Guides, and a little Cocoa



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to create to-many accessor methods at runtime

2008-07-08 Thread Steve Weller


On Jul 8, 2008, at 8:55 AM, Mike Abdullah wrote:



On 8 Jul 2008, at 15:45, Steve Weller wrote:



On Jul 8, 2008, at 2:28 AM, Mike Abdullah wrote:



On 8 Jul 2008, at 07:10, Steve Weller wrote:


What I am attempting to do is not working. -valueForKey:  does  
not look for methods with -respondsToSelector: to figure out if  
methods exist sufficient to have KVC. So overriding this has no  
effect. My only option, it seems, is to use  
+resolveInstanceMethod and actually create the methods that are  
needed.


Or, you know, just override -valueForKey: ? NSArray and the other  
contain classes do just that to get their custom behaviour.


Then I'd need to create an NSArray proxy, probably by subclassing  
NSArray. This was the way I first thought of and decided not to go  
that route.


My current thinking is to hard-code -count and -objectForKey (and  
possibly others) in a helper object, then vend instances of that  
according to what the array should implement. Each of those objects  
ultimately gets its data from a single source, so if I change  
values, all the arrays' customers see the changes. It is likely  
that I will want KVO compliance one day too and that will not work  
with the helpers.


Well I am now officially confused. As I understood it, you were  
writing a class that could have any number of keys, each one of  
which was a one-to-many relationship. Since the number of keys was  
undefined, it wasn't possible to write accessor methods for them,  
and so instead, you were overriding -respondsToSelector: and friends  
to fool the KVC system into thinking that you had written the  
appropriate accessor methods.


But, the implementation of -valueForKey: specifically does not use - 
respondsToSelector:, and so you can't the fool the system that way.  
And so, I'm suggesting simply overriding -valueForKey: in your  
custom class in order for it to return a suitable array.


That's my problem. What makes the array "suitable"?


However, from your last mail, it seems I have the wrong end of the  
stick, as you think it requires overriding -valueForKey: in a custom  
NSArray subclass. So, um, any chance of some clarification?





If I want to override -valueForKey: and return an array object  (as I  
am supposed to since this is what is expected), then whatever object I  
return has to behave as an NSArray does. So unless I want to duplicate  
the functionality of NSArray, I'll have to subclass it.


That's my thinking anyway.

However I now have another idea. I can have a central object that owns  
the data, say called Machine. Other objects can request object  
instances, say Shape, from Machine that implement different operations  
on that data and reference them by a key. Shape objects themselves can  
implement the to-many accessors, and so can respond to objectForKey  
for the property I want.


Load the machine up with recipes:
[machine -addRecipe:recipeA forKey:@"circle" withParameter:345];
[machine -addRecipe:recipeB forKey:@"square" withParameter:778];

Ask machine for objects that implement the recipe on the data. These  
all use the same data stored in the machine instance but process it in  
different ways.

shape1 = [machine shapeForKey:@"circle"];
shape2 = [machine shapeForKey:@"square"];

Get arrays of the things I am actually interested in. If the data in  
machine changes, the array data changes. "points" and "lines" have  
hard-coded to-many accessor methods.

arrayOfPoints = [shape1 valueForKey:@"points"];
arrayOfLines = [shape1 valueForKey:@"lines"];



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to create to-many accessor methods at runtime

2008-07-08 Thread Steve Weller


On Jul 8, 2008, at 2:28 AM, Mike Abdullah wrote:



On 8 Jul 2008, at 07:10, Steve Weller wrote:


What I am attempting to do is not working. -valueForKey:  does not  
look for methods with -respondsToSelector: to figure out if methods  
exist sufficient to have KVC. So overriding this has no effect. My  
only option, it seems, is to use +resolveInstanceMethod and  
actually create the methods that are needed.


Or, you know, just override -valueForKey: ? NSArray and the other  
contain classes do just that to get their custom behaviour.


Then I'd need to create an NSArray proxy, probably by subclassing  
NSArray. This was the way I first thought of and decided not to go  
that route.


My current thinking is to hard-code -count and -objectForKey (and  
possibly others) in a helper object, then vend instances of that  
according to what the array should implement. Each of those objects  
ultimately gets its data from a single source, so if I change values,  
all the arrays' customers see the changes. It is likely that I will  
want KVO compliance one day too and that will not work with the helpers.



Steve Weller   [EMAIL PROTECTED]
Technical Writing, Editing, Developer Guides, and a little Cocoa



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to create to-many accessor methods at runtime

2008-07-07 Thread Steve Weller




Just to follow up on my own question...

What I am attempting to do is not working. -valueForKey:  does not  
look for methods with -respondsToSelector: to figure out if methods  
exist sufficient to have KVC. So overriding this has no effect. My  
only option, it seems, is to use +resolveInstanceMethod and actually  
create the methods that are needed.




Steve Weller   [EMAIL PROTECTED]
Technical Writing, Editing, Developer Guides, and a little Cocoa



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to create to-many accessor methods at runtime

2008-07-06 Thread Steve Weller


On Jul 6, 2008, at 5:02 PM, Ben Trumbull wrote:

First, have you considered the low tech approach of using a gcc  
variadic macro (#define) ?  <http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html 
>  You can generate a lot of template code this way.  With one line  
of code per key you can generate all the accessors you need.


I had not considered this. However I do want to set up the methods at  
run time since the action of the methods depends on how a number of  
other objects are set up and attached.


A second option would be to override -mutableArrayValueForKey: to  
return a proxy object that knows both the source object and the key  
and fulfills the mutable KVC contract.  Basically, this is creating  
a subclass of NSMutableArray that knows how to properly handle your  
source object, it's key.


My class only presents a set of immutable to-many accessors. But now I  
am wondering -- if I do that my values may get optimized away by  
another object that thinks the values never change. I should probably  
add the mutable accessors too, even if they do nothing.


On 10.5, you have an additional hook that is invoked before  
forwarding:


+ (BOOL)resolveInstanceMethod:(SEL)sel;

This is much more efficient than forwarding, and the result is  
cached, so method resolution is only invoked once per selector.  It  
does require some nasty "parsing" of the selector, and use of the  
raw objective-c runtime functions to register the new method on the  
class.


That's an interesting option. My selectors are fixed, so that would  
not be too bad.


-forwardInvocation: is the least efficient choice, although it can  
be handy under some circumstances where flexibility is the most  
important design issue.


I'm sticking with that for now. Another responder set me straight  
about -respondToSelector being only for he convenience of other  
methods. I can say YES as long as I actually implement the dynamic  
methods somehow. NSInvocation is a good container for all the  
information I need, so I also use it to call the method. I set up one  
NSInvocation per method and select the correct one based on the  
selector I am passed after dropping the arguments in as needed, then  
transfer the return result back.




- Ben



Steve Weller   [EMAIL PROTECTED]
Technical Writing, Editing, Developer Guides, and a little Cocoa



___

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

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

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

This email sent to [EMAIL PROTECTED]


How to create to-many accessor methods at runtime

2008-07-06 Thread Steve Weller


I have an object that I would like to respond to a potentially large  
number of KVC compliant to-many accessors of the form:


-countOf
-objectIn:atIndex:

so that they can be used with valueForKey: to return a proxy array, or  
just called directly.


Rather than implement these as methods (and because  specifies  
the array behavior), I want to be able to create them dynamically and  
have all accesses to


-countOf
-objectIn:atIndex:

be handled by two central methods:

-countOfForKey:
-objectInForKey:atIndex:

that respond according to .

I had thought that implementing forwardInvocation would do this, but - 
forwardInvocation is only called if -respondsToSelector says NO. And  
if -respondsToSelector says NO, then the tests for -countOf and - 
objectIn:atIndex: will always fail and I will lose KVC compliance.


Another approach would be to override -valueForUndefinedKey:, but that  
gives me the responsibility of creating and returning the proxy  
NSArray that implements accesses to -countOfForKey: and - 
objectInForKey:atIndex:


Is there a better way to be KVC compliant and yet create the methods  
dynamically?




Steve Weller   [EMAIL PROTECTED]
Technical Writing, Editing, Developer Guides, and a little Cocoa



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Why aren't my bindings firing?

2008-06-28 Thread Steve Weller


On Jun 28, 2008, at 2:55 AM, Ken Thomases wrote:



Also interestingly, the only reference to the  
bind:toObject:withKeyPath:options: method that comes up in an API  
search of the documentation is from the NSKeyValueBindingCreation  
protocol, which states this:


"Establishes a binding between a given property of the receiver and  
the property of a given object specified by a given key path."


Since this doesn't seem to be actually the case, someone ought to  
file a report on the documentation about this.


Yeah, and the description of the "binding" parameter of that method  
also says it's a "key path for a property of the receiver", which  
contradicts my understanding (as we've been discussing).


So, my curiosity piqued, I did some more reading.  The "Bindings"  
chapter of the Cocoa Fundamentals Guide <http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_6.html 
> also directly contradicts what I've been saying.  It unambiguously  
states that you can bind together any two objects so long as they're  
KVC/KVO-compliant.  Now _I'm_ confused -- and worried that I've been  
spreading misinformation.


Note the terminology on that page:
" You can establish a binding between an attribute of a view object  
and a property of a model object (typically through a mediating  
property of a controller object)."


It refers to an "attribute", not a property or a key or key path. So I  
am guessing that's the difference here: views override NSObject's  
default property-based binding and replace it with an attribute-based  
one. This allows two-way syncing to occur and prevents loops. Views,  
since they allow the user to make changes, go the extra step of  
propagating the change to the model as part of their binding  
implementation. Regular non-view objects don't have this, so the  
binding is one-way. They use KVC to see changes in the model value but  
not to change the model value. Am I right?


[Stuff snipped]



None of this jibes with bindings as they're used in views.  First,  
there's that reference listing the bindings supported by various  
classes.  As discussed, the list for NSTextField is decidedly  
shorter than the list of properties for which NSTextField is KVC/KVO- 
compliant.  That's generally true of most views listed in that  
reference.  Second, establishing a binding to a view is two-way,  
while establishing non-view bindings is one-way.


It's time for mmalc to chime in and put everyone straight.


Steve Weller   [EMAIL PROTECTED]
Technical Writing, Editing, Developer Guides, and a little Cocoa



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: File's Owner

2008-05-23 Thread Steve Weller


The hang up that I see is that this documentation give no clue as to  
the reason for File's Owner's existence.


What problem does it solve?

Fundamentals mean nothing unless they read like a story: you have to  
give each thing a reason to exist so that the reader has a place to  
mentally hang them.


On May 23, 2008, at 12:13 PM, Matt Long wrote:

I'm trying to figure out why the big hang up on needing to  
understand it fully. Not understanding it should not prevent you  
from developing applications. So why the hangup? What is the actual  
problem? Just set your own NSObject based app delegate as the File's  
Owner delegate in IB and start adding your code to it. That's really  
all you *need* to know.


-Matt



--
Matt Long
[EMAIL PROTECTED]
http://www.matthew-long.com/


On May 23, 2008, at 12:49 PM, Johnny Lundy <[EMAIL PROTECTED]>  
wrote:


I decided to once again go verbatim through Cocoa Fundamentals. So  
far it has been largely "uh-huh, yep", but the File's Owner, my  
nemesis, comes up again.


http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_3.html

You connect an outlet in Interface Builder, but the procedure  
starts in Xcode. The following steps describe the procedure:


When defining your custom class, declare an outlet by tagging the  
instance variable with the IBAction qualifier.
In Interface Builder, drag a generic object into the top level of  
the nib file window (if one doesn’t already exist for your custom  
class).
If an instance of your custom class is to be the File’s Owner for  
the nib file, this step is not necessary. Also, if you’re defining  
a custom NSView object, select that object instead.


Import the custom class into Interface Builder.
With the generic object (or File’s Owner) selected, type the name  
of your custom class in the Class field of the Identify pane of  
the Interface Builder inspector. This assigns your custom class as  
the class of the selected object. This step has to be done only  
once.


Select your custom instance (or File’s Owner).
Right-click or Control-click this object to display the  
connections panel.
Find your outlet under Outlets and drag a connection line from the  
circle next to the outlet to the object on the user interface that  
you want that outlet to reference.


I sent feedback on this as File's Owner is mentioned several times  
and not defined. There seems to be some huge problem with File's  
Owner. Even Aaron Hillegass says that people have trouble  
understanding File's Owner - and sure enough, when I read his  
explanation, I remained clueless.


I can follow making a generic NSObject set to my custom class, but  
why File's Owner?


My birthday is coming up and if I can understand File's Owner, I  
will consider that one of the best presents.


As usual, I can recite the documentation without understanding it :  
File's Owner is a proxy object that is set at nib load time to the  
object that loaded the nib (I don't know what object loaded my nib,  
so that does not help me). In MainMenu.nib, this is the application  
instance, which is a shared singleton instance of NSApplication  
(how all applications can share this is beyond me), which is also  
set to the global variable NSApp (uhh, OK...).


That's all well and good, but what exactly is this thing? Why would  
I succeed in having an outlet in my class if I set the Class  
Identity of File's Owner to my custom class? Why should I set  
File's Owner's Class Identity rather than the Class Identity of a  
plain NSObject that I drag out of the Library

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: A documetation suggestion (was Re: Cocoa et al as HCI usability problem)

2008-05-23 Thread Steve Weller


The documentation is for the most part oriented around the  
implementation of the technologies offered (inside out view) rather  
than the solving of the challenged faced (outside in view). For  
experts this is no great barrier, because they are already arguably  
inside. But see how this trips non-experts up and makes it hard to  
find things:



On May 23, 2008, at 3:09 AM, Gerriet M. Denkmann wrote:
Yes. I even can give you a concrete example:
I do seem to remember that there was something to write files and  
folders to a CDs using an Objective-C interface.

- entered "disk" into AppKido - nothing except NSURLCache.
- entered "disk recording" into Xcode -> Help -> Documentation -  
nothing at all
- entered "disk recording" into Spotlight - got 360 things, about  
250 are .html with names like "index-topic0.html" or similar.


Now I start reminiscing about the good old times with Digital  
Librarian:
- I would enable the Conceptual Guides or the Reference (or both)  
enter my string and am quite confident to get some references (if  
NeXTStep 3.3 only would have had disk recording).


- Ok so I open /Developer/ADC Reference Library/index.html and look  
at the choices (Note: there is no search offered). "Cocoa" (because  
I am looking for an Objective-C interface) or "Storage" look  
promising.
"Carbon" is absolutely wrong, because everybody knows that Carbon  
contains only C-APIs.


Well, the answer is of course: look under "Carbon" then "Audio" (I  
want to backup the data of my hard disk - I am not interested in  
burning audio CDs at all) - then you will see the "Disc Recording  
Framework Reference" which "Describes the Objective-C and C API for  
burning audio and data CDs and DVDs."


Yes: "Carbon", because there also is a C-API; "Audio" because it  
also can burn audio CDs.


This took me just now quite some time (almost half an hour?) to find  
(even though I have looked for it several times before).





On May 23, 2008, at 2:49 AM, Ken Thomases wrote:
Unfortunately, you've been bitten by a quirk of technical  
terminology.  Apple consistently uses "disk" with a 'k' to refer to  
magnetic storage media, and "disc" with a 'c' to refer to optical  
storage media.  If you had searched for "disc recording", you would  
have found what you needed right away.



Search fails miserably when you don't know what to search for.

Had there been problem-based top level choices not only would the  
information have been found sooner, but the error of terminology  
either never made or corrected before it became a burden. Examples of  
the kind of topics needed for beginners, the things they encounter  
very early without knowing how they are implemented:


Disks
Files
Strings
Tables
Windows
Menus
Buttons
Text fields
Fonts

There *are* some top-level topics, but the organization is odd. If I  
want to do some Cocoa Networking, do I look at Cocoa > Networking, or  
Networking > Cocoa?









___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa et al as HCI usability problem

2008-05-21 Thread Steve Weller


Scott,

Thank you for taking time to reply. You must be getting pretty tired  
of all this. Worse, this is not a documentation issue, it's an Apple  
issue.


On May 20, 2008, at 11:51 PM, Scott Anguish wrote:



[helpful pointers and other parts snipped]


Ultimately, learning is a very personal experience and we all do it  
differently. I'm not surprised that there are issues for some  
developers with the docs.  We do our best to get you what you need.


But don't you see how biased the system is against those "some  
developers" who have issues? Those are exactly the people least likely  
to complain and least likely to file bugs against the docs! And if  
they do, the bugs are unlikely to be actionable because the issues  
they are encountering are not specific enough or in the wrong terms.  
If you experience just a tiny teeny number of people who voice  
usability problems with such a powerful filter in place then you know  
that the problem is large and real.


Don't you see how different the learning experience is for 100,000  
iPhone developers in 2008 vs. a few hundred Next developers twenty  
years ago? And the differences in motivation? And background? And  
sponsorship?


Scott, you *are* doing your best, and you are doing a great job with  
what you have. But I feel that there is a part of Apple that is in a  
state of denial, and until that changes, we're stuck with bug reports  
as a means of trying to change corporate vision.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa et al as HCI usability problem

2008-05-20 Thread Steve Weller
However you slice it and whatever your personal experience, I believe  
that what we are experiencing with the docs are the early symptoms of  
massive scaling of the problem vs. insufficient scaling of the  
resources to tackle it. If anyone can fix this, it is Apple.


If you care to invest the time, I have 3400 words on the subject here:

http://www.bagelturf.com/files/8f2cab87e2f633752047fcac70643352-1179.php


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Learning Curve/Documentation Challenge/Recommendation

2008-05-17 Thread Steve Weller


On May 17, 2008, at 7:19 AM, Hamish Allan wrote:


On Sat, May 17, 2008 at 3:03 PM, colo <[EMAIL PROTECTED]> wrote:


F-Script [...] gives you the code to Create a window from scratch
and logically place the buttons on the window by coordinates. That
kind of "knowing" how to make a window without IB is priceless to me
imo.


I know you're never going to believe us about this, but it would be
much more valuable for you to stop fighting the Cocoa way and forget
about constructing windows in code until you absolutely need to...

Hamish


Of course, but that is not what is going on here.

He's quite happy to walk across the floor, but knowing how the floor  
is constructed adds enormously to his confidence of doing so. Don't  
forget this is an unfamiliar building, a type of which he has not  
encountered before.


It's a different learning and understanding style that cannot be  
dismissed by calling it fighting. If he were to refuse to touch  
anything but the green tiles and make bridges out of chairs and tables  
to sustain that, well that would certainly be fighting.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to import drawing paths into a Cocoa application?

2008-04-26 Thread Steve Weller


On Apr 21, 2008, at 5:23 PM, Steve Weller wrote:



I my app I want to be able to use drawing paths for two purposes:

1. Clip images to the path

2. Generate points that lie on the path as a function of the  
distance along the path


I want to be able to create paths with Omnigraffle or some other  
vector-image app, and export them to PDF or EPS or equivalent  
format. The objects I am dealing with could have multiple path  
segments and/or paths that intersect themselves and each other. I  
will probably use Quartz rather than Cocoa drawing.


I expected to see a class method for NSBezierPath that would grab a  
path from a file, but it is not there. So:


1. What file format should I use to store my paths?

2. How do I get the path into an object that I can use?

I can clip images to a path by using the addClip method on the  
NSBezierPath. Are there any easy ways of calculating the points on  
the path as a function of the distance from the start of the path?


Having researched #2 above and found a number of resources that say  
"It's not trivial", I encountered the developer example code for  
Voyeur. It's an app that looks inside PDFs and extracts, lists, and  
renders them. So there is a decent example, but it is certainly not  
trivial. Carbon and Quartz. I pretty much expected to be working in  
Quartz, but it looks like there are no nice Cocoa classes to help me.

___

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

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

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

This email sent to [EMAIL PROTECTED]


How to import drawing paths into a Cocoa application?

2008-04-21 Thread Steve Weller


I my app I want to be able to use drawing paths for two purposes:

1. Clip images to the path

2. Generate points that lie on the path as a function of the distance  
along the path


I want to be able to create paths with Omnigraffle or some other  
vector-image app, and export them to PDF or EPS or equivalent format.  
The objects I am dealing with could have multiple path segments and/or  
paths that intersect themselves and each other. I will probably use  
Quartz rather than Cocoa drawing.


I expected to see a class method for NSBezierPath that would grab a  
path from a file, but it is not there. So:


1. What file format should I use to store my paths?

2. How do I get the path into an object that I can use?

I can clip images to a path by using the addClip method on the  
NSBezierPath. Are there any easy ways of calculating the points on the  
path as a function of the distance from the start of the path?



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSPopupButton Bindings

2008-04-19 Thread Steve Weller



On Apr 19, 2008, at 5:58 PM, Johnny Lundy wrote:


Good evening,

I am having trouble understanding the bindings for NSPopupButton.

View: NSPopupButton
Controller: NSArrayController, just for the popup button
Model: NSMutableArray of NSMutableDictionaries.


I have the array controller bound to the array in the model, and  
that is working fine.


My question is: which one of these multiple bindings do I want if I  
want to have either the popup button's selectedIndex or the actual  
mutableDictionary at that index passed to my method (I am using  
another NSButton to invoke the method using the selection of the  
array controller as an argument).


So far I am getting the proper strings in the popup, but what is  
getting passed to the method looks like the [dictionary description]  
of the first item in the model array, no matter what I select in the  
popupButton.


I've spent the whole day scouring the docs for some guidance in  
which of the (Content, Content Objects, Content Values, Selected  
Index, Selected Object, and Selected Value) to use in order to send  
the model array element (or its index, I can deal with either) as an  
argument to my method.


I just use the action to get the value I need. For instance, this is  
the action for a pop-up that displays a list of ways a list can be  
sorted. I set up the list dynamically and use bindings to keep the  
view up to date. When an item is selected the action goes here:


// Sort order actions
-(IBAction)sortOrderPopupAction:(id)sender;
{

[self setSortName:[[sender selectedItem] title]];
[self reSortByName:sortName ascending:sortAscendingOrder];
}

Using the title is not 100% safe since that can change with the  
language.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to use bindings with IKImageBrowserView?

2008-04-04 Thread Steve Weller


On Apr 4, 2008, at 2:18 PM, Adam Gerson wrote:

It does work. I have defined a core data entity that conforms to
IKBrowerItem protocol and my IKImageBrowserView is working with
bindings. I think you still need to point the delegate and data source
outlets to an object that implements the datasource methods:


Are you doing the below plus bindings? That makes no sense to me.

The code below is using the array controller as its data source. That  
means you have to manually use reloadData I assume. My goal is to  
update a store of images that is KVO/KVC compliant and have the view  
update automatically as images are added and removed.







//  
-

//  numberOfItemsInImageBrowser:view
//  
-

- (int)numberOfItemsInImageBrowser:(IKImageBrowserView*)view
{
// The item count to display is the datadsource item count.
   return [[imageBrowserArrayController arrangedObjects] count];
}

//  
-

//  imageBrowser:view:index:
//  
-

- (id)imageBrowser:(IKImageBrowserView *) view itemAtIndex:(int) index
{
   return [[imageBrowserArrayController arrangedObjects]  
objectAtIndex:index];

}


// Implement some optional methods of the image browser  datasource
protocol to allow for removing and reodering items.

//  
-

//  removeItemsAtIndexes:
//
//  The user wants to delete images, so remove these entries from the
data source.
//  
-

- (void)imageBrowser:(IKImageBrowserView*)view removeItemsAtIndexes:
(NSIndexSet*)indexes
{
	[imageBrowserArrayController  
removeObjectsAtArrangedObjectIndexes:indexes];

}


On Fri, Apr 4, 2008 at 1:01 AM, Steve Weller <[EMAIL PROTECTED]>  
wrote:


I am attempting to use bindings to supply an IKImageBrowserView  
with data.
I have successfully used IKImageBrowserView with a data source, but  
cannot

get bindings to work. Should it work with bindings?

The array controller's contentArray is hooked up to an NSMutableArray
called storedImages. That contains instances of storedImage. And  
those have
a method browserObject that returns instances of an object that  
implements
the IKBrowerItem protocol to fetch and display an image (uid, path,  
etc).


The Image Kit browser is bound to the array controller's arranged  
objects
with the model key path browserObject. It is set to automatically  
prepare

content.

I get no images displayed even though there are plenty in the  
storedImages

array. I am telling the browser view to reload its data.

If I set a breakpoint at browserObject, it is never hit. So it  
looks like
the array controller is never attempting to read my model. I get no  
errors

when loading my nib.


--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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/agersonl%40gmail.com

This email sent to [EMAIL PROTECTED]



--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]


How to use bindings with IKImageBrowserView?

2008-04-03 Thread Steve Weller


I am attempting to use bindings to supply an IKImageBrowserView with  
data. I have successfully used IKImageBrowserView with a data source,  
but cannot get bindings to work. Should it work with bindings?


The array controller's contentArray is hooked up to an NSMutableArray  
called storedImages. That contains instances of storedImage. And those  
have a method browserObject that returns instances of an object that  
implements the IKBrowerItem protocol to fetch and display an image  
(uid, path, etc).


The Image Kit browser is bound to the array controller's arranged  
objects with the model key path browserObject. It is set to  
automatically prepare content.


I get no images displayed even though there are plenty in the  
storedImages array. I am telling the browser view to reload its data.


If I set a breakpoint at browserObject, it is never hit. So it looks  
like the array controller is never attempting to read my model. I get  
no errors when loading my nib.



--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]


Re: NSScroller question

2008-03-29 Thread Steve Weller


Try looking at the source for TextEdit. TextEdit adds a pop-up at the  
end of the horizontal scroller by overriding NSScrollView's tile:  
method. You may be able to change the layout so that the end of the  
NSScroller is clipped off.


On Mar 29, 2008, at 4:57 AM, [EMAIL PROTECTED] wrote:

Thanks Troy for the in-depth account. Yes, my goal is to customize the
scroller's appearance, and yes, I wish this process involved less
guess-work. As you say, there is no empty space when you let the
scroller draw normally. You only see this when drawing a custom
scroller based on the rects returned by -rectForPart:. That makes
sense as those rects, as you say, are for hit-testing purposes only.
Hence NSScrollerKnobSlot does not return the full rect for the slot,
only the clickable part. I currently modify the rects returned by
-rectForPart: for my drawings (eg. adjust the height and y position to
cover the empty space), but I suppose calculating the parts based on
the rect from the -drawRect: method would be even easier. My problem
is I have a transparent table view and would prefer not to a have a
slot for the knob at all, just a vertical scroller that goes all the
way up to the edge of the table's header view, but it seems this is
not possible. I can draw the knob in the designated slot cap area, but
the drawing is messed up whenever the view is redisplayed. Oh well,
the gap is only a few pixels, no big deal.

On Fri, Mar 28, 2008 at 5:44 PM, Troy Stephens <[EMAIL PROTECTED]>  
wrote:

As Hamish Allan pointed out, a scroller has logical "parts", but they
are not subviews.  -rectForPart: returns the bounding rects that are
used for hit-testing those parts.  In the olden days of OpenStep- 
style
Scrollers and their purely rectangular parts, these were exact and  
the

same rects used for drawing.  On Mac OS X, they are only hit testing
bounding rects (since Scrollers now have curved parts), and do not
affect drawing of the Scroller, only hit-testing.

So all that rectForPart:NSScrollerNoParts is telling you is that
there's a skinny rect at the top of the scroller that is not  
sensitive

to hit-testing.  That makes sense, since there is a nonreactive end
cap on the scroll track that has no arrow (when Appearance prefs are
set for the scroll arrows to be shown "Together" at the other end).
This isn't an "empty" space when you let the scroller draw normally
though -- there's art there, or at least there should be.  If you're
seeing otherwise, something else must be wrong.  Can you clarify
whether you're seeing this when the scroller draws normally, or only
with your test drawing based on the -rectForPart: results in place?

If your goal is to subclass NSScroller to customize its appearance, I
should add that the -drawParts and -drawArrow:highlight: methods are
obsolete and is no longer invoked by NSScroller's drawing code.   
Those

methods should be deprecated.  There are some other difficulties with
customizing Scroller appearance using the existing API, and we have  
at

least one request to make that easier in the future.



On Mar 27, 2008, at 6:17 PM, [EMAIL PROTECTED] wrote:

Yes, I meant scroller, not slider. Just had a glass of wine too
much :-)

Actually I don't want to add an accessory view, I want to get rid of
the one that appears to be there by default. I have attached a
screenshot showing what I'm talking about. The yellow part is the
knob, drawn by filling the rect return by calling [self
rectForPart:NSScrollerKnob]. The green part is the slot,  [self
rectForPart:NSScrollerKnobSlot]. The white part above the slot is by
default black, but here I made it white by filling the rect returned
by calling [self rectForPart:NSScrollerNoParts].

I can move the knob/slot upwards by tampering with their designated
rects ("rect.origin.y -= 5"), thus hiding the white part. But that
messes up the drawing when the view is updated.

I figured the white part was a view, but since you are telling me
NSScroller has no subviews I really don't know what to think. Maybe
there is something wrong with my implementation?

@implementation TestScroller

- (void)drawRect:(NSRect)rect
{
 [self drawKnobSlot];
 [self drawKnob];
}

- (void)drawKnob
{
 NSRect rect = [self rectForPart:NSScrollerKnob];
 [[NSColor yellowColor] set];
 [NSBezierPath fillRect:rect];
}

- (void)drawKnobSlot
{
 NSRect rect = [self rectForPart:NSScrollerKnobSlot];
 [[NSColor greenColor] set];
 [NSBezierPath fillRect:rect];
}

@end

On Fri, Mar 28, 2008 at 12:41 AM, Troy Stephens
<[EMAIL PROTECTED]> wrote:


On Mar 27, 2008, at 4:26 PM, [EMAIL PROTECTED] wrote:

Thanks, but the corner view is the right side corner of the header
view, right? I was talking about the small view just below it, on
top
of the vertical slider and part of the slider itself. It's a tiny
view
of about 2 pixels height. I believe it corresponds to
NSScrollerNoPart, but I'm not sure.


(By "slider" I take it you really mean "scroller", as NSSlider is
someth

Re: Communications between multiple NIB's

2008-03-29 Thread Steve Weller


On Mar 28, 2008, at 11:27 AM, Lincoln Green wrote:
I followed your suggestion, and it worked great! However, when I  
delete the preferences file form /Library/Preferences/, my  
application won't put up a window. Any suggestions to get around this?


Check the console window in Xcode and then start debugging.

Of course I didn't post all my code, so you may have failed to  
initialize NSUserDefaults yourself. Here is what I have in my app  
controller:


// Early set up
+ (void)initialize
{
// Set up initial defaults
NSDictionary *defaultValues = [NSDictionary  
dictionaryWithObjectsAndKeys:
		 [NSArchiver archivedDataWithRootObject:[NSColor whiteColor]],  
@"browserBackgroundColor",

[NSNumber numberWithInteger:1], PrefsVersion,
 [NSNumber numberWithInteger:1], AppVersion,
 nil];

// Set up default values for preferences managed by  
NSUserDefaultsController
[[NSUserDefaults standardUserDefaults]  
registerDefaults:defaultValues];





___

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

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

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

This email sent to [EMAIL PROTECTED]


--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]


Re: Communications between multiple NIB's

2008-03-24 Thread Steve Weller


On Mar 24, 2008, at 3:27 PM, Gerd Knops wrote:

Is there a way to programmatically connect to a NIB file and read  
it's

outlets without changing my File's Owner? I have a color well in one
NIB (My Prefs NIB) and a window in another. I want the color well to
change the window's background. I have an action called setColor:,  
but

I cannot figure out how to access the window outlet from the NIB
containing the window. Please help!


I use a different approach -- it may not be the "right" one, but it  
works for me. In my case I have a gray slider in a prefs panel. In IB  
I bind that to Shared User Defaults and provide Controller Key  
"values" and Model Key Path "browserBackgroundGray". That deals with  
everything except updating the browser view.


In the prefs pane window controller I do this:

- (IBAction)browserBackgroundGrayAction:(id)sender;
{
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
	[center postNotificationName:@"browserBackgroundColorChanged"  
object:self];


}

In the browser view controller I do this:

// Observe changes in browser background color
-(void)startObservingChanges;
{
// Register to observe notifications of background color changes
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
	[center addObserver:self  
selector:@selector(browserBackgroundColorChange:)  
name:@"browserBackgroundColorChanged" object:nil];

}

-(void)stopObservingChanges;
{
//
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center removeObserver:self];

}

These are called by appropriate methods that the window controller  
makes.


I implement the color change like this:

// Handle browser background color notification
-(void)browserBackgroundColorChange:(NSNotification*)note;
{
float grayValue;
NSColor *color;
	grayValue = [[NSUserDefaults standardUserDefaults]  
floatForKey:@"browserBackgroundGray"];
	color = [NSColor colorWithCalibratedRed:grayValue green:grayValue  
blue:grayValue alpha:1.0];

[browserView setValue:color forKey:IKImageBrowserBackgroundColorKey];   

[browserView setNeedsDisplay:YES];  
}

In my multiple document application this changes the background of the  
browser in all documents at once.





Given you are talking preferences, you probably do not want a direct  
connection at all but rather use the user defaults system as middle  
man, which has the additional benefit that it will save the color  
for you:


In IB select the Bindings info for your color well, and bind the  
value as follows:


Bind to: Shared Defaults
Model Key Path: myWindowBackgroundColor (or whatever)
Value Transformer: NSUnachiveFromData

Now somewhere in your application you probably want to set an  
initial default, like so:


+ (void)initialize {

//
// Register initial defaults
//
NSMutableDictionary *defaults=[NSMutableDictionary dictionary];

	[defaults setObject:[NSArchiver archivedDataWithRootObject:[NSColor  
windowBackgroundColor]] forKey:@"myWindowBackgroundColor"];

// Set other initial defaults here

[[NSUserDefaults standardUserDefaults]registerDefaults:defaults];
}


Now in your window or window controller class you want to get  
notified when that color is changed. So somewhere in -init or - 
awakeFromNib add this:


	[[NSUserDefaultsController  
sharedUserDefaultsController]addObserver:self

forKeyPath:@"values.myWindowBackgroundColor"
options:0
context:nil];   

In the same class you need to implement an observer method like so:

- (void)observeValueForKeyPath:(NSString*)keyPath
 ofObject:(id)object
   change:(NSDictionary*)change
  context:(void*)context
{
if([keyPath isEqualToString:@"values.myWindowBackgroundColor"])
{
[self setBackgroundColorFromDefaults];
}
}


And finally the method that sets the color:

- (void)setBackgroundColorFromDefaults {

NSUserDefaults  *ud=[NSUserDefaults standardUserDefaults];
	NSColor		*bgColor=[NSUnarchiver unarchiveObjectWithData:[ud  
dataForKey:@"myWindowBackgroundColor"]];


[self setColor:bgColor];
}

As last step you should probably call setBackgroundColorFromDefaults  
somewhere early in your code so that your window start out with the  
right color.


Alternatively don't set the color at all, but have the observer  
trigger a redraw, and in the drawing code read the color from the  
defaults.


Hope that helps!

Gerd


___

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

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

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

Re: Correct use of NSViewController

2008-03-21 Thread Steve Weller


On Mar 21, 2008, at 2:31 PM, Cathy Shive wrote:
1,  window is about to close (wish there was a more reliable place  
to do this, but it has to be before dealloc):


windowController:

- (void)windowWillClose
{
	[mViewController removeObservations]; // this causes the method to  
be called all the way down the view controller tree

}

2.  view controller removes it's observations

viewController:

- (void)removeObservations
{
[wArrayController removeObserver:self forKeyPath:@"selectedObjects"];
[super removeObservations];
}

3.  The document closes and the window controller is released and  
dealloced:


window controller:
- (void)dealloc
{
[mViewController release];
[super dealloc];
}

3.  The first view controller is released and dealloced:

viewController:
- (void)dealloc
{
[mSubcontrollers release];
[super dealloc];
}


I do a very similar thing, but name things differently. Instead of  
telling the lower objects what to do (remove observations) I tell them  
what is happening at the high level so they can do their own thing  
based on that (window is closing.. so I'll remove my observers). This  
lets me keep everything out of dealloc except for memory management.  
In that way if I switch to GC it will still work.



--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]


Re: Correct use of NSViewController

2008-03-21 Thread Steve Weller


I'm going down this same path I think. I have a split view with a  
browser and a document. The way I solve it is to have the window  
controller have outlets to the scroll views of the two panes of the  
split view. Then in the window controller I do this:


- (void)windowDidLoad {
[super windowDidLoad];

// Create the browser view controller and give it its data source
	browserViewController = [[BTPPBrowserViewController alloc]  
initWithScrollView:browserScroller];

[browserViewController setDataSource:[[self document] imageStorage]];
[browserViewController windowDidLoad];  // Allow controller to set up


I split the initialization into two parts: the initialization of the  
view controller where I provide the superview, and the the  
windowDidLoad method where I let it finish setting up now it has its  
data source (owned by the document). To tear it down I use:


// Window will close
-(void)windowWillClose:(NSNotification *)notification;
{
// Tell all the view controllers that the window will close
[browserViewController windowWillClose];
}

Of course I will add more view controllers as I create them.

My view controllers hide the view implementation from the higher  
levels. My browser is an IKBrowwserView, so I have limited control  
over it.


Of course I am still learning, so all of this may be fatally flawed


On Mar 20, 2008, at 2:53 AM, Cathy Shive wrote:


Jonathan,

I just wanted to say one more thing.  I was re-reading what you had  
written and I see the problem you're having with setting up the  
frame for that first split view.


The problem isn't just the set up of your view controllers and the  
order of creating/adding views, you're also dealing with the issue  
of setting an auto-resizing mask for your view.  Wouldn't it be  
great if your view controller for the split view could just  
configure the view to "fill" it's size to match the size of it's  
superview instead of having to explicitly size and position it when  
it's created?  This is a flaw in this system.  The sub view  
controller has to be able to access the view of its super controller  
so that it can inspect its frame.   With the way autoresizing  
currently works in NSView, you're never going to get around this.


So the part of my system that I haven't described, because I just  
realized that it is important to this issue, is that I have coded my  
own resizing behavior into my NSView subclass to add these kinds of  
features.  I have a "FillWidthAndHeight" option, for instance (I use  
this one most often). This way I don't have to know the super view's  
frame when I add a subview.  At the end of the original window  
controller's init method, I just reset the frame of the window, and  
NSView goes through the view hierarchy and they all size themselves  
correctly within their superviews.  In fact, when I create my views,  
many of them are initialized with an NSZeroRect and the first thing  
my window controller does is set the content view of the window to  
be one of my NSView subclasses.  This topic is much more difficult  
to tackle, but if you want a truly dynamic view system, your view  
code needs to be able to work without any prior knowledge about the  
super view's and sibling view's frames.


IMHO, this is the the Pandora's Box when it comes to working with  
the view hierarchy.  The standard autoresizing mechanism isn't  
really built to handle dynamic layout changes.  You always have to  
know the exact size of your view and its position within its  
superview (and sometimes the size and position of sibling views)  
before you set it.


If you need to program a complex, dynamic view system where sizing  
and positioning managed in the code, first subclass NSView and  
figure out a way to deal with autoresizing.  Maybe this is a bigger  
project than you have time take on right now and maybe its  
unnecessary for the scope of your project, but you're going to bang  
your head against this issue over and over again as you develop more  
dynamic layouts.


It's important to keep in mind the fact that NSView's autoresizing  
and NSWindowController were created to support interfaces that get  
laid out in IB and don't change much after their awake from nib state.


I really hope that I haven't made the issue more complicated for you!

Cathy


On Mar 20, 2008, at 2:19 AM, Jonathan Dann wrote:


Hi Cathy,

Thanks for the comprehensive answer to my question, I wanted to  
make sure that I wasn't committing heresy by going down the 'tree  
of view controllers' road before jumping in and refactoring all my  
code.  I was hoping to set it up so I could forget about most of  
the memory management as I'm replacing views all over the place at  
runtime.


Out of interest, when I add my main split view, I then have to set  
its size to fit my document window's content view.  As this task is  
view-related it seems like it the split view's NSViewController  
sh

Re: Printing Page Orientation

2008-03-18 Thread Steve Weller


On Mar 18, 2008, at 8:31 PM, John Bishop wrote:

Anyone know how to change the printing page orientation or scaling  
in Xcode 3.0 for data model diagrams (or any other printing task in  
Xcode)?  It used to be available in Page Setup, but that disappeared  
in 3.0.


Thanks.


I would like to know this too. Now that the printing architecture has  
changed some things are not possible. Setting up a large custom paper  
size does not work (at least for me). I just get small page images in  
the center of regular sized paper. The print scale factor setting does  
not permit large factors so that will not work either. I even tried  
CUPS-PDF, with no change in behavior.


--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]


Re: User Defaults Controller - IB

2008-03-18 Thread Steve Weller
Check out http://cocoacast.com/, in particular episodes 14, 15, 16 for  
prefs (and notifications). The example they show does not use  
bindings, but by binding the view objects you can scrap much of the  
code.


Also see http://developer.apple.com/documentation/Cocoa/Conceptual/DrawColor/Tasks/StoringNSColorInDefaults.html 
 for binding example and for how to deal with colors or other complex  
objects.


On Mar 18, 2008, at 5:09 PM, Jeremy wrote:


Hello,

I am working on a 10.5 only application. Now I want to start adding  
and using preferences in my code. This is my first MAJOR application  
and the first one to use preferences. How can I use the new "User  
Defaults Controller" and assign variables to it? My book isn't very  
helpful because it is all using custom classes. Help please. :D


Jeremy Dentel
"For a long time it puzzled me how something so expensive, so  
leading edge, could be so useless, and then it occurred to me that a  
computer is a stupid machine with the ability to do incredibly smart  
things, while computer programmers are smart people with the ability  
to do incredibly stupid things. They are, in short, a perfect  
match." - Bill Bryson



___

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

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

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

This email sent to [EMAIL PROTECTED]


--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]


NSDocument and control of multiple views

2008-03-02 Thread Steve Weller


I have a document-based application that has a custom view that fills  
much of the content view. In that custom view I want to display a  
"page" like a piece of paper. As the window is scaled, the "page"  
scales. This all works either if I code the page as a part of the  
custom view, or if I set it up as another custom view which is a  
subview of the larger view.


But which is the better approach? I will want to work at two scales at  
all times: the scale on the page and the scale on the custom view.  
Will a subview make that easier?


If I do use a subview, then what should my philosophy be for  
communicating among objects? I *think* that the NSDocument should  
manage both views. If the user resizes the window, that will resize  
the frame of the custom view. That will send a notification to the  
NSDocument which will make the appropriate changes to both views  
(scaling, bounds, whatever). Or is there a better way?


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Subview bounds resizing when frame resizes

2008-03-02 Thread Steve Weller


On Mar 2, 2008, at 4:03 PM, Steve Weller wrote:



I have a custom view with a custom subview. I can't seem t make the  
bounds of the subview stick. When the view changes the subview's  
frame, I want the subview's bounds to stay exactly as I set them the  
first time. The whole point of having this subview is to have a  
separate coordinate system.


I create the subview like this:

// Add page into our view
pageView = [[BTPPPageView alloc] initWithFrame:[self pageFrame]];
	[pageView  
setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];

[self addSubview:pageView];

and I reposition the subview's frame when the view's frame changes:

[pageView setFrame:[self pageFrame]];

The subview bounds are set correctly at the start, but if I make the  
subview's frame larger, the bounds are scaled larger too. I thought  
from this in the NSView docs that the subview's bounds would stay  
fixed:


If your view does not use a custom bounds rectangle, this method  
also sets your view bounds to match the size of the new frame. You  
specify a custom bounds rectangle by calling setBounds:,  
setBoundsOrigin:, setBoundsRotation:, or setBoundsSize:explicitly.  
Once set, NSView creates an internal transform to convert from frame  
coordinates to bounds coordinates.


I am using setBounds, so why is it not preventing the scaling? My  
view has the Autoresizes subviews flag off. The view is created in  
IB, the subview in code, as above.



Having discovered that all uses of setFrame that I could find that  
handle scaling reset the bounds every time, I changed the code to:


[pageView setFrame:[self pageFrame]];
[pageView  
setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];


and this achieves what I wanted to do.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Subview bounds resizing when frame resizes

2008-03-02 Thread Steve Weller


I have a custom view with a custom subview. I can't seem t make the  
bounds of the subview stick. When the view changes the subview's  
frame, I want the subview's bounds to stay exactly as I set them the  
first time. The whole point of having this subview is to have a  
separate coordinate system.


I create the subview like this:

// Add page into our view
pageView = [[BTPPPageView alloc] initWithFrame:[self pageFrame]];
	[pageView  
setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];

[self addSubview:pageView];

and I reposition the subview's frame when the view's frame changes:

[pageView setFrame:[self pageFrame]];

The subview bounds are set correctly at the start, but if I make the  
subview's frame larger, the bounds are scaled larger too. I thought  
from this in the NSView docs that the subview's bounds would stay fixed:


If your view does not use a custom bounds rectangle, this method also  
sets your view bounds to match the size of the new frame. You specify  
a custom bounds rectangle by calling setBounds:, setBoundsOrigin:,  
setBoundsRotation:, or setBoundsSize:explicitly. Once set, NSView  
creates an internal transform to convert from frame coordinates to  
bounds coordinates.


I am using setBounds, so why is it not preventing the scaling? My view  
has the Autoresizes subviews flag off. The view is created in IB, the  
subview in code, as above.


--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]


Re: Scrollers on custom view appearing but not disappearing

2008-03-01 Thread Steve Weller


On Feb 29, 2008, at 10:33 PM, Quincey Morris wrote:


A couple of small points:

-- It's not quite correct to use the superview's frame to calculate  
a view's frame, since they are in different coordinate systems. You  
really should use [[self superview] bounds], which is in the same  
coordinate system as [self frame].


The problem is harmless in this case, because the superview is a  
NSClipView, which happens to keep its frame coordinate system  
synchronized with that of view it contains, but this is not  
generally true of view-superview geometry.


-- If you want to refer to the clip view, [[self  
enclosingScrollView] contentView] is more correct than [self  
superview]. The fact that they're the same thing is an  
implementation detail. (But if you're going to pretend not to know  
they're the same you really should do an explicit coordinate  
conversion when combining their dimensions.)


-- As someone suggested on this list a few weeks ago, it's perhaps  
marginally more elegant to use [self visibleRect] instead of the  
clip view bounds. Although the purpose of the clip view is to manage  
the visible rect of the view it contains, using the visible rect  
directly means you don't have to build in knowledge of that  
implementation detail. And there's no coordinate conversion needed.



Thank you. All very helpful information. I have incorporated the  
changes, added origin offsetting to keep things central, and it works  
perfectly. The last change I made was to manually send the  
notification once the content parameters were set up. That ensured  
that the scrollers appeared when the window was first created.



--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]


Re: Scrollers on custom view appearing but not disappearing

2008-02-29 Thread Steve Weller


On Feb 29, 2008, at 4:00 PM, Steve Weller wrote:



I have a custom view into which I can draw a background color and a  
centered rectangle. As the window is resized, the rectangle stays  
centered and is clipped when the window gets small.


I want to define a canvas size slightly bigger than the rectangle  
and have the scrollers appear when the available space is less than  
the canvas needs. I override setFrameSize to do this:


- (void) setFrameSize:(NSSize)newSize
{
NSSize cSize;
cSize = [self canvasSize];   // Provides a size

// Use the larger dimensions of the two rects
if(newSize.width > cSize.width)
cSize.width = newSize.width;
if(newSize.height > cSize.height)
cSize.height = newSize.height;

 [super setFrameSize:cSize];
}

And this works as long as the window is only made smaller. If the  
window is made larger then the scrollers do not disappear.


Is my approach the right one for what I am trying to achieve?

If it is, how can I fix the scroller problem?


I figured it out. Key to my confusion was that I was not involving the  
superview in the calculation.

In my -awakeFromNib I put this code:

// Receive notifications if the frame changes
[self setPostsBoundsChangedNotifications: YES];

NSNotificationCenter *center = [NSNotificationCenter defaultCenter] ;
[center addObserver: self
   selector: @selector(frameDidChangeNotification:)
   name: NSViewFrameDidChangeNotification
 object: self];

NSSize cSize;
cSize = [self canvasSize];
[self setFrame:NSMakeRect(0,0,cSize.width,cSize.height)];

and I added

// The frame has changed
-(void)frameDidChangeNotification:(NSNotification *)notification
{

[[NSNotificationCenter defaultCenter] removeObserver: self];
NSRect frame = [[self superview] frame];
NSSize cSize;
cSize = [self canvasSize];

// Use the larger dimensions of the canvas and the superview
if(frame.size.width > cSize.width)
cSize.width = frame.size.width; 
if(frame.size.height > cSize.height)
cSize.height = frame.size.height;

	[self  
setFrame:NSMakeRect 
(frame.origin.x,frame.origin.y,cSize.width,cSize.height)];

//  NSLog(@"%f %f",newSize.width, newSize.height);

NSNotificationCenter *center = [NSNotificationCenter defaultCenter] ;
[center addObserver: self
   selector: @selector(frameDidChangeNotification:)
   name: NSViewFrameDidChangeNotification
 object: self];

}

This figures out the rectangle that encloses both the canvas and the  
superview's frame and makes my custom view's frame equal to that. The  
only remaining thing to fix is that the lower left point is always  
shown in the view, when I actually want the center point to be shown.  
So I have to shift the frame origin as part of the calculation.




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Scrollers on custom view appearing but not disappearing

2008-02-29 Thread Steve Weller


On Feb 29, 2008, at 4:46 PM, Quincey Morris wrote:



On Feb 29, 2008, at 16:00, Steve Weller wrote:


- (void) setFrameSize:(NSSize)newSize
{
NSSize cSize;
cSize = [self canvasSize];   // Provides a size

// Use the larger dimensions of the two rects
if(newSize.width > cSize.width)
cSize.width = newSize.width;
if(newSize.height > cSize.height)
cSize.height = newSize.height;

 [super setFrameSize:cSize];
}

And this works as long as the window is only made smaller. If the  
window is made larger then the scrollers do not disappear.


Is my approach the right one for what I am trying to achieve?


Probably not. There are various ways the view frame can change, and  
they don't all funnel through the setFrameSize method.


If you register to receive NSViewFrameDidChangeNotification's for  
your view (remembering to call setPostsFrameChangedNotifications:  
YES), it might work to do something like this in the notification  
method:


[[NSNotificationCenter defaultCenter] removeObserver: self];
NSRect frame = [self frame];
// calculate new frame
[self setFrame: frame];
[[NSNotificationCenter defaultCenter] addObserver: self ...




I implemented this with no change no behavior.

The higher level problem I am trying to solve is this:

My custom view spans the window's content view. I want to draw a white  
rectangle (think of a document) centered in that area and fill the  
remainder gray. In my drawRect method I first draw gray into the  
rectangle passed. Then I calculate where the white rectangle should be  
and draw it.


I need the scrollers to act on the bounds of the white rectangle so  
that they are present when any part of it is not visible.


Should I be putting my custom view inside another view and doing the  
centering and background color with IB instead?


What is the best way of implementing this?


___

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

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

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

This email sent to [EMAIL PROTECTED]


Scrollers on custom view appearing but not disappearing

2008-02-29 Thread Steve Weller


I have a custom view into which I can draw a background color and a  
centered rectangle. As the window is resized, the rectangle stays  
centered and is clipped when the window gets small.


I want to define a canvas size slightly bigger than the rectangle and  
have the scrollers appear when the available space is less than the  
canvas needs. I override setFrameSize to do this:


- (void) setFrameSize:(NSSize)newSize
{
NSSize cSize;
cSize = [self canvasSize];   // Provides a size

// Use the larger dimensions of the two rects
if(newSize.width > cSize.width)
cSize.width = newSize.width;
if(newSize.height > cSize.height)
cSize.height = newSize.height;

 [super setFrameSize:cSize];
}

And this works as long as the window is only made smaller. If the  
window is made larger then the scrollers do not disappear.


Is my approach the right one for what I am trying to achieve?

If it is, how can I fix the scroller problem?

--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]