Re: Methods that return autoreleased objects?

2008-06-28 Thread mmalc crawford


On Jun 28, 2008, at 9:59 PM, Charles Srstka wrote:

Methods that begin with "alloc" or "new" or contain "copy" will  
return objects you are responsible for. All other objects returned  
from methods are taken care of.


Well, there is the notable exception of top-level objects loaded  
from a NIB file, which do need to be released.



... which is documented:
	


mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Garbage Collection woes...

2008-06-28 Thread Stephen J. Butler
On Fri, Jun 27, 2008 at 2:31 PM, John Engelhart
<[EMAIL PROTECTED]> wrote:
> Lesson #2:  Since there is so little documentation about the GC system, this
> involves a lot of speculation, but I think it summarizes what's really going
> on.  This all started with an effort to keep a __weak reference to a passed
> in string that was used to initialize an element in a cache.  When the cache
> was checked, if that weak reference was NULL, then the cache line is invalid
> and should be cleared.  The cache consisted of a global array of elements,
> selection was done via KEY_STRING_HASH % CACHE_SIZE, and everything was
> under a mutex lock.  An approximation of the cache is:
>
> typedef struct {
>  NSString *aString;
>  __weak NSString *aWeakString;
>  NSInteger anInteger;
> } MYStructType;
>
> MYStructType globalStructTypeArray[42]; // <-- Global!
>
> Simple, right?  That's how it always starts out...  The first problem
> encountered was:
>
> [EMAIL PROTECTED] /tmp% gcc -o Global_GC Global_GC.m -framework Foundation
> -fobjc-gc
> Global_GC.m:14: warning: __weak attribute cannot be specified on a field
> declaration
>
> (The attached file contains the full example demonstrating the problem.)
>
> I'm not really sure what this means, and I don't recall reading anything in
> the documentation that would suggest anything is amiss.  I never actually
> managed to figure out what, if any, problem this causes because it quickly
> became apparent that there was a much bigger problem that needed dealing
> with:

Speculation: __weak needs a read-barrier as well as a write-barrier,
and with structs people have a long history of reading them without
going through the accessor. This isn't generally a problem for
__strong and write barriers because for all of this to work you need
to make sure that the memory for MYStructType is GC scanned anyway.

> The pointer to 'aString' in the above (or any of my other __strong pointers
> in my actual code) were clearly not being treated as __strong, and the GC
> system was reclaiming them causing all sorts of fun and random crashes.
>
> The documentation states: The initial root set of objects is comprised of
> global variables, stack variables, and objects with external references.
> These objects are never considered as garbage.

This is kind of a lie since not ALL global memory is treated as
collectable. Hence the need for special assigns.

> Putting the pieces together, it became obvious what was really going on.
>  The two commented out lines in the example that update the global variable
> are the key to the mystery and make everything work as expected.
>
> It turns out that when the documentation says that "root set of objects is
> comprised of global variables", it's true, but probably not in the way that
> you think it is.
>
> It would 'seem' that global variables are only __strong when the compiler
> can reason that you're referring to a global variable directly. In this
> particular case, that would be:
>
> globalStructTypeArray[23].aString = newString;

Speculation: another way to think of it is that not all global memory
is considered a collectable root until you've first used it. That is,
on the first call to objc_assign_global, the pointer is added to the
list of collectable roots. It appears to be a lazy sort of system.

> They are not strong when you refer to them indirectly (even though write
> barriers are clearly being performed), such as:
>
> update(&globalStructTypeArray[23], newString);
>
> update(MYStructType *aStructType, NSString *string) {
>  aStructType->aString = string;
> }
>
> Looking at the assembly output, the reason becomes clear:
>
> The write barrier used by the first, direct reference is objc_assign_global,
> while the write barrier used by the indirect reference in update is
> objc_assign_strongCast.
>
> This is probably an important point that you should consider if you're
> depending on global variables being truly __strong.  No doubt someone here
> will explain that this isn't a bug, it's just that you shouldn't reference a
> global variable via a pointer (this is sarcastic for the challenged).

You shouldn't reference a global variable via a pointer! Kidding.

The problem is essentially the same as the one in this code:

class Foo {
  public:
  NSString* fieldA;
  int fieldB;

  Foo( NSString *_fieldA, int _fieldB ) : fieldA( _fieldA ), fieldB(
_fieldB ) {}
};

Foo *f = new Foo( @"Something strong", 42 );

IIRC, you'll also find that here f->fieldA is collected way before you
expect. Only this time, there's plenty of emails about how to fix it.
The problem is that ::new returns a block of non-GC memory. So even
though the write barriers are setup properly, f->fieldA is in a
non-scanned region. See here:

http://lists.apple.com/archives/Cocoa-dev/2008/Feb/msg00435.html

In your case, globalStructTypeArray is also in a non-scanned region,
which is why the compiler uses the special _global assign. But you've
hidden the global nature from the compiler

Re: Building a Setup Assistant

2008-06-28 Thread Andy Lee

On Jun 29, 2008, at 1:35 AM, David Wilson wrote:

On Sat, Jun 28, 2008 at 11:00 PM, Andy Lee <[EMAIL PROTECTED]> wrote:

And remember that the last tab you had open when you save the nib  
is the one
that will be open when the nib is loaded.  I often forget this when  
I go in

to tweak something.


Better yet, remember that there's an option in the tab view's
inspector to specify a specific tab to be the default, regardless of
what you've been looking at in IB.


Ooh!  Thanks!

--Andy

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSExpression

2008-06-28 Thread Chris


If anyone has a clue how to use it, I'd be grateful. This was my  
unsuccessful attempt:


NSExpression * ex = [NSExpression expressionForFunction:[NSExpression  
expressionForConstantValue:@"BAR"] selectorName:@"length"  
arguments:nil];


NSPredicate * predicate = [NSCompoundPredicate
andPredicateWithSubpredicates:[NSArray arrayWithObject: ex]];

[predicate evaluateWithObject:@"FOO" substitutionVariables:nil];

[NSFunctionExpression evaluateWithObject:substitutionVariables:]:  
unrecognized selector sent to instance 0x68b8af0



On 29/06/2008, at 12:43 AM, Shawn Erickson wrote:


On Jun 28, 2008, at 12:13 AM, Chris <[EMAIL PROTECTED]> wrote:



NSExpression defines this method:

+ (NSExpression *)expressionForFunction:(NSString *)name arguments: 
(NSArray *)parameters


and the doco provides this example:

[NSExpression expressionForFunction:(@selector(random))  
arguments:nil];



Isn't that wrong? Can you really pass a selector to a NSString  
argument? The compiler is complaining, and the program crashes when  
I attempt.


Yeah it is wrong. I believe you just pass a string with the same  
contents as what you would put in @selector.


-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 [EMAIL PROTECTED]


Re: Building a Setup Assistant

2008-06-28 Thread David Wilson
On Sat, Jun 28, 2008 at 11:00 PM, Andy Lee <[EMAIL PROTECTED]> wrote:

> And remember that the last tab you had open when you save the nib is the one
> that will be open when the nib is loaded.  I often forget this when I go in
> to tweak something.

Better yet, remember that there's an option in the tab view's
inspector to specify a specific tab to be the default, regardless of
what you've been looking at in IB.

-- 
- David T. Wilson
[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]


XML-RPC Cocoa Parsing

2008-06-28 Thread Rick Langschultz

Hello everyone,

I am trying to use XML-RPC for my data access on a web server (HTTPS).  
I wanted to know if parsing the XML-RPC data can be handled using  
NSXMLDocument and parsing the , , ,  XML- 
RPC tags. Also, initWithContentsOfURL doesn't seem to fit that well...  
Should I use initWithXMLString? Also, WS prefixed classes will not  
work in my instance, I can't say why, so that is out.


I am using the XMLRPCCall.h,m XMLRPCRequest.h,m and XMLRPCResponse.h,m  
classes, also with CURLHandle.framework...


Does anyone have any pointers? sample code? etc...?

Thanks,

Rick
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Methods that return autoreleased objects?

2008-06-28 Thread Charles Srstka

On Jun 28, 2008, at 7:43 PM, Markus Spoettl wrote:

Methods that begin with "alloc" or "new" or contain "copy" will  
return objects you are responsible for. All other objects returned  
from methods are taken care of.


Well, there is the notable exception of top-level objects loaded from  
a NIB file, which do need to be released.


Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Output of NSHTTPCookieStorage to NSTableView

2008-06-28 Thread Shawn Erickson
On Sat, Jun 28, 2008 at 9:46 PM, Chris Purcell <[EMAIL PROTECTED]> wrote:
> Hello,
> Not sure where my problem is I've tried a few things and no success.  I am
> trying to output NSHTTPCookieStorage *cookies array to a table view.
>  Whenever I call the objectValueForTableColumn:row method the app errors
> out, but if I leave it out the app launches displaying the correct number of
> rows with nothing in it (as expected since I left out the other method).
>
> Here is the code to get the cookies array:
>
>NSHTTPCookieStorage* sharedCookieStorage = [NSHTTPCookieStorage
> sharedHTTPCookieStorage];
>cookies = [sharedCookieStorage cookies] ;
>
> Here is the code to output the data to the table view:
>
> - (int)numberOfRowsInTableView:(NSTableView *)tableView
> {
>return [cookies count];
> }
>
>
> - (id)tableView:(NSTableView *)tableView
> objectValueForTableColumn:(NSTableColumn *)tableColumn
>row:(int)row
> {
>return [cookies objectAtIndex:row];
> }

What type of NSCell do you have set for the column (looks like you
only have a single column)? It is a specialized NSCell subclass that
knows how to display an instance NSHTTPCookie? If not this isn't going
to work as coded.

NSHTTPCookie isn't a string, number, image, etc. so one of the
standard cell subclasses wont know what to do with it. You either need
a custom cell subclass that can display it the way you want it
displayed or you will have to convert the NSHTTPCookie instance into a
form that a standard cell can handle (maybe an NSString).

-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 [EMAIL PROTECTED]


Output of NSHTTPCookieStorage to NSTableView

2008-06-28 Thread Chris Purcell

Hello,
Not sure where my problem is I've tried a few things and no success.   
I am trying to output NSHTTPCookieStorage *cookies array to a table  
view.  Whenever I call the objectValueForTableColumn:row method the  
app errors out, but if I leave it out the app launches displaying the  
correct number of rows with nothing in it (as expected since I left  
out the other method).


Here is the code to get the cookies array:

	NSHTTPCookieStorage* sharedCookieStorage = [NSHTTPCookieStorage  
sharedHTTPCookieStorage];

cookies = [sharedCookieStorage cookies] ;

Here is the code to output the data to the table view:

- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
return [cookies count];
}


- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row
{
return [cookies objectAtIndex:row];
}


Here is the output in the console:

2008-06-28 21:45:01.997 Cookie Monster[25168:10b] You have   362  
cookies.
2008-06-28 21:45:02.020 Cookie Monster[25168:10b] *** -[NSHTTPCookie  
copyWithZone:]: unrecognized selector sent to instance 0x14b0c0
2008-06-28 21:45:02.021 Cookie Monster[25168:10b] An uncaught  
exception was raised
2008-06-28 21:45:02.021 Cookie Monster[25168:10b] *** -[NSHTTPCookie  
copyWithZone:]: unrecognized selector sent to instance 0x14b0c0
2008-06-28 21:45:02.021 Cookie Monster[25168:10b] *** Terminating app  
due to uncaught exception 'NSInvalidArgumentException', reason: '*** - 
[NSHTTPCookie copyWithZone:]: unrecognized selector sent to instance  
0x14b0c0'

2008-06-28 21:45:02.022 Cookie Monster[25168:10b] Stack: (
2523074891,
2460709115,
2523104074,
2523097420,
2523097618,
2461744868,
2461827850,
2461827587,
2462515572,
2462515044,
2462512282,
2462140684,
2462135280,
2462726532,
2462721147,
2462722066,
2462722066,
2462722066,
2462722066,
2462715345,
2462713619,
2462700087,
2461916303,
2461915197,
2462684049,
2462682600,
2462887525,
2461711615,
2461670930,
2461669236,
2461668279,
2461668085,
2461667236
)

Thanks!  Any help would be appreciated!


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: trackmouse problems in Leopard

2008-06-28 Thread Graham Cox
Not really a very helpful answer, since a) it's not deprecated, and b)  
every existing NSCell class depends on it.


G.

On 29 Jun 2008, at 9:57 am, William Squires wrote:


it's probably deprecated... :)


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Ask for help when encountering GC issues (was Re: Garbage Collection woes...)

2008-06-28 Thread Chris Hanson

On Jun 27, 2008, at 12:31 PM, John Engelhart wrote:

Lesson #1:  If you have any interest in performance, you must avoid,  
at all costs, "writing" to a __strong pointer.


If this were the case, all assignments to instance variables would be  
exceptionally costly under GC.  They are not -- applications run under  
GC can get quite good performance.  Assignment through write barriers  
does have a cost, yes, but that cost is amortized by the fact that the  
GC system can use the generation information provided by using write  
barriers to be more efficient.


Furthermore *every* assignment to an object pointer is effectively a  
__strong assignment.  If your performance assumptions were true in the  
general case, you might expect to see everything that runs under GC  
perform at a fraction the speed it runs under non-GC, which isn't the  
case for the large application I work on.


And thus began yet another exciting adventure with the GC system  
that caused me to waste several days.


You could ask for help on the list sooner rather than spending days  
and days beating your head against something like this...


I'll reiterate what I've said in the past, though:  Objective-C  
Garbage Collection works quite well in Leopard, and applications large  
and small can use it quite effectively.  I generally don't create new  
Cocoa projects these days without turning on Objective-C GC support.   
If you encounter bugs, file them.


  -- 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 [EMAIL PROTECTED]


Re: mutableArrayForKeyValue Question (ignore other email)

2008-06-28 Thread Alex Wait
indeed it was. it's not needed. I took it out.

On Sat, Jun 28, 2008 at 9:19 PM, mmalc crawford <[EMAIL PROTECTED]> wrote:

>
> On Jun 28, 2008, at 8:51 PM, Alex Wait wrote:
>
>  i've read most of
>> http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSArrayController_Class/Reference/Reference.html
>> and I don't see what you mean. is there some "magic" key?
>>
>>  No, there is no magic key.
>
>  why isn't it Person or array?
>>
>>  What does the documentation say about how mutableArrayValueForKey: works?
> <
> http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueCoding_Protocol/Reference/Reference.html#//apple_ref/occ/instm/NSObject/mutableArrayValueForKey
> :>
> If you read *all* the reference for NSArrayController, do you see a method
> "Person" or a method "array"?
>
>  I tried doing
>> [controller addObject:newObj];
>>[table reloadData];
>> and that 'worked" at least.
>>
>>  It's not clear in what sense this "worked" as opposed to just worked.
> The invocation of relaodData should be superfluous.
>
> mmalc
>
>


-- 
If you can't be kind, at least have the decency to be vague.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: mutableArrayForKeyValue Question (ignore other email)

2008-06-28 Thread mmalc crawford


On Jun 28, 2008, at 8:51 PM, Alex Wait wrote:


i've read most of 
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSArrayController_Class/Reference/Reference.html
and I don't see what you mean. is there some "magic" key?


No, there is no magic key.


why isn't it Person or array?

What does the documentation say about how mutableArrayValueForKey:  
works?

If you read *all* the reference for NSArrayController, do you see a  
method "Person" or a method "array"?



I tried doing
[controller addObject:newObj];
[table reloadData];
and that 'worked" at least.


It's not clear in what sense this "worked" as opposed to just worked.
The invocation of relaodData should be superfluous.

mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Methods that return autoreleased objects?

2008-06-28 Thread Omar Qazi
Oops. Sorry for the double reply. Stupid phone doesn't have a threaded view.

-Original Message-
From: Shawn Erickson <[EMAIL PROTECTED]>
Sent: Saturday, June 28, 2008 5:32 PM
To: john muchow <[EMAIL PROTECTED]>
Cc: cocoa-dev@lists.apple.com 
Subject: Re: Methods that return autoreleased objects?

On Sat, Jun 28, 2008 at 5:25 PM, john muchow <[EMAIL PROTECTED]> wrote:
> The last thread that I saw on this topic was dated sometime in
> 2004if there is something more recent that I didn't find, I
> apologize up front...
>
> I realize nothing has probably changed as far as the API and the
> documentation to indicate autoreleased methods, however, can someone
> provide any insight as to how one knows if a method from a framework
> returns an autoreleased object?

Who cares if it is autoreleased? That is essentially an implementation
detail in most situations.

Just learn the memory management rules, mix in common sense, look for
exceptions to the rules (very seldom do any exist) and follow the
rules in your own code.

http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html

-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/omar%40hellogalaxy.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: Methods that return autoreleased objects?

2008-06-28 Thread Omar Qazi
Well theres no way to know, unless it's specifically mentioned in the 
documentation, but it really shouldn't matter. If you need the object retain 
it, if you don't let someone else worry about it.

-Original Message-
From: john muchow <[EMAIL PROTECTED]>
Sent: Saturday, June 28, 2008 5:24 PM
To: cocoa-dev@lists.apple.com 
Subject: Methods that return autoreleased objects?

The last thread that I saw on this topic was dated sometime in
2004if there is something more recent that I didn't find, I
apologize up front...

I realize nothing has probably changed as far as the API and the
documentation to indicate autoreleased methods, however, can someone
provide any insight as to how one knows if a method from a framework
returns an autoreleased object?

Thanks

John
MacDeveloperTips.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/omar%40hellogalaxy.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: Building a Setup Assistant

2008-06-28 Thread Omar Qazi
NSViewController will hanfle view swapping stylishly. The oreily book is really 
outdated. Read Hillegas' instead. I'd link you but I am writing this on my 
phone.


-Original Message-
From: Christopher Keath <[EMAIL PROTECTED]>
Sent: Saturday, June 28, 2008 2:14 PM
To: cocoa-dev@lists.apple.com 
Subject: Building a Setup Assistant

>
> For the life of me, I just don't know where to begin on this  
> seemingly simple project, which is basically my first Xcode project.
>
> Quite specifically, I can't seem to figure out how to setup the  
> 'Next' button that would step you thru each stage of the process.  
> All I want to do is collect some text based info that I will write  
> out to a plist. But this process will involve about 10 windows that  
> ask various questions, and later windows will need access to info  
> entered in earlier windows. KInd of like the registration apps that  
> launch after an application installs.
>
> I have read through Cocoa with Objective C (the O'Reilly book) but  
> there is nothing about having non-document based apps with more then  
> 1 window. I have looked thru the examples as well, but none seem to  
> follow this format.
>
> I'm especially having trouble with the fact that I am using XCode 3,  
> and it looks nothing like the examples in the book - for the life of  
> me I can't figure out where the Classes Menu went, and I can't find  
> the Instantiate command that will make the header files and so forth  
> in Xcode based on what I do in IB.
>
> So anyway -
> Do I want to try and do this with only 1 window object, and have  
> each stage simply load a new view? Or do I want a new nib for each  
> step?
> In either case, I have no idea where to begin. I can add my initial  
> text box that will hold my Welcome message, and I can add the 'Next'  
> button, all to the Window, but have no idea where to go from  
> there Do I need some kind of custom class for this? Where do I  
> overwrite the default latin text that is in my box? Can window have  
> multiple views that are mutually exclusive? or do I need to load a  
> new nib for each window? How do you load a new nib? How do you take  
> the old one off?
>
> Should I be trying to use core data for this? I messed with that for  
> a while but for the life of me could not figure out how to attach  
> the data objects I made in the Core Data part of XCode to fields in  
> IB.
>
> I can do the table view stuff from the book too, to get and write  
> the data I want for each window, but structurally, I'm not sure how  
> to setup a series of windows that would all have access to that  
> data, or even how to load the next window.
>
> I know it's a very basic question, but I would really appreciate the  
> help.
>
> THANKS!
>
> 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/omar%40hellogalaxy.com

This email sent to [EMAIL PROTECTED]


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 [EMAIL PROTECTED]

Re: mutableArrayForKeyValue Question (ignore other email)

2008-06-28 Thread Alex Wait
i've read most of
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSArrayController_Class/Reference/Reference.html

and I don't see what you mean. is there some "magic" key?

why isn't it Person or array?
I tried doing
[controller addObject:newObj];
[table reloadData];

and that 'worked" at least.


On Sat, Jun 28, 2008 at 8:03 PM, mmalc crawford <[EMAIL PROTECTED]> wrote:

>
> On Jun 28, 2008, at 7:42 PM, Alex Wait wrote:
>
>  I am trying to modify the array controller programmatically and I'm
>> running
>> into problems using mutableArrayForKeyValue
>> I am using this line
>>   id proxy = [controller mutableArrayValueForKey:@"Person"];
>> when I do
>>   [proxy addObject:newPerson]
>> I get
>> [ valueForUndefinedKey:]: this class is not
>> key
>> value coding-compliant for the key Person.
>> In IB I have bound the Content Array to my array member in App Controller.
>> Shouldn't this work?
>>
>>  No.
> Just as the error states, @"Person" is not a valid key for the controller.
>
>  I have set the class name to be of the "Person" class. Right now the key I
>> am using is "Person" but I have also tried "array" and got the same
>> problem.
>>
>>  Similarly, @"array" is not a valid key for the controller.
>
>  What do I do next?
>>
>>  Look at the API reference for NSArrayController to see what are valid
> messages to send to the controller to achieve what it is that you want; read
> the bindings conceptual documentation to see how else you might achieve this
> by modifying the source data controller; or look at the myriad online
> examples that illustrate this.
>
> mmalc
>
>


-- 
If you can't be kind, at least have the decency to be vague.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: valueForKey: on collections [was: Re: Using isMemberOfClass with a tree of subclass of NSManagedObject]

2008-06-28 Thread Kyle Sluder
On Sat, Jun 28, 2008 at 9:35 PM, Owen Yamauchi
<[EMAIL PROTECTED]> wrote:
> On Sat, Jun 28, 2008 at 6:24 PM, Ben Trumbull <[EMAIL PROTECTED]> wrote:
>>> Which is, frankly, a bit goofy and, thus, the primary reason why I
>>> would avoid using -valueForKey: on a dictionary.
>>
>> Amen.  It's slower, and people reading your code can get very confused.
>
> Then is there a recommended way of binding to the contents of
> dictionaries? For example, suppose I have an NSObjectController
> representing some object, which has an NSDictionary (let's say it's
> called "attributes") as a property. Then can I bind to the value
> stored under a key in that dictionary? Say I want to bind a text
> field's value to whatever is stored under the key "name" in the
> "attributes" dictionary. The intuitive (to me) thing to do is bind to
> the NSObjectController, controller key "selection", model key path
> "attributes.name". But that won't work. Is there a good solution?

Why wouldn't it?  The NSObjectController's selection proxy receives
the keypath "attributes.name", so it sends
-valueForKeyPath:@"attributes.name" to its concrete object (your model
object).  This object's implementation of -valueForKeyPath: sees that
"attributes" is a valid key, so it gets your NSDictionary exposed as
"attributes" and sends it -valueForKeyPath:@"name".
-valueForKeyPath:'s custom logic treats "name" as a dictionary key
first, and returns -objectForKey:@"name".

At least this is what I've gathered from Bill and Ben's discussion.

--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 [EMAIL PROTECTED]


Re: mutableArrayForKeyValue Question

2008-06-28 Thread Kyle Sluder
Gah!  For some reason Gmail sorted this message as newer than your
other, properly detailed message.  I really apologize for that.

--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 [EMAIL PROTECTED]


Re: mutableArrayForKeyValue Question

2008-06-28 Thread Kyle Sluder
On Sat, Jun 28, 2008 at 10:39 PM, Alex Wait <[EMAIL PROTECTED]> wrote:
> I am trying to modify the array controller programmatically and I'm running
> into problems using mutableArrayForKeyValue
>
> I am using this line
>
>id proxy = [controller mutableArrayValueForKey:@"Person"];

... and?  You need to 1) post more code and 2) post the actual problem
you're encountering.  We're not psychics.

--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 [EMAIL PROTECTED]


Re: mutableArrayForKeyValue Question (ignore other email)

2008-06-28 Thread mmalc crawford


On Jun 28, 2008, at 7:42 PM, Alex Wait wrote:

I am trying to modify the array controller programmatically and I'm  
running

into problems using mutableArrayForKeyValue
I am using this line
   id proxy = [controller mutableArrayValueForKey:@"Person"];
when I do
   [proxy addObject:newPerson]
I get
[ valueForUndefinedKey:]: this class is  
not key

value coding-compliant for the key Person.
In IB I have bound the Content Array to my array member in App  
Controller.

Shouldn't this work?


No.
Just as the error states, @"Person" is not a valid key for the  
controller.


I have set the class name to be of the "Person" class. Right now the  
key I
am using is "Person" but I have also tried "array" and got the same  
problem.



Similarly, @"array" is not a valid key for the controller.


What do I do next?

Look at the API reference for NSArrayController to see what are valid  
messages to send to the controller to achieve what it is that you  
want; read the bindings conceptual documentation to see how else you  
might achieve this by modifying the source data controller; or look at  
the myriad online examples that illustrate this.


mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Building a Setup Assistant

2008-06-28 Thread Andy Lee

On Jun 28, 2008, at 7:34 PM, Jens Alfke wrote:
(Once you hide the tabs in IB, you may wonder how you get to the  
different views to edit their contents. If you select the tab view  
itself, its attributes inspector pane has a stepper control to  
select the different items. Or you can use the outline view of the  
nib and expand the tab view to see the different items; then you can  
double-click them.)


And remember that the last tab you had open when you save the nib is  
the one that will be open when the nib is loaded.  I often forget this  
when I go in to tweak something.


--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 [EMAIL PROTECTED]


mutableArrayForKeyValue Question (ignore other email)

2008-06-28 Thread Alex Wait
Gmail sent an email on me while I was typing. No idea what happened! :) So
please ignore the incomplete message.

I have successfully done some more bindings (they're so much fun ^_^ )

I am trying to modify the array controller programmatically and I'm running
into problems using mutableArrayForKeyValue

I am using this line

id proxy = [controller mutableArrayValueForKey:@"Person"];

when I do
[proxy addObject:newPerson]

I get

[ valueForUndefinedKey:]: this class is not key
value coding-compliant for the key Person.

In IB I have bound the Content Array to my array member in App Controller.
Shouldn't this work?
I have set the class name to be of the "Person" class. Right now the key I
am using is "Person" but I have also tried "array" and got the same problem.

What do I do next?

-- 
If you can't be kind, at least have the decency to be vague.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


mutableArrayForKeyValue Question

2008-06-28 Thread Alex Wait
I have successfully done some more bindings (they're so much fun ^_^ )

I am trying to modify the array controller programmatically and I'm running
into problems using mutableArrayForKeyValue

I am using this line

id proxy = [controller mutableArrayValueForKey:@"Person"];



-- 
If you can't be kind, at least have the decency to be vague.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSTextView to replace NSTextList confused

2008-06-28 Thread Kyle Sluder
On Sat, Jun 28, 2008 at 8:28 PM, Papa-Raboon <[EMAIL PROTECTED]> wrote:
> So I did this and changed the header file for my mainController to
> take the NSTextView into consideration by changing:
>
> IBOutlet NSTextField* theNotes;
>
> to:
>
> IBOutlet NSTextView *theNotes;
>
> I then built and ran the project and surprise surprise it didn't work.
> In Xcode I get the following:
> warning 'NSTextView' may not respond to '-stringValue'
> (Messages without a matching method signature will be assumed to
> return 'id' and accept '...' as arguments.).
>
> Any ideas what I am doing wrong please anyone.

Look at the documentation for NSTextView.  Notice how it doesn't
implement -stringValue?  Neither do any of its superclasses.
Therefore you can't send an NSTextView a -stringValue message and
expect anything meaningful.  NSTextView does inherit from NSText,
though, which responds to -string by returning the backing store.

Do read the documentation for the Cocoa Text System.  NSTextView is
different from (and far more powerful than) NSTextField.

--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 [EMAIL PROTECTED]


Re: valueForKey: on collections [was: Re: Using isMemberOfClass with a tree of subclass of NSManagedObject]

2008-06-28 Thread Owen Yamauchi
On Sat, Jun 28, 2008 at 6:24 PM, Ben Trumbull <[EMAIL PROTECTED]> wrote:
>> Which is, frankly, a bit goofy and, thus, the primary reason why I
>> would avoid using -valueForKey: on a dictionary.
>
> Amen.  It's slower, and people reading your code can get very confused.

Then is there a recommended way of binding to the contents of
dictionaries? For example, suppose I have an NSObjectController
representing some object, which has an NSDictionary (let's say it's
called "attributes") as a property. Then can I bind to the value
stored under a key in that dictionary? Say I want to bind a text
field's value to whatever is stored under the key "name" in the
"attributes" dictionary. The intuitive (to me) thing to do is bind to
the NSObjectController, controller key "selection", model key path
"attributes.name". But that won't work. Is there a good solution?

Owen
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Methods that return autoreleased objects?

2008-06-28 Thread Owen Yamauchi
Don't think about it.

If memory management confuses you in any way, don't try to think about
the status of objects returned from framework methods. Only worry
about it from the perspective of your code. Do you need the object to
stay around after your method returns? Then retain it, and remember to
release it somewhere else as appropriate. If you make an object with
+alloc or -copy, then you'll need to release it somewhere too.

In practice, most framework methods return autoreleased objects (if
the method creates it). There are other situations, for example:
-[NSArray objectAtIndex:] will return an object that is retained by
the array, and is not in any autorelease pools (unless you've put it
in one). But that's because the object was not created by the array.

Bottom line: don't think about it. Follow the rules in your own code,
and all will be well.

Owen
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


valueForKey: on collections [was: Re: Using isMemberOfClass with a tree of subclass of NSManagedObject]

2008-06-28 Thread Ben Trumbull

On Jun 28, 2008, at 1:08 PM, Kyle Sluder wrote:

On Sat, Jun 28, 2008 at 2:14 PM, Bill Bumgarner <[EMAIL PROTECTED]> wrote:

You want -objectForKey:  -valueForKey: is for key value coding,
-objectForKey: is for extracting objects from a dictionary.

Shouldn't cause a problem.


I thought the collection classes were smart and treated -valueForKey:
by sending each object in the collection -valueForKey: and compiling
the results in an object arranged in the same way as the original.
That way you could have an array of strings and do something like
[myArray valueForKey:@"length"] to get an array of lengths
corresponding to each instance.


Sort of.  Depends on the collection class.  The behavior you describe
works for NSArray (and NSSet, IIRC).  For NSDictionary, the rules are
slightly different:
...

If key does not start with [EMAIL PROTECTED], invokes objectForKey:. If key does
start with [EMAIL PROTECTED], strips the [EMAIL PROTECTED] and invokes [super 
valueForKey:]with
the rest of the key.



The real problem is -valueForKeyPath: behaves magically differently on  
dictionaries from everything else.  If the argument contains a "."  
character, the entire keypath is treated as a single key to - 
objectForKey:  If the entire keypath does not exist in the dictionary,  
then it falls back to the normal -valueForKeyPath: behavior.


Basically, if you have a "." character in any of your keys, you can  
find some serious confusion.  Say, if you ever use a DNS or reverse  
DNS names for a key.  Like the contents of ~Library/Preferences


-valueForKey:  != -objectForKey:


Which is, frankly, a bit goofy and, thus, the primary reason why I
would avoid using -valueForKey: on a dictionary.


Amen.  It's slower, and people reading your code can get very confused.

- Ben

___

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

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

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

This email sent to [EMAIL PROTECTED]


NSURLConnection vs CF and other ideas

2008-06-28 Thread Alex Kac
I've got a working HTTP Post with file upload using NSURLConnection,  
but I don't seem to see any ways to get progress on the upload beyond  
the connectionDidFinishLoading: delegate. Is there a better way to be  
able to get progress info so we can display that to the user?


I checked the archives as any good list user would do, but I don't see  
any answers and this quote from someone makes me think you can:

http://lists.apple.com/archives/cocoa-dev/2005/Jan/msg01851.html
Furthermore if you use the synchronous call on NSURLConnection you  
can't get progress information; you'll only know when the request  
completes or fails.


I then found this one that seemed to give me a bit more info, but the  
threading in the list archives was wonky and so I can't get the full  
thread:

http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00653.html
http://lists.apple.com/archives/cocoa-dev/2005/Oct/msg00717.html

Anyhow - with snippets I see there I can see its possible - but I'm  
not getting info on how. Its like seeing a part of the puzzle but not  
the full picture and I'm a bit of a newbie, only working with Cocoa  
for the last year with a good part of my real-world experience more  
recently so maybe something obvious isn't jumping out at me.


Alex Kac - President and Founder
Web Information Solutions, Inc. -  Central Texas Microsoft Certified  
Partner


“Don't forget until too late that the business of life is not business  
but living.”

-- B.C. Forbes,



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Garbage Collection woes...

2008-06-28 Thread John Engelhart
A few days ago, I decided to give leopards GC system another crack.   
The experience was pretty much the same as all my other experiences  
have been with Leopards GC system (several days wasted).  I learned  
two important things that I thought I would share:


Lesson #1:  If you have any interest in performance, you must avoid,  
at all costs, "writing" to a __strong pointer.  I thought I was being  
quite careful about which pointers were __strong and which were  
getting touched in the critical path, which should have been none.  
However, once I flipped GC on, micro benchmarks results went right  
through the floor, an order of magnitude worse.  The problem was the  
following innocent statement:


-(BOOL)doSomething:(id)obj error:(NSError **)error
{
  if(error != NULL) { *error = NULL; } // Make sure we clear the  
error object

}

It's sort of ambiguous as to what should be returned by the indirect  
error pointer on the condition of success.  I could think of several  
neat ideas if the expected behavior were defined up front, even  
requiring the caller to initialize the pointer to a default NSError  
singleton and allowing errors to accumulate in a stack like fashion.   
Alas, the only clearly defined behavior is that one failure, a NSError  
object is indirectly returned.


I prefer the "Initialize your environment to a known state."   Leave  
it up to the optimizer to figure out if such an initialization is in  
fact useless because, one way or another, some path is guaranteed to  
set it later on without depending on its initial value.


Now, typically, the passed in error pointer itself lives on the  
stack.  The compiler can't tell where the pointer really lives, and so  
it must "assume the worst"[1] an insert a write barrier, even if such  
a write barrier is pointless because it's protecting an update to a  
location that ultimately lives on the stack.


[1] This is an important point in the next GC lesson learned.

So the way to 'fix' this is to do something like:

  if((error != NULL) && (*error != NULL)) { *error = NULL; }

This will at least only incur a write barrier penalty only when it  
needs to.


The write barrier penalty is substantial.  I benchmarked a tight loop  
that called a function that did nothing but the naive clearing of the  
value.  The result (on a 1.5GHz G4) was that it was 2429.55% (or, over  
24 times) slower with -fobjc-gc enabled.  So, best to avoid updating a  
__strong pointer at any and all costs.


Lesson #2:  Since there is so little documentation about the GC  
system, this involves a lot of speculation, but I think it summarizes  
what's really going on.  This all started with an effort to keep a  
__weak reference to a passed in string that was used to initialize an  
element in a cache.  When the cache was checked, if that weak  
reference was NULL, then the cache line is invalid and should be  
cleared.  The cache consisted of a global array of elements, selection  
was done via KEY_STRING_HASH % CACHE_SIZE, and everything was under a  
mutex lock.  An approximation of the cache is:


typedef struct {
  NSString *aString;
  __weak NSString *aWeakString;
  NSInteger anInteger;
} MYStructType;

MYStructType globalStructTypeArray[42]; // <-- Global!

Simple, right?  That's how it always starts out...  The first problem  
encountered was:


[EMAIL PROTECTED] /tmp% gcc -o Global_GC Global_GC.m -framework  
Foundation -fobjc-gc
Global_GC.m:14: warning: __weak attribute cannot be specified on a  
field declaration


(The attached file contains the full example demonstrating the problem.)

I'm not really sure what this means, and I don't recall reading  
anything in the documentation that would suggest anything is amiss.  I  
never actually managed to figure out what, if any, problem this causes  
because it quickly became apparent that there was a much bigger  
problem that needed dealing with:


The pointer to 'aString' in the above (or any of my other __strong  
pointers in my actual code) were clearly not being treated as  
__strong, and the GC system was reclaiming them causing all sorts of  
fun and random crashes.


The documentation states: The initial root set of objects is comprised  
of global variables, stack variables, and objects with external  
references. These objects are never considered as garbage.


And thus began yet another exciting adventure with the GC system that  
caused me to waste several days.  In all honesty, I've probably sunk  
about 3 weeks worth of 10 hour days in to tracking down "problems"  
like this whenever I've tried to use the GC system.  At this point,  
I've probably spent more time dealing with memory allocation problems  
due to the GC system than I've spent dealing with memory allocation  
problems in the last 20 years.


I spent several hours digging through the assembly output, and even  
(once again) plunging in to the gcc source to try to figure out what  
was going on.  Using dtrace to catch all calls t

Re: Methods that return autoreleased objects?

2008-06-28 Thread Markus Spoettl

On Jun 28, 2008, at 5:25 PM, john muchow wrote:

The last thread that I saw on this topic was dated sometime in
2004if there is something more recent that I didn't find, I
apologize up front...

I realize nothing has probably changed as far as the API and the
documentation to indicate autoreleased methods, however, can someone
provide any insight as to how one knows if a method from a framework
returns an autoreleased object?



Methods that begin with "alloc" or "new" or contain "copy" will return  
objects you are responsible for. All other objects returned from  
methods are taken care of.


More information here:

http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html

Regards
Markus
--
__
Markus Spoettl



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 [EMAIL PROTECTED]

Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Markus Spoettl

On Jun 28, 2008, at 5:07 PM, Quincey Morris wrote:
The last-modified date on that page is Feb, 2007. Seems like a long  
time for such a fundamental document to be incomplete. That may be a  
good thing to mention when you file a bug report against the  
documentation. ;)



Done, 6042235.

Regards
Markus
--
__
Markus Spoettl



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 [EMAIL PROTECTED]

Re: Methods that return autoreleased objects?

2008-06-28 Thread Shawn Erickson
On Sat, Jun 28, 2008 at 5:25 PM, john muchow <[EMAIL PROTECTED]> wrote:
> The last thread that I saw on this topic was dated sometime in
> 2004if there is something more recent that I didn't find, I
> apologize up front...
>
> I realize nothing has probably changed as far as the API and the
> documentation to indicate autoreleased methods, however, can someone
> provide any insight as to how one knows if a method from a framework
> returns an autoreleased object?

Who cares if it is autoreleased? That is essentially an implementation
detail in most situations.

Just learn the memory management rules, mix in common sense, look for
exceptions to the rules (very seldom do any exist) and follow the
rules in your own code.

http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html

-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 [EMAIL PROTECTED]


NSTextView to replace NSTextList confused

2008-06-28 Thread Papa-Raboon
Hi there guys.

I am a newbie to OOP and cocoa and as a personal project I have been
building a simple little app to allow me to quickly add people to the
Apple address book and at the moment it works well using NSTextFields
for every field, however I want to use an NSTextView to enter the text
for the 'note' field for the new contact as it would be a lot better
suited so I thought I could just lob an NSTextView at my window in
Interface builder, wire it up to my mainController class like I did
the text fields and change the reference in the header file to take
the text view into consideration.

So I did this and changed the header file for my mainController to
take the NSTextView into consideration by changing:

IBOutlet NSTextField* theNotes;

to:

IBOutlet NSTextView *theNotes;

I then built and ran the project and surprise surprise it didn't work.
In Xcode I get the following:
warning 'NSTextView' may not respond to '-stringValue'
(Messages without a matching method signature will be assumed to
return 'id' and accept '...' as arguments.).

Any ideas what I am doing wrong please anyone.

Cheers
Paul Randall
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Methods that return autoreleased objects?

2008-06-28 Thread john muchow
The last thread that I saw on this topic was dated sometime in
2004if there is something more recent that I didn't find, I
apologize up front...

I realize nothing has probably changed as far as the API and the
documentation to indicate autoreleased methods, however, can someone
provide any insight as to how one knows if a method from a framework
returns an autoreleased object?

Thanks

John
MacDeveloperTips.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: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Quincey Morris


On Jun 28, 2008, at 16:38, Markus Spoettl wrote:


On Jun 28, 2008, at 4:06 PM, Clark Cox wrote:

They're listed in the NSKeyValueCoding.h header, but it seems that
they aren't included in the equivalent documentation
().



That's it! This is what the comment for NSMutableArray says. In the  
first paragraph notice that -insert:atIndexes: and - 
removeAtIndexes: is not in the documentation.


The last-modified date on that page is Feb, 2007. Seems like a long  
time for such a fundamental document to be incomplete. That may be a  
good thing to mention when you file a bug report against the  
documentation. ;)





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: trackmouse problems in Leopard

2008-06-28 Thread William Squires

it's probably deprecated... :)

On Jun 28, 2008, at 8:24 AM, Moray Taylor wrote:


Hi, hope someone can help...

I have an app that uses a custom NSCell that implements the

- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame  
ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp


method.

In Tiger, this works just fine, if I build targeting the 10.5 API,  
it does not work, the method does not get called at all, I can put  
an NSLog right at the start, and it never happens.


If I build targeting 10.4, it works great, even if the host machine  
is running Leopard, so it seems its an API difference.


If anyone can shed any light on this, I'd be eternally grateful!

Thanks a lot

Moray


  __
Not happy with your email address?.
Get the one you really want - millions of new email addresses  
available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/wsquires% 
40satx.rr.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: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Markus Spoettl

On Jun 28, 2008, at 4:06 PM, Clark Cox wrote:

They're listed in the NSKeyValueCoding.h header, but it seems that
they aren't included in the equivalent documentation
().



That's it! This is what the comment for NSMutableArray says. In the  
first paragraph notice that -insert:atIndexes: and - 
removeAtIndexes: is not in the documentation.


Thanks Clark!

Regards
Markus

From NSKeyValueCoding.h:

1. Searches the class of the receiver for methods whose names  
match the patterns -insertObject:inAtIndex: and - 
removeObjectFromAtIndex: (corresponding to the two most primitive  
methods defined by the NSMutableArray class), and (introduced in Mac  
OS 10.4) also -insert:atIndexes: and -removeAtIndexes:  
(corresponding to -[NSMutableArray insertObjects:atIndexes:] and - 
[NSMutableArray removeObjectsAtIndexes:). If at least one insertion  
method and at least one removal method are found each NSMutableArray  
message sent to the collection proxy object will result in some  
combination of -insertObject:inAtIndex:, - 
removeObjectFromAtIndex:, -insert:atIndexes:, and - 
removeAtIndexes: messages being sent to the original receiver of - 
mutableArrayValueForKey:. If the class of the receiver also implements  
an optional method whose name matches the pattern - 
replaceObjectInAtIndex:withObject: or (introduced in Mac OS 10.4)  
-replaceAtIndexes:with: that method will be used when  
appropriate for best performance.
2. Otherwise (no set of array mutation methods is found),  
searches the class of the receiver for an accessor method whose name  
matches the pattern -set:. If such a method is found each  
NSMutableArray message sent to the collection proxy object will result  
in a -set: message being sent to the original receiver of - 
mutableArrayValueForKey:.
3. Otherwise (no set of array mutation methods or simple accessor  
method is found), if the receiver's class'  
+accessInstanceVariablesDirectly method returns YES, searches the  
class of the receiver for an instance variable whose name matches the  
pattern _ or , in that order. If such an instance variable  
is found, each NSMutableArray message sent to the collection proxy  
object will be forwarded to the instance variable's value, which  
therefore must typically be an instance of NSMutableArray or a  
subclass of NSMutableArray.
4. Otherwise (no set of array mutation methods, simple accessor  
method, or instance variable is found), returns a mutable collection  
proxy object anyway. Each NSMutableArray message sent to the  
collection proxy object will result in a -setValue:forUndefinedKey:  
message being sent to the original receiver of - 
mutableArrayValueForKey:. The default implementation of - 
setValue:forUndefinedKey: raises an NSUndefinedKeyException, but you  
can override it in your application.


--
__
Markus Spoettl



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 [EMAIL PROTECTED]

Re: Building a Setup Assistant

2008-06-28 Thread Jens Alfke


On 28 Jun '08, at 2:15 PM, Christopher Keath wrote:

Do I want to try and do this with only 1 window object, and have  
each stage simply load a new view? Or do I want a new nib for each  
step?


The best way to do an assistant UI is with an NSTabView. Put each step  
inside a separate tab, and set the tab view to hide the tabs. Wire the  
"Next" and "Previous" buttons to the tab view's - 
selectNextTabViewItem: and -selectPrevTabViewItem: actions.


(Once you hide the tabs in IB, you may wonder how you get to the  
different views to edit their contents. If you select the tab view  
itself, its attributes inspector pane has a stepper control to select  
the different items. Or you can use the outline view of the nib and  
expand the tab view to see the different items; then you can double- 
click them.)


—Jens___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Bill Bumgarner

On Jun 28, 2008, at 1:08 PM, Kyle Sluder wrote:

On Sat, Jun 28, 2008 at 2:14 PM, Bill Bumgarner <[EMAIL PROTECTED]> wrote:

You want -objectForKey:  -valueForKey: is for key value coding,
-objectForKey: is for extracting objects from a dictionary.

Shouldn't cause a problem.


I thought the collection classes were smart and treated -valueForKey:
by sending each object in the collection -valueForKey: and compiling
the results in an object arranged in the same way as the original.
That way you could have an array of strings and do something like
[myArray valueForKey:@"length"] to get an array of lengths
corresponding to each instance.


Sort of.  Depends on the collection class.  The behavior you describe  
works for NSArray (and NSSet, IIRC).  For NSDictionary, the rules are  
slightly different:

...

If key does not start with [EMAIL PROTECTED], invokes objectForKey:. If key does  
start with [EMAIL PROTECTED], strips the [EMAIL PROTECTED] and invokes [super valueForKey:]with  
the rest of the key.


...


Which is, frankly, a bit goofy and, thus, the primary reason why I  
would avoid using -valueForKey: on a dictionary.


b.bum

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 [EMAIL PROTECTED]

Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Clark Cox
On Sat, Jun 28, 2008 at 3:53 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> On Jun 28, 2008, at 1:03 PM, Kyle Sluder wrote:
>>
>> And you're surprised that this caused an infinite loop?
>
> As a matter of fact, yes I was until I realized what was happening. I read
> the documentation and there was no mention about this specific accessor.
> That was not the question, though, only an explanation of what has happened
> and why I asked the question I am asking.
>
> The real question is if there is a list of accessor methods that can be
> implemented optionally so you don't run into this accidentially as I did.

They're listed in the NSKeyValueCoding.h header, but it seems that
they aren't included in the equivalent documentation
().

-- 
Clark S. Cox III
[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: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Keary Suska
6/28/08 4:53 PM, also sprach [EMAIL PROTECTED]:

> The real question is if there is a list of accessor methods that can
> be implemented optionally so you don't run into this accidentially as
> I did.

http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Con
cepts/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-BAJEDEFB

It's not a list per se, but does reference every accessor. For more info on
the various methods in a more listy kind of way, refer to the protocol doc:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Protocol
s/NSKeyValueCoding_Protocol/Reference/Reference.html

HTH,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Markus Spoettl

On Jun 28, 2008, at 1:03 PM, Kyle Sluder wrote:

And you're surprised that this caused an infinite loop?


As a matter of fact, yes I was until I realized what was happening. I  
read the documentation and there was no mention about this specific  
accessor. That was not the question, though, only an explanation of  
what has happened and why I asked the question I am asking.


The real question is if there is a list of accessor methods that can  
be implemented optionally so you don't run into this accidentially as  
I did.


Markus
--
__
Markus Spoettl



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 [EMAIL PROTECTED]

Re: Determining general type of a file (image, text, sound, etc...)

2008-06-28 Thread Owen Yamauchi
On Sat, Jun 28, 2008 at 2:37 PM,  <[EMAIL PROTECTED]> wrote:
> Hi
>
> I'm writing a "KFile" class that encapsulates a bunch of file operations that 
> are spread out over several Cocoa and Carbon classes and want to have a 
> couple of testing methods such as "isImageFile", "isMusicFile", "isTextFile" 
> etc. I'm trying to avoid hard coding HFS types and/or file extensions and 
> have it perform these tests much like the Finder does in it's search window 
> where you can specify file kind as "Images", "Music", "Text", "Movies" etc. 
> Is there any any built in way, in either Cocoa or Carbon, to get a list of 
> types that correspond to say "Images" or perform a test on a specific file 
> that returns true for "Images"?

You could use the command-line utility "file" via an NSTask. Look at
its manpage for more info.

Owen
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Building a Setup Assistant

2008-06-28 Thread Richard Adams
I'm a relative newbie to cocoa but I found this interesting tidbit  
when looking at core animation - how to build a wizard dialog using  
core animation


http://www.cimgf.com/2008/03/03/core-animation-tutorial-wizard-dialog-with-transitions/

I hope this helps

Richard


On Jun 28, 2008, at 10:15 PM, Christopher Keath wrote:



For the life of me, I just don't know where to begin on this  
seemingly simple project, which is basically my first Xcode project.


Quite specifically, I can't seem to figure out how to setup the  
'Next' button that would step you thru each stage of the process.  
All I want to do is collect some text based info that I will write  
out to a plist. But this process will involve about 10 windows that  
ask various questions, and later windows will need access to info  
entered in earlier windows. KInd of like the registration apps that  
launch after an application installs.


I have read through Cocoa with Objective C (the O'Reilly book) but  
there is nothing about having non-document based apps with more  
then 1 window. I have looked thru the examples as well, but none  
seem to follow this format.


I'm especially having trouble with the fact that I am using XCode  
3, and it looks nothing like the examples in the book - for the  
life of me I can't figure out where the Classes Menu went, and I  
can't find the Instantiate command that will make the header files  
and so forth in Xcode based on what I do in IB.


So anyway -
Do I want to try and do this with only 1 window object, and have  
each stage simply load a new view? Or do I want a new nib for each  
step?
In either case, I have no idea where to begin. I can add my initial  
text box that will hold my Welcome message, and I can add the  
'Next' button, all to the Window, but have no idea where to go from  
there Do I need some kind of custom class for this? Where do I  
overwrite the default latin text that is in my box? Can window have  
multiple views that are mutually exclusive? or do I need to load a  
new nib for each window? How do you load a new nib? How do you take  
the old one off?


Should I be trying to use core data for this? I messed with that  
for a while but for the life of me could not figure out how to  
attach the data objects I made in the Core Data part of XCode to  
fields in IB.


I can do the table view stuff from the book too, to get and write  
the data I want for each window, but structurally, I'm not sure how  
to setup a series of windows that would all have access to that  
data, or even how to load the next window.


I know it's a very basic question, but I would really appreciate  
the help.


THANKS!

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/cocoa-dev.aml%40slayford.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: Determining general type of a file (image, text, sound, etc...)

2008-06-28 Thread Oleg Svirgstin

Hi Ken and all,

I would use the Uniform Type Identifiers (UTI), look at the ADC:
"ADC Home > Reference Library > Guides > Carbon > Data Management >  
Uniform Type Identifiers Overview >".


I have used the UTI several times to identify image files and it  
worked well.


HTH,
Oleg




On Jun 29, 2008, at 01:37, [EMAIL PROTECTED] wrote:


Hi

I'm writing a "KFile" class that encapsulates a bunch of file  
operations that are spread out over several Cocoa and Carbon classes  
and want to have a couple of testing methods such as "isImageFile",  
"isMusicFile", "isTextFile" etc. I'm trying to avoid hard coding HFS  
types and/or file extensions and have it perform these tests much  
like the Finder does in it's search window where you can specify  
file kind as "Images", "Music", "Text", "Movies" etc. Is there any  
any built in way, in either Cocoa or Carbon, to get a list of types  
that correspond to say "Images" or perform a test on a specific file  
that returns true for "Images"?


Thanks for any 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 [EMAIL PROTECTED]


Determining general type of a file (image, text, sound, etc...)

2008-06-28 Thread kentozier
Hi

I'm writing a "KFile" class that encapsulates a bunch of file operations that 
are spread out over several Cocoa and Carbon classes and want to have a couple 
of testing methods such as "isImageFile", "isMusicFile", "isTextFile" etc. I'm 
trying to avoid hard coding HFS types and/or file extensions and have it 
perform these tests much like the Finder does in it's search window where you 
can specify file kind as "Images", "Music", "Text", "Movies" etc. Is there any 
any built in way, in either Cocoa or Carbon, to get a list of types that 
correspond to say "Images" or perform a test on a specific file that returns 
true for "Images"?

Thanks for any 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 [EMAIL PROTECTED]


Building a Setup Assistant

2008-06-28 Thread Christopher Keath


For the life of me, I just don't know where to begin on this  
seemingly simple project, which is basically my first Xcode project.


Quite specifically, I can't seem to figure out how to setup the  
'Next' button that would step you thru each stage of the process.  
All I want to do is collect some text based info that I will write  
out to a plist. But this process will involve about 10 windows that  
ask various questions, and later windows will need access to info  
entered in earlier windows. KInd of like the registration apps that  
launch after an application installs.


I have read through Cocoa with Objective C (the O'Reilly book) but  
there is nothing about having non-document based apps with more then  
1 window. I have looked thru the examples as well, but none seem to  
follow this format.


I'm especially having trouble with the fact that I am using XCode 3,  
and it looks nothing like the examples in the book - for the life of  
me I can't figure out where the Classes Menu went, and I can't find  
the Instantiate command that will make the header files and so forth  
in Xcode based on what I do in IB.


So anyway -
Do I want to try and do this with only 1 window object, and have  
each stage simply load a new view? Or do I want a new nib for each  
step?
In either case, I have no idea where to begin. I can add my initial  
text box that will hold my Welcome message, and I can add the 'Next'  
button, all to the Window, but have no idea where to go from  
there Do I need some kind of custom class for this? Where do I  
overwrite the default latin text that is in my box? Can window have  
multiple views that are mutually exclusive? or do I need to load a  
new nib for each window? How do you load a new nib? How do you take  
the old one off?


Should I be trying to use core data for this? I messed with that for  
a while but for the life of me could not figure out how to attach  
the data objects I made in the Core Data part of XCode to fields in  
IB.


I can do the table view stuff from the book too, to get and write  
the data I want for each window, but structurally, I'm not sure how  
to setup a series of windows that would all have access to that  
data, or even how to load the next window.


I know it's a very basic question, but I would really appreciate the  
help.


THANKS!

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 [EMAIL PROTECTED]


Re: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Kyle Sluder
On Sat, Jun 28, 2008 at 2:14 PM, Bill Bumgarner <[EMAIL PROTECTED]> wrote:
> You want -objectForKey:  -valueForKey: is for key value coding,
> -objectForKey: is for extracting objects from a dictionary.
>
> Shouldn't cause a problem.

I thought the collection classes were smart and treated -valueForKey:
by sending each object in the collection -valueForKey: and compiling
the results in an object arranged in the same way as the original.
That way you could have an array of strings and do something like
[myArray valueForKey:@"length"] to get an array of lengths
corresponding to each instance.

--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 [EMAIL PROTECTED]


Re: List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Kyle Sluder
On Sat, Jun 28, 2008 at 3:56 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> I had this in my code
>
> - (void)removeAtIndexes:(NSIndexSet *)indexes
> {
>NSMutableArray *kva = [self mutableArrayValueForKey:@""];
>[kva removeObjectsAtIndexes:indexes];
> }

And you're surprised that this caused an infinite loop?  The point of
the indexed accessors is to implement the actual data manipulation for
the proxy returned by -mutableArrayValueForKey.  So all
-removeKeyAtIndexes: should do is remove the requested object from
whatever storage mechanism is being used to back that property.

--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 [EMAIL PROTECTED]


List of Indexed Accessor Names for NSMutableArray

2008-06-28 Thread Markus Spoettl

Hello List,

  is there a complete list of indexed accessor names that can be  
implemented? The KVC guides just mentions the basic ones


- (NSUInteger)countOf
- (id)objectInAtIndex:(unsigned)theIndex
- (void)get:(id *)objsPtr range:(NSRange)range
- (void)insertObject:(id)obj inAtIndex:(NSUInteger)theIndex
- (void)removeObjectFromAtIndex:(NSUInteger)theIndex
- (void)replaceObjectInAtIndex:(NSUInteger)theIndex withObject: 
(id)obj


I had this in my code

- (void)removeAtIndexes:(NSIndexSet *)indexes
{
NSMutableArray *kva = [self mutableArrayValueForKey:@""];
[kva removeObjectsAtIndexes:indexes];
}

which caused an endless recursion because [kva  
removeObjectsAtIndexes:] assumes that removeAtIndexes: is the KVC  
implementation for it. Of course it was not. I can't find any mention  
in the documentation about this accessor name.


So, is there complete list of method names or is it just all  
NSMutableArray methods that contain "Objects" in their name with  
"Objects" replaced by "" ?


Regards
Markus
--
__
Markus Spoettl



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 [EMAIL PROTECTED]

setAccessoryView question

2008-06-28 Thread Frank Fenn

Hello,

so far I could not find a solution to this problem. I'm using an  
accessoryView in a 10.4 applications page layout dialog.
Everything works, but how do I change the name that shows up in the  
settings popup button?

I looks like it always defaults to the application name.

Sincerely
Frank Fenn




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: trackmouse problems in Leopard

2008-06-28 Thread Andy Kim
For a quick test, see if putting in the following in your cell  
subclass makes it work again:


- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect: 
(NSRect)cellFrame ofView:(NSView*)controlView

{
	return NSCellHitContentArea | NSCellHitEditableTextArea |  
NSCellHitTrackableArea;

}

It might not be exactly what you want, but I'm pretty sure your  
solution is a good implementation of this method.


Andy Kim


On Jun 28, 2008, at 6:24 AM, Moray Taylor wrote:


Hi, hope someone can help...

I have an app that uses a custom NSCell that implements the

- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame  
ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp


method.

In Tiger, this works just fine, if I build targeting the 10.5 API,  
it does not work, the method does not get called at all, I can put  
an NSLog right at the start, and it never happens.


If I build targeting 10.4, it works great, even if the host machine  
is running Leopard, so it seems its an API difference.


If anyone can shed any light on this, I'd be eternally grateful!

Thanks a lot

Moray




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 [EMAIL PROTECTED]

Re: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Yoann GINI
Nota : userInfo pointer of kind NSNotification is a mistake, it's a  
NSDictionary of course.


Le 28 juin 08 à 19:58, Yoann GINI a écrit :


A part of code (this is a simply try code for a R&D):

@interface root :  NSManagedObject
@interface song :  root
@interface artist :  root
@interface modification :  NSManagedObject



-(void)dataBaseHaveChange:(NSNotification*)notification//I  
receive here the notification of a CoreData modification

{
NSNotification* userInfo= [[notification 
userInfo] retain];
NSSet*  objectsSet  = nil;

objectsSet = [userInfo valueForKey:NSInsertedObjectsKey];
for (NSManagedObject* modEntry in objectsSet) {
if ([modEntry isKindOfClass:[root class]]) {
//do something
}
}

//The same things for modified and deleted object
}


The aim of that is to record changement in the data base, but the  
record is in data base too, and I don't want to catch the  
modification of kind "modification", the solution retained for do  
that it's do something only if the managed object is a subclass of  
root. But actually the condition is never verified...





Le 28 juin 08 à 19:30, Mike Abdullah a écrit :


Post some code.

Mike.

On 28 Jun 2008, at 18:25, Yoann GINI wrote:

Ho sorry, of cours it's isKindOfClass, I've this problem since 2  
days and I've try all similar method by despair !


With isKindOfClass I've always a NO in return...

Le 28 juin 08 à 19:15, Owen Yamauchi a écrit :


On Sat, Jun 28, 2008 at 9:58 AM, Yoann GINI
<[EMAIL PROTECTED]> wrote:

   Do you have an idea ?



Use -isKindOfClass: instead. -isMemberOfClass: only tells you if an
object is an instance of that specific class. -isKindOfClass:  
includes

all superclasses as well.

Owen
[forgot to reply-all]


___

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

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

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

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/yoann.gini%40inig-services.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: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Yoann GINI
Answer for the other mail (from Bill) : Yes, my objectsSet contain my  
object, and when I display the class type of this object in a NSLog I  
obtain the good thing (artist, song, modification).


Sorry for the conventions, this is just a "test code"...

root is the name of the class used for the entity and for the class  
represent the entity (that is the default behaviour when you create a  
new class for custom a existing entity in a .xcdatamodel)


The entity root is an abstract class what contain the common  
attributes, song and artist inherit from the root entity


Le 28 juin 08 à 20:15, mmalc crawford a écrit :



On Jun 28, 2008, at 11:07 AM, Yoann GINI wrote:

@interface root :  NSManagedObject
@interface song :  root
@interface artist :  root
@interface modification :  NSManagedObject
This doesn't work with isKindOfEntity, used like that :
	NSEntityDescription*		rootDescription		= [[NSEntityDescription  
entityForName:@"root" inManagedObjectContext:[self  
managedObjectContext]] retain];

...
[rootDescription isKindOfEntity:[modEntry entity]]
It's always return NO...



Is "root" the name of the *entity* or of the *class* used to  
represent the entity?
Whichever, it's helpful if you adhere to standard naming conventions  
by capitalising the names of both.


If the entity name is "root", then do the "song" and "artist"  
entities inherit from that entity?


mmalc



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


[SOLVED] NSPopupButton Bindings-Related Issue

2008-06-28 Thread Keary Suska
For perpetuity, to do what I wanted I needed to bind selectedIndex to the
controller's "selectionIndex". I was avoiding this because it requires me to
have an outlet to the controller for conditionally enabling/disabling popup
items. Oh well.

Best,

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

-- Forwarded Message
> From: Keary Suska <[EMAIL PROTECTED]>
> Date: Sat, 28 Jun 2008 11:15:46 -0600
> To: Ken Thomases <[EMAIL PROTECTED]>
> Conversation: NSPopupButton Bindings-Related Issue
> Subject: Re: NSPopupButton Bindings-Related Issue
> 
> 6/28/08 12:30 AM, also sprach [EMAIL PROTECTED]:
> 
>> On Jun 27, 2008, at 11:01 PM, Keary Suska wrote:
>> 
>>> Generally, my needs are simple. In this case, I need a sheet that  displays
>>> an nspopupbutton populated with product names, where a user can  select an
>>> item from the popup and a description of the item would appear in a
>>> designated space below the control, and of course I want to retrieve  the
>>> value after the sheet is dismissed, providing that the correct  button is
>>> pressed. Sounds easy, right?
>>> 
>>> So, I have an NSPanel with an NSPopupButton, NSTextField, and two  buttons
>>> ("Cancel" and "Use"). The NSPopupButton "content" is bound to
>>> "ProductController", which is a special NSArrayController subclass  whose
>>> content is an array objects I am interested in, with key  "arrangedObjects"
>>> no key path. "Content values" is bound to same with key path "name".
>>> "Selected value" is bound to same but with controller key  "selection" and
>>> key path "name". NSTextField "value" is bound to ProductController
>>> "selection" key path "descrip".
>> 
>> The last two bindings are incorrect, I think.  Bind the pop-up's  Selected
>> Object to a property of your model, not the array  controller's selection.
>> That is, when the pop-up has an item  selected, it will stuff that object
>> (the 
>> "product") into that property  of your model.
> 
> The "selected" binding very well may be wrong. I didn't give the history
> there. If I don't bind anything there, the controller won't maintain a
> selection--i.e. the controller selection never changes. I tried various
> bindings, but I also have the issue of needing a sensible representedObject.
> 
> Anyway, one key, or issue, is that none of this setup is part of a
> relationship, which your description above would apply to. I.e., there is no
> separate model object that wants the selected object. There is only a
> controller that wants it, but only if the user doesn't cancel the dialog.
> 
> It could be that an NSArrayController can only function in a relationship, but
> I was hoping that wasn't necessary. All I want is a simple MVC: my model, an
> array of objects; my view, an NSPopUpButton (and NSTextField on the side); my
> contoller, a simple NSArrayController. BTW, I lied about it being a
> subclass--it's just a vanilla NSArrayController.
> 
> I just want the array controller to do its job--maintain a selection that I
> can get later.
> 
>> Then, binding your text field's Value to that same model property,  except
>> adding on ".descrip" to the key path.
> 
> No, this would be incorrect. View should always bind to a controller, and I
> shouldn't need an additional one. My binding is a typical type used in a
> master-detail interface.
> 
>> This sort of arrangement is illustrated in the "Real-World Example" in
>> the Cocoa Bindings Programming Topics:
>> 
>
e
>> pts/WhatAreBindings.html#//apple_ref/doc/uid/20002372-181136
> 
> This shows the binding that I am currently sing, BTW. Anyway, I should
> probably start googling for implementing a maser-detail interface using
> NSPopupButton, which seems to involve some sort of trickery.
> 
> Thanks for the assist,
> 
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"

-- End of Forwarded Message


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: trackmouse problems in Leopard

2008-06-28 Thread Moray Taylor
Hi, thanks for the reply

It's an NSTextFieldCell subclass, and it's setup as the data cell for the 
column in Interface Builder.

I've tried making in just a plain NSCell subclass, but it doesn't make any 
difference.


Thanks a lot

Moray

--- On Sat, 28/6/08, Andreas Mayer <[EMAIL PROTECTED]> wrote:

> From: Andreas Mayer <[EMAIL PROTECTED]>
> Subject: Re: trackmouse problems in Leopard
> To: cocoa-dev@lists.apple.com
> Date: Saturday, 28 June, 2008, 5:28 PM
> Am 28.06.2008 um 15:24 Uhr schrieb Moray Taylor:
> 
> > I have an app that uses a custom NSCell that
> implements the
> >
> > - (BOOL)trackMouse:(NSEvent *)theEvent
> inRect:(NSRect)cellFrame  
> > ofView:(NSView *)controlView
> untilMouseUp:(BOOL)untilMouseUp
> >
> > method.
> >
> > In Tiger, this works just fine, if I build targeting
> the 10.5 API,  
> > it does not work, the method does not get called at
> all, I can put  
> > an NSLog right at the start, and it never happens.
> 
> Since I'm using this methods myself and it works in
> Leopard just as it  
> did in Tiger for me, I guess we need to see more code to
> diagnose your  
> problem.
> 
> Did you subclass some control or just a cell? How do you
> create and  
> set the cell?
> 
> 
> Andreas
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to
> the list.
> Contact the moderators at
> cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/moray_taylor%40yahoo.co.uk
> 
> This email sent to [EMAIL PROTECTED]


  __
Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at 
Yahoo! http://uk.docs.yahoo.com/ymail/new.html
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread mmalc crawford


On Jun 28, 2008, at 11:07 AM, Yoann GINI wrote:

@interface root :  NSManagedObject
@interface song :  root
@interface artist :  root
@interface modification :  NSManagedObject
This doesn't work with isKindOfEntity, used like that :
	NSEntityDescription*		rootDescription		= [[NSEntityDescription  
entityForName:@"root" inManagedObjectContext:[self  
managedObjectContext]] retain];

...
[rootDescription isKindOfEntity:[modEntry entity]]
It's always return NO...



Is "root" the name of the *entity* or of the *class* used to represent  
the entity?
Whichever, it's helpful if you adhere to standard naming conventions  
by capitalising the names of both.


If the entity name is "root", then do the "song" and "artist" entities  
inherit from that entity?


mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: [SOLVED] noob question regarding proxy object returned by -selection method of NSArrayController

2008-06-28 Thread Owen Yamauchi
How about [[controller selection] valueForKey:@"self"]? NSObject has a
-self method which just returns the receiver, and since the proxy
object must respond to the KVC query as if it were the underlying
object, you get the underlying object back.

Owen
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Bill Bumgarner

On Jun 28, 2008, at 10:58 AM, Yoann GINI wrote:

@interface root :  NSManagedObject
@interface song :  root
@interface artist :  root
@interface modification :  NSManagedObject


Obj-C classes start with a capital letter, by convention.  So -- Root,  
Song, Artist, and Modification would be standard.


-(void)dataBaseHaveChange:(NSNotification*)notification//I  
receive here the notification of a CoreData modification

{
NSNotification* userInfo= [[notification 
userInfo] retain];


No need to -retain the userInfo.



NSSet*  objectsSet  = nil;

objectsSet = [userInfo valueForKey:NSInsertedObjectsKey];


You want -objectForKey:  -valueForKey: is for key value coding, - 
objectForKey: is for extracting objects from a dictionary.


Shouldn't cause a problem.



for (NSManagedObject* modEntry in objectsSet) {


Are you sure objectsSet contains any objects?



if ([modEntry isKindOfClass:[root class]]) {
//do something
}
}


b.bum

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 [EMAIL PROTECTED]

Re: Style Question (Robert Claeson)

2008-06-28 Thread Roni Music
the bottom of the page below has one opinion why one style is superior to 
the other,
(at least when it comes to C++ and the way C++ objects behave when going out 
of scope)



http://www.relisoft.com/book/lang/scopes/2local.html






On 28 Jun 2008, at 06:30, Alex Wait wrote:


I have noticed, coming from C++ and Visual Studio (at school), a
couple
style differences

if (value) {
   //do something
}

insteasd of

if (value)
{
   //do something
}

Also since I am using this style, XCode doesn't tab in for me when I
type {
then a return. This is the style I "taught" and I would like to
continue the
good habits
during the summer.


I learned C on Unix long before Microsoft had started producing
Windows 1.0. The first style was the first style I learned. I believe
it's called the K&R style (from the inventors of C) and it also seems
to be the preferred style in Java if you look in Sun's Java
documentation. When I then learned C++ back in 1988 (from Bjarne
Stroustrup, nonetheless), the K&R style was still the style being used.

The first time I came across the latter style was when I had to work
on some Windows C and C++ style. I believe the style was more or less
invented by Microsoft. Most of the Unix/Linux/Cocoa code I've worked
on has used the K&R style.

I personally prefer the K&R style as it is more compact. I can get a
better sense of the code on a screenful, while a larger portion of the
screen estate is consumed by syntactics (curly braces) that really
doesn't add much of a value in the latter style.

But it's mostly a matter of personal preference. Cocoa doesn't care
and neither does Xcode. You should be able to set up Xcode to indent
properly for you even when using the latter style. If it can't, file a
bug report on bugreporter.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 [EMAIL PROTECTED]


Re: NSSpeechSynthesizer and empty strings

2008-06-28 Thread Jim Correia

On Jun 26, 2008, at 8:32 PM, Nick Zitzmann wrote:


On Jun 26, 2008, at 6:16 PM, William Squires wrote:

Actually, "if ([myString length] == 0)" is probably better, but  
just IMHO... :)


No; don't ever do that. It is possible for an NSString to have zero  
length but not be empty. See  for details.


That isn't what Mike said. He said that it possible for a *non-empty*  
string can be semantically equal to @"".


A string with 0 length is, obviously, always empty.

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 [EMAIL PROTECTED]


Re: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Yoann GINI

This doesn't work with isKindOfEntity, used like that :

	NSEntityDescription*		rootDescription		= [[NSEntityDescription  
entityForName:@"root" inManagedObjectContext:[self  
managedObjectContext]] retain];

...
[rootDescription isKindOfEntity:[modEntry entity]]

It's always return NO...


Le 28 juin 08 à 19:32, mmalc crawford a écrit :


On Jun 28, 2008, at 10:15 AM, Owen Yamauchi wrote:


On Jun 28, 2008, at 9:58 AM, Yoann GINI wrote:
	I've a CoreData base with some kind of object what are a subclass  
of an abstract class called "root" (root is a subclass of  
NSManagedObject). In a part of my code I need to catch all  
operation on object what are a child of root. For do that I use  
the notification  
NSManagedObjectContextObjectsDidChangeNotification and I would use  
"isMemberOfClass" method for test each objet. I don't know why but  
this method always return "NO" even of an object what are a chlid  
of root...



Use -isKindOfClass: instead. -isMemberOfClass: only tells you if an
object is an instance of that specific class. -isKindOfClass:  
includes

all superclasses as well.


isKindOfClass: includes all *subclasses* as well.

You should almost certainly, though, not be using class-based tests  
-- you should instead test the entity of the managed object (if you  
need to test for subentities, use isKindOfEntity).


mmalc



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


[SOLVED] noob question regarding proxy object returned by -selection method of NSArrayController

2008-06-28 Thread Stuart Malin

Sorry for the post  how did I miss -selectedObjects

Begin forwarded message:
From: Stuart Malin <[EMAIL PROTECTED]>
Date: June 28, 2008 10:43:36 AM PDT
To: Cocoa Developer List 
Subject: noob question regarding proxy object returned by -selection  
method of NSArrayController


Still pursuing my understanding of bindings:

I have a table view whose columns are bound to an NSArrayController,  
which in turn has its contentObject that is a mutable array of Person  
objects. Person objects have KVC-conforming properties, which provide  
the values for the data in the columns of the table. This all works.


I have a button in the GUI that should cause various changes to the  
person selected in the table. In the method that is the target of the  
button's action, I need to get the selected Person object so I can  
operate on it.


I know I could use the  -selection method of the NSController to get  
a proxy object, and then use -valueForKey: and -setValueForKey to  
operate on the object via the proxy. However, this puts the logic of  
the manipulations in my appController. I'd rather the collection of  
manipulations be in the Person class,  (i.e., have instance methods  
in the Person class that update a person object).


If I do this (have the update logic in the Person class),  then I  
can't use the proxy object returned by the -selection method of the  
NSController (because the proxy object doesn't respond to the methods  
of the backing class).


My question is: What is the best way to get the actual model entry,  
so such instance methods can be invoked?


BTW: I have one solution, which is to send the controller a - 
selectionIndex message, and use the resulting index to directly  
access the backing store. But doing this is based on knowing what  
that backing content object is, which seems like I am using side  
knowledge in my appController, and so I wonder if there is a way to  
get the actual model content object directly from the  
NSArrayController


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Yoann GINI

A part of code (this is a simply try code for a R&D):

@interface root :  NSManagedObject
@interface song :  root
@interface artist :  root
@interface modification :  NSManagedObject



-(void)dataBaseHaveChange:(NSNotification*)notification//I receive  
here the notification of a CoreData modification

{
NSNotification* userInfo= [[notification 
userInfo] retain];
NSSet*  objectsSet  = nil;

objectsSet = [userInfo valueForKey:NSInsertedObjectsKey];
for (NSManagedObject* modEntry in objectsSet) {
if ([modEntry isKindOfClass:[root class]]) {
//do something
}
}

//The same things for modified and deleted object
}


The aim of that is to record changement in the data base, but the  
record is in data base too, and I don't want to catch the modification  
of kind "modification", the solution retained for do that it's do  
something only if the managed object is a subclass of root. But  
actually the condition is never verified...





Le 28 juin 08 à 19:30, Mike Abdullah a écrit :


Post some code.

Mike.

On 28 Jun 2008, at 18:25, Yoann GINI wrote:

Ho sorry, of cours it's isKindOfClass, I've this problem since 2  
days and I've try all similar method by despair !


With isKindOfClass I've always a NO in return...

Le 28 juin 08 à 19:15, Owen Yamauchi a écrit :


On Sat, Jun 28, 2008 at 9:58 AM, Yoann GINI
<[EMAIL PROTECTED]> wrote:

Do you have an idea ?



Use -isKindOfClass: instead. -isMemberOfClass: only tells you if an
object is an instance of that specific class. -isKindOfClass:  
includes

all superclasses as well.

Owen
[forgot to reply-all]


___

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

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

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

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: switching content views

2008-06-28 Thread dudley ackerman


On Jun 28, 2008, at 7:35 AM, Shawn Erickson wrote:


On Jun 27, 2008, at 11:33 PM, dudley ackerman <[EMAIL PROTECTED]>  
wrote:


i can call setContentView on my app's window only if i don't plug  
in a 2nd monitor.
posts on this topic in the archives say you can't simple call  
setContentView on a window -

i'm not clear if that means even once.
even with a 2nd monitor, the call always works the 1st time for me  
-- perhaps accidentally.


i can see no frames or bounds


Can you better explain the problem you are having?

Having secondary monitors should have no affect at the view level.  
So something else is wrong.


i have 2 views in a nib file.
the first one is used as [window setContentView:<1stview>] in my  
controller's awakeFromNib, and the view is populated dynamically with  
layerbacked subviews.

the window is set to be the desktop behind everything else.

on a menu command, the window is changed to a normal desktop window.
everything displays correctly.

then on a menu command a want to switch the 2nd nib view and populate  
it with subviews.
i see the subviews being created, but the window gets drawn with a  
black background and no drawing of my views.
i can mouse over where the subviews are and see tooltips popup, and i  
can click where the subviews are and bring up an image or show a movie  
in the window.

it does this by doing [window setContentView:].

but on menu command to go back to my 2nd content view, it is back to  
black.


again -- the window is on my 1st monitor and all is fine if i don't  
have my 2nd monitor plugged in.

any windows from other apps on my 2nd monitor are fine.

this is on a macbook pro with leopard 10.5.3.

i am thinking of trying to bring up the window on the 2nd monitor and  
see if it displays correctly there.
it doesn't seem to have something to do with the extend of the screen  
being extend upward: my 2nd monitor is positioned above my 1st  
(logically and physically).
because it doesn't help to logically position the 2nd monitor to the  
side of the 1st.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: noob question regarding proxy object returned by -selection method of NSArrayController

2008-06-28 Thread Keary Suska
6/28/08 11:43 AM, also sprach [EMAIL PROTECTED]:

> If I do this (have the update logic in the Person class),  then I
> can't use the proxy object returned by the -selection method of the
> NSController (because the proxy object doesn't respond to the methods
> of the backing class).
> 
> My question is: What is the best way to get the actual model entry,
> so such instance methods can be invoked?

I call [[arrayController selectedObjects] objectAtIndex:0] to get the actual
object.

> BTW: I have one solution, which is to send the controller a -
> selectionIndex message, and use the resulting index to directly
> access the backing store. But doing this is based on knowing what
> that backing content object is, which seems like I am using side
> knowledge in my appController, and so I wonder if there is a way to
> get the actual model content object directly from the
> NSArrayController

Probably a bad idea. You can't guarantee the order unless, as you say, your
controller knows too much about the view. You could use the index but use it
on -arrangedObjects, however.

HTH,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


noob question regarding proxy object returned by -selection method of NSArrayController

2008-06-28 Thread Stuart Malin

Still pursuing my understanding of bindings:

I have a table view whose columns are bound to an NSArrayController,  
which in turn has its contentObject that is a mutable array of Person  
objects. Person objects have KVC-conforming properties, which provide  
the values for the data in the columns of the table. This all works.


I have a button in the GUI that should cause various changes to the  
person selected in the table. In the method that is the target of the  
button's action, I need to get the selected Person object so I can  
operate on it.


I know I could use the  -selection method of the NSController to get  
a proxy object, and then use -valueForKey: and -setValueForKey to  
operate on the object via the proxy. However, this puts the logic of  
the manipulations in my appController. I'd rather the collection of  
manipulations be in the Person class,  (i.e., have instance methods  
in the Person class that update a person object).


If I do this (have the update logic in the Person class),  then I  
can't use the proxy object returned by the -selection method of the  
NSController (because the proxy object doesn't respond to the methods  
of the backing class).


My question is: What is the best way to get the actual model entry,  
so such instance methods can be invoked?


BTW: I have one solution, which is to send the controller a - 
selectionIndex message, and use the resulting index to directly  
access the backing store. But doing this is based on knowing what  
that backing content object is, which seems like I am using side  
knowledge in my appController, and so I wonder if there is a way to  
get the actual model content object directly from the  
NSArrayController




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread mmalc crawford

On Jun 28, 2008, at 10:15 AM, Owen Yamauchi wrote:


On Jun 28, 2008, at 9:58 AM, Yoann GINI wrote:
	I've a CoreData base with some kind of object what are a subclass  
of an abstract class called "root" (root is a subclass of  
NSManagedObject). In a part of my code I need to catch all  
operation on object what are a child of root. For do that I use the  
notification NSManagedObjectContextObjectsDidChangeNotification and  
I would use "isMemberOfClass" method for test each objet. I don't  
know why but this method always return "NO" even of an object what  
are a chlid of root...



Use -isKindOfClass: instead. -isMemberOfClass: only tells you if an
object is an instance of that specific class. -isKindOfClass: includes
all superclasses as well.


isKindOfClass: includes all *subclasses* as well.

You should almost certainly, though, not be using class-based tests --  
you should instead test the entity of the managed object (if you need  
to test for subentities, use isKindOfEntity).


mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Charles Srstka

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

Yeah, it surprises me, too, that NSObject has an implementation of  
bind:toObject:withKeyPath:options:.  I had thought that it was just  
part of an informal protocol -- that is, that it was declared in a  
category on NSObject, but never implemented except by specific  
classes which adopted that protocol.  However, I did a symbol dump  
of the AppKit framework and I see that there is, in fact, an  
implementation.  I have no idea what it could be doing.


Actually, I gave it a little thought, and perhaps the purpose of  
NSObject's default implementation is just to make it easier to  
implement the stuff that's mentioned in that "how bindings work"  
document. The built-in implementation provides the bindings in one  
direction for us - all we have to do is supply the bindings in the  
other direction, so adding an NSMutableDictionary instance variable to  
the view and then adding these methods:


- (void)bind:(NSString *)key toObject:(id)obj withKeyPath:(NSString  
*)keyPath options:(NSDictionary *)options {
NSDictionary *binding = [NSDictionary  
dictionaryWithObjectsAndKeys:key, @"key", obj, @"target", keyPath,  
@"keyPath", nil];


[ivar_bindingsDict setObject:binding forKey:key];

[super bind:key toObject:obj withKeyPath:keyPath options:options];
}

- (void)unbind:(NSString *)key {
[ivar_bindingsDict removeObjectForKey:key];
}

- (void)fireNotificationsForKey:(NSString *)key {
NSDictionary *binding = [ivar_bindingsDict objectForKey:key];

if(binding) {
id target = [binding objectForKey:@"target"];
NSString *keyPath = [binding objectForKey:@"keyPath"];

[target setValue:[self valueForKey:key] forKeyPath:keyPath];
}
}

and then just calling [self fireNotificationsForKey:@"someKey"] each  
time you modify whatever it is in the view's state that will cause the  
binding "someKey" to need to be updated, would pretty much do it, am I  
right?


(I suppose you'd also want to expose your available bindings by  
calling +exposeBinding: in your +initialize method and implement  
valueClassForBinding: if you're going to make an Interface Builder  
palette for your view)


Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Mike Abdullah

Post some code.

Mike.

On 28 Jun 2008, at 18:25, Yoann GINI wrote:

Ho sorry, of cours it's isKindOfClass, I've this problem since 2  
days and I've try all similar method by despair !


With isKindOfClass I've always a NO in return...

Le 28 juin 08 à 19:15, Owen Yamauchi a écrit :


On Sat, Jun 28, 2008 at 9:58 AM, Yoann GINI
<[EMAIL PROTECTED]> wrote:

 Do you have an idea ?



Use -isKindOfClass: instead. -isMemberOfClass: only tells you if an
object is an instance of that specific class. -isKindOfClass:  
includes

all superclasses as well.

Owen
[forgot to reply-all]


___

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

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

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

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: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Yoann GINI
Ho sorry, of cours it's isKindOfClass, I've this problem since 2 days  
and I've try all similar method by despair !


With isKindOfClass I've always a NO in return...

Le 28 juin 08 à 19:15, Owen Yamauchi a écrit :


On Sat, Jun 28, 2008 at 9:58 AM, Yoann GINI
<[EMAIL PROTECTED]> wrote:

  Do you have an idea ?



Use -isKindOfClass: instead. -isMemberOfClass: only tells you if an
object is an instance of that specific class. -isKindOfClass: includes
all superclasses as well.

Owen
[forgot to reply-all]


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Owen Yamauchi
On Sat, Jun 28, 2008 at 9:58 AM, Yoann GINI
<[EMAIL PROTECTED]> wrote:
>Do you have an idea ?
>

Use -isKindOfClass: instead. -isMemberOfClass: only tells you if an
object is an instance of that specific class. -isKindOfClass: includes
all superclasses as well.

Owen
[forgot to reply-all]
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-28 Thread Yoann GINI

Hi all,

	I've a CoreData base with some kind of object what are a subclass of  
an abstract class called "root" (root is a subclass of  
NSManagedObject). In a part of my code I need to catch all operation  
on object what are a child of root. For do that I use the notification  
NSManagedObjectContextObjectsDidChangeNotification and I would use  
"isMemberOfClass" method for test each objet. I don't know why but  
this method always return "NO" even of an object what are a chlid of  
root...


Do you have an idea ?

Bests regards,
Yoann.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 deal with a MenuItem with both a binded state property and an action method

2008-06-28 Thread Keary Suska
6/28/08 8:54 AM, also sprach [EMAIL PROTECTED]:

> To sumarize, the problem is that I am not able to change the menuItem
> state programatically (ie. in myAction) without avoiding the second
> call to setMenuState. However if the call to myAction comes from a
> button set up in IB (instead the menuItem), then everything goes ok.
> In that case myAction is called by the click of the button and if the
> state of the menuItem is updated by myAction then it is correctly
> changed. No second call to setMenuState is received because the
> originating event came from the button. On the contrary if the event
> originates from the menuItem, first myAction is called, and then
> setMenuState is called.

With controls, the bound value is changed *before* the target-action is
called, as you are seeing, but it seems NSMenuItem does the opposite. If the
calls are sequential--i.e. without a call to the run loop--you could use
performSelector:withObject:afterDelay:to make the setMenuState call.

HTH,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: trackmouse problems in Leopard

2008-06-28 Thread Andreas Mayer


Am 28.06.2008 um 15:24 Uhr schrieb Moray Taylor:


I have an app that uses a custom NSCell that implements the

- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame  
ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp


method.

In Tiger, this works just fine, if I build targeting the 10.5 API,  
it does not work, the method does not get called at all, I can put  
an NSLog right at the start, and it never happens.


Since I'm using this methods myself and it works in Leopard just as it  
did in Tiger for me, I guess we need to see more code to diagnose your  
problem.


Did you subclass some control or just a cell? How do you create and  
set the cell?



Andreas
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: while loop with sleep(): logging works, but not UI events

2008-06-28 Thread Shawn Erickson
On Sat, Jun 28, 2008 at 8:29 AM, Shawn Erickson <[EMAIL PROTECTED]> wrote:
> On Sat, Jun 28, 2008 at 8:13 AM, Daniel Richman
> <[EMAIL PROTECTED]> wrote:
>> Thanks very much for this detailed explanation. I realize my mistake now; I
>> was thinking about this in the wrong way. I eventually coded it as follows:
>>
>> - (IBAction)startTimer:(id)sender
>> { timeInSeconds = [((NSNumber *)[inTextField objectValue]) intValue];
>>   [NSTimer scheduledTimerWithTimeInterval:1.0
>>target:self
>>  selector:@selector(checkTimer:)
>>  userInfo:nil
>>   repeats:YES];
>> }
>>
>>
>> - (void)checkTimer:(NSTimer *)timer
>> {
>>   if (timeInSeconds == 0) {
>>   [timer invalidate];
>>   [outTextField setStringValue:@"Finished timing"];
>>   } else {
>>   [outTextField setStringValue:[NSString stringWithFormat:@"%d more
>> second(s) to go", timeInSeconds]];
>>   NSLog(@"in loop, timeInSeconds is %d", timeInSeconds);
>>   timeInSeconds--;
>>   }
>> }
>
> You really shouldn't use an NSTimer to count time as you are doing
> above. For example your timer can be delayed from firing because of
> other work taking place on the main thread. Over a long enough period
> of time (use enters a larger value for seconds) these small delays can
> build up and cause you to miscount time when compared to wall clock
> time.
>
> You should instead use something like NSDate. For example create an
> NSDate instance for the finish time (consider +[NSDate
> dateWithTimeIntervalSinceNow:]) in you action method and then in your
> check timer method look at that date to see if you have passed it to
> know if you are done. Also you would use current time and finish time
> to calculate how many seconds remand. You get current time using
> -[NSDate date].
>
> You could also consider two timers... one firing often to cause you to
> update the UI and the other firing once at the finish time.

Ah found it...

http://lists.apple.com/archives/cocoa-dev/2006/Nov/msg00447.html

...and you can count using a timer if you use a constant time based
(see my email related to the linked email thread)...

http://lists.apple.com/archives/cocoa-dev/2006/Nov/msg00494.html

-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 [EMAIL PROTECTED]


Re: KVO Question -- Really Simple for Pros

2008-06-28 Thread mmalc Crawford


On Jun 27, 2008, at 11:29 PM, Alex Wait wrote:

What I need to know is what I need to add to get the text field to  
update

whenever firstName is changed. I want it to set
the value of its string value to the string.


That's explained in the document for which I provided the link...

mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Charles Srstka

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

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


I wouldn't worry about that too much - everything you said seems to  
jibe perfectly with what views do - the text field's binding *is*  
called "value" and not "stringValue" (that was my bad), and there's no  
corresponding "value" instance method on NSTextView nor any of its  
superclasses, nor does running class-dump on the AppKit turn up a  
"value" method on any class in the AppKit except for  
_NSControllerKeyValuePair, whatever that is. So in the typical case of  
views, you'd seem to be correct that the bindings represent something  
other than properties, and live in a different namespace.


However, NSObject does have a default implementation of  
bind:toObject:withKeyPath:options:, which must have some purpose.  
Setting up a two-way binding by running the binding twice does seem to  
work, although I don't know how "kosher" it is, and it does seem less  
than satisfactory to me as, like you mentioned, it doesn't seem to  
work with a key path for the first argument, making it necessary to  
take the controller out of the equation. So it's definitely probably  
better to override bind:toObject:withKeyPath:options: on the view, to  
allow for using a controller and having a cleaner implementation.


After thinking about it a bit, though, I don't think infinite loops  
should be a problem, because my guess as to how the bindings work is  
that the willChangeValueForKey: method probably registers the object  
somewhere as being in the middle of setting that key, and then when  
the bindings system goes around looking for objects to set that key  
for, it would pass over the ones that have indicated they're already  
setting that key by calling willChangeValueForKey: I'd expect then  
that didChangeValueForKey: would clear that status (along with asking  
the bindings system to update any object that observes that key and  
hasn't called willChangeValueForKey: recently). So infinite loops  
shouldn't be much of a problem if I'm understanding this right.


I think what we can all take home from this is that the documentation  
for bindings needs to be clearer and less self-contradictory on the  
very basic concept of exactly what Cocoa Bindings *is*.


Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: while loop with sleep(): logging works, but not UI events

2008-06-28 Thread Daniel Richman
One second seems to be accurate enough for my purposes, but I'll 
investigate using 0.5 seconds.


Daniel


Shawn Erickson wrote:

On Sat, Jun 28, 2008 at 7:58 AM, Michael Ash <[EMAIL PROTECTED]> wrote:
  

On Sat, Jun 28, 2008 at 12:10 AM, Shawn Erickson <[EMAIL PROTECTED]> wrote:


Also you should fire your timer every
0.75 of seconds (or so) to ensure your UI update is consistent/smooth.
Firing every second may cause your timer to fire a little after 1
second later so your UI could skip from say 50s to 52s.
  

I do not recommend this, as using 0.75s will guarantee a jittery
update. Consider what happens when you start at 0 and round down to
figure out what to display. You'll display 0, then 0 again. Then
you'll display 1, at 1.5 seconds after start, then 2 and 3 each 0.75
seconds after the previous number. The cycle repeats with 4, which
displays 1.5 seconds after 3.



Actually I meant to type 0.5s which is what I use in my code for this
type of thing and you don't want to use the timer to track time but
the actual system clock... assuming you use a simple repeating timer.

Firing once every 1 second can cause you skip numbers as timer jitter
walks near to a second boundary based on wall clock time assuming
you use a simple repeating timer and don't round as you suggest.

If you reschedule a timer every time the prior timer fires you can use
a 1 second timer delay if you attempt to ensure that your current time
isn't close to a second boundary of the wall clock.

..or rounding can be used (depends on how you are calculating the time, etc.)

-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/applemaillist%40mm.danielrichman.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: while loop with sleep(): logging works, but not UI events

2008-06-28 Thread Daniel Richman
Thanks very much for this detailed explanation. I realize my mistake 
now; I was thinking about this in the wrong way. I eventually coded it 
as follows:


- (IBAction)startTimer:(id)sender
{   
   timeInSeconds = [((NSNumber *)[inTextField objectValue]) intValue];

   [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
  selector:@selector(checkTimer:)
  userInfo:nil
   repeats:YES];
}


- (void)checkTimer:(NSTimer *)timer
{
   if (timeInSeconds == 0) {
   [timer invalidate];
   [outTextField setStringValue:@"Finished timing"];
   } else {
   [outTextField setStringValue:[NSString stringWithFormat:@"%d 
more second(s) to go", timeInSeconds]];

   NSLog(@"in loop, timeInSeconds is %d", timeInSeconds);
   timeInSeconds--;
   }
}   



Thanks again to all.
Daniel


Ken Thomases wrote:

On Jun 27, 2008, at 10:55 PM, Daniel Richman wrote:

I'm trying to program a simple timer app: you enter a number of 
seconds, and it updates a text field every second with the number of 
secs remaining. The problem is that I'm not able to do anything with 
the UI while this is going on. Here's my code:


- (IBAction)startTimer:(id)sender
{
  [startButton setState:NSOffState];
int timeInSeconds = [((NSNumber *)[inTextField objectValue]) 
intValue];

while (timeInSeconds > 0) {
  [outTextField setStringValue:[NSString stringWithFormat:@"%d 
more second(s) to go", timeInSeconds]];

sleep(1);
  timeInSeconds--;
  }
[outTextField setStringValue:@"Finished timing"];
  NSBeep();
}

What's happening is that if I enter a number and then press 'start', 
'start' stays in the 'pressed' position until the loop finishes, 
after which it returns to the normal position. My guess is that this 
is stopping any other UI events from occurring. This would also 
explain why I'm able to log a message each time the loop iterates.


But I'm still not sure why the button is staying pressed. Thoughts, 
anyone?


What others have said is correct, but I wanted to provide some more 
explanation.


Let's think about why the button is staying pressed.  I'll illustrate 
purely using pseudocode.  I'm _not_ implying that this is literally 
what's happening, but let's imagine that your button click is 
processed by code which looks something like this:


while (get an event)
{
if (event is a mouse click on a button)
{
paint the button as pressed
invoke the button's action method on the button's target  // 
this calls your startTimer: method

paint the button as normal
}
else /* ... */
}

Now, can you see why the button is staying pressed?  The invocation of 
your startTimer: method is not exiting until N seconds go by, and the 
button doesn't get repainted until after it does.  The code in the 
framework isn't magical or special.  Just like code that you write, it 
has to finish with one thing before it can go on to the next thing.  
In your code, you wouldn't expect the [outTextField 
setStringValue:@"Finished timing"] to be performed before the while 
loop exits.  Why would you expect anything else to?


Next, let's image we insert some code into the while loop, at the end 
of the block:


while (get an event)
{
if (event is a mouse click on a button)
/* ... same as above ... */

for each window
{
for each view in this window which needs to be redrawn due to 
a state change

draw this view
}
}

This window and view redrawing code is what is responsible for showing 
the changes you make to the output text field.  So, by blocking inside 
startTimer: you're not only preventing the button from being redrawn, 
you're also preventing the output text field from being redrawn with 
its new content.



That's the explanation behind what the others have told you.  Unless 
and until your method returns, none of the other work that's waiting 
to be done will get done.


I hope that helps.

Cheers,
Ken

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Prevent Asynchronous operation of beginSheetModalForWindow

2008-06-28 Thread John Love
> (1) warning: no doSheetSelection:contextInfo method found which, I think,
>> is
>> due to the fact that the external class of mFileSheetDelegate =
>> FileController, yet when referenced in SaveSheetController, it's = id, a
>> general pointer.  But, I thought all anonymous pointers were resolved at
>> runtime ... am I just going to force myself to ignore this Build Warning,
>> knowing that it will all go away at runtime???
>>
>
>
> The reason for this is because the sheet controller is not aware of your
> File Controller's methods. Nor should it be. So how to resolve it? The
> answer is to declare the callback method as an informal protocol *within
> SheetController.h* Thus:
>
> I figured this out while I was mowing the lawn yesterday (before reading
this reply) (really!) -- do not have a clue what sort of Freudian psychology
this demonstrates -- cutting off the heads of delegates and informal
protocols, maybe?  Regardless of the deviant psychology, I remember thinking
(while pushing the mower) "so that's what informal protocols are good for ..
delaying the presentation of Build Errors until runtime when all unresolved
references are - duh - resolved!!!"


>
>  (2)I still get "unrecognized selector" .. but,
>>
>
> That's because you're targeting the wrong object. Here:
>

no psychology here, just plain brain-dead on my part


>
> You have got to get these relationships straight in your mind. It's not
> that hard. I've goaded and prompted you and written your code for you piece
> by piece - that's great, it solves your problem. But has it increased your
> understanding? I fear it hasn't, and it still all seems like voodoo. I'm not
> sure what I can do about that.
>

Amen to that .. no excuses here .. trying to do too many things at once ..
get re-acquainted with C, trying to use the same logic as my application's
AppleScript Studio Project counterpart .. Cocoa delegates .. who does what
to whom behind the scenes.

Anyway, it finally sunk in to keep all UI objects(buttons) local to the
individual sheet controllers and have the file controller worry only about
return codes.  I also figured out (quirky psychology as noted above)
informal protocols .. my file controller imports "WhateverSheetController.h"
and to do away with informal protocols would necessitate
"WhateverSheetController.h" to import "FileController.h", aka a perfect
circle, aka failure to compile.

BTW, the reason for my originally passing (NSWindow*)sheet to
"doSheetSelection" within FileController.m was so this method could call
[sheet closeOut:self] .. not required now that I call the latter within the
sheet's didEndSelector.

I'll guarantee you one thing .. no one could ask for a more patient teacher
that you .. trust me, I mean that, every syllable. You remind me of an old
Physics prof I had many, many, many years ago who made physics sound so darn
simple (once it sunk in, which it did with minimal effort since I was so
young at the time).

Anyway, got some more things to understand (Menus and Toolbars) and probably
more questions to ask later, so ...

John
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: while loop with sleep(): logging works, but not UI events

2008-06-28 Thread Shawn Erickson
On Sat, Jun 28, 2008 at 7:58 AM, Michael Ash <[EMAIL PROTECTED]> wrote:
> On Sat, Jun 28, 2008 at 12:10 AM, Shawn Erickson <[EMAIL PROTECTED]> wrote:
>> Also you should fire your timer every
>> 0.75 of seconds (or so) to ensure your UI update is consistent/smooth.
>> Firing every second may cause your timer to fire a little after 1
>> second later so your UI could skip from say 50s to 52s.
>
> I do not recommend this, as using 0.75s will guarantee a jittery
> update. Consider what happens when you start at 0 and round down to
> figure out what to display. You'll display 0, then 0 again. Then
> you'll display 1, at 1.5 seconds after start, then 2 and 3 each 0.75
> seconds after the previous number. The cycle repeats with 4, which
> displays 1.5 seconds after 3.

Actually I meant to type 0.5s which is what I use in my code for this
type of thing and you don't want to use the timer to track time but
the actual system clock... assuming you use a simple repeating timer.

Firing once every 1 second can cause you skip numbers as timer jitter
walks near to a second boundary based on wall clock time assuming
you use a simple repeating timer and don't round as you suggest.

If you reschedule a timer every time the prior timer fires you can use
a 1 second timer delay if you attempt to ensure that your current time
isn't close to a second boundary of the wall clock.

..or rounding can be used (depends on how you are calculating the time, etc.)

-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 [EMAIL PROTECTED]


Re: while loop with sleep(): logging works, but not UI events

2008-06-28 Thread Michael Ash
On Sat, Jun 28, 2008 at 12:10 AM, Shawn Erickson <[EMAIL PROTECTED]> wrote:
> Also you should fire your timer every
> 0.75 of seconds (or so) to ensure your UI update is consistent/smooth.
> Firing every second may cause your timer to fire a little after 1
> second later so your UI could skip from say 50s to 52s.

I do not recommend this, as using 0.75s will guarantee a jittery
update. Consider what happens when you start at 0 and round down to
figure out what to display. You'll display 0, then 0 again. Then
you'll display 1, at 1.5 seconds after start, then 2 and 3 each 0.75
seconds after the previous number. The cycle repeats with 4, which
displays 1.5 seconds after 3.

Firing once a second is usually just fine, so if you want to keep
things simple, do that. To ensure against skipping, round to the
nearest integer, which will ensure that you can be off by up to .5
seconds without skipping any numbers.

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 [EMAIL PROTECTED]


Re: How to deal with a MenuItem with both a binded state property and an action method

2008-06-28 Thread Joan Lluch (casa)


El 28/06/2008, a las 9:59, Ken Thomases escribió:


On Jun 28, 2008, at 2:41 AM, Joan Lluch (casa) wrote:

The problem remains because when the user selects the menuItem the  
following happens:


FIRST- myAction is executed (possibly setting menuState to an  
appropiate  value)
SECOND - setMenuState is executed with a value contrary to the last  
one, so if I had set it to NO in myAction, it is called now with  
YES, destroying completely the intended behaviour. The menu item  
then shows the wrong state in the running app.


From where is this second call to setMenuState: coming?

Put a breakpoint on it and backtrace.  In Xcode's Breakpoints window  
(Run > Show > Breakpoints), toggle open the breakpoint's disclosure  
triangle.  Click the plus button to add a debugger command.  Enter  
"bt" as the command.  Enable the "Log" checkbox beneath the debugger  
command field.  Click the checkbox in the continue (▐▶) column,  
so that the program automatically continues after the breakpoint  
fires.  With this setup, the debugger console will get a backtrace  
every time your setMenuState: method is called, but it won't  
annoying break the flow of your application or require you to hit  
continue each time.


Cheers,
Ken


Thanks for the debugger tip, I didn't know it.

Both calls come ultimately from AppKitMenuEventHandler, although the  
first one comes through "myAction" (as it is intended when it fails to  
do its thing). Actually, the menuItem event handler calls "myAction"  
because it is its "action", and then calls "setMenuState" because  
menuState is binded to its value property. Looks all normal but  
unfortunatelly if myAction sends NO to setMenuState (first call), the  
following call to setMenuState (second call direct from the event  
hander) receives YES and vice-versa. So the second call from the event  
handler is always produced with the reverse state than the current  
menu item state (this is expected) but unfortunately it is still  
called after myAction has set the state, ruining the behaviour.


To sumarize, the problem is that I am not able to change the menuItem  
state programatically (ie. in myAction) without avoiding the second  
call to setMenuState. However if the call to myAction comes from a  
button set up in IB (instead the menuItem), then everything goes ok.  
In that case myAction is called by the click of the button and if the  
state of the menuItem is updated by myAction then it is correctly  
changed. No second call to setMenuState is received because the  
originating event came from the button. On the contrary if the event  
originates from the menuItem, first myAction is called, and then  
setMenuState is called.


Sure, all this can be solved by using a flag variable handling the  
different cases or by directly setting the menu item state without  
using bindings but I think that It should not be that tedious to do  
what I intend to.


Cheers,
Joan ___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSExpression

2008-06-28 Thread Shawn Erickson

On Jun 28, 2008, at 12:13 AM, Chris <[EMAIL PROTECTED]> wrote:



NSExpression defines this method:

+ (NSExpression *)expressionForFunction:(NSString *)name arguments: 
(NSArray *)parameters


and the doco provides this example:

[NSExpression expressionForFunction:(@selector(random))  
arguments:nil];



Isn't that wrong? Can you really pass a selector to a NSString  
argument? The compiler is complaining, and the program crashes when  
I attempt.


Yeah it is wrong. I believe you just pass a string with the same  
contents as what you would put in @selector.


-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 [EMAIL PROTECTED]


Re: switching content views

2008-06-28 Thread Shawn Erickson






On Jun 27, 2008, at 11:33 PM, dudley ackerman <[EMAIL PROTECTED]>  
wrote:


i can call setContentView on my app's window only if i don't plug in  
a 2nd monitor.
posts on this topic in the archives say you can't simple call  
setContentView on a window -

i'm not clear if that means even once.
even with a 2nd monitor, the call always works the 1st time for me  
-- perhaps accidentally.


i can see no frames or bounds


Can you better explain the problem you are having?

Having secondary monitors should have no affect at the view level. So  
something else is 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 [EMAIL PROTECTED]


Re: Style Question

2008-06-28 Thread Rob Ross

On Jun 28, 2008, at 6:39 AM, Sam Mo wrote:


On Jun 28, 2008, at 4:54 AM, Robert Claeson wrote:


On 28 Jun 2008, at 06:30, Alex Wait wrote:

I have noticed, coming from C++ and Visual Studio (at school), a  
couple

style differences

if (value) {
   //do something
}

insteasd of

if (value)
{
   //do something
}

Also since I am using this style, XCode doesn't tab in for me  
when I type {
then a return. This is the style I "taught" and I would like to  
continue the

good habits
during the summer.


I learned C on Unix long before Microsoft had started producing  
Windows 1.0. The first style was the first style I learned. I  
believe it's called the K&R style (from the inventors of C) and it  
also seems to be the preferred style in Java if you look in Sun's  
Java documentation. When I then learned C++ back in 1988 (from  
Bjarne Stroustrup, nonetheless), the K&R style was still the style  
being used.


The first time I came across the latter style was when I had to  
work on some Windows C and C++ style. I believe the style was more  
or less invented by Microsoft. Most of the Unix/Linux/Cocoa code  
I've worked on has used the K&R style.


I got the impression that the latter style was rooted from Pascal  
(or even Algo) programmers where they usually place the "begin" and  
"end" on separate lines.



If you look at an example BCPL program, you'll see the block style is  
similar to the second example above, except the closing curly brace  
is on the same line as the last line of the block - the mirror image  
of the first example


You can d/l the BCPL reference manual that contains an example  
program here:


 http://www.fh-jena.de/~kleine/history/languages/Richards-BCPL- 
ReferenceManual.pdf


(This manual is actually from a TYPEWRITER )

The example starts on page 29. BCPL is using $( and $) as the  
equivalent of { and }


BCPL is the ancestor of B which is the ancestor of C, so this style  
predates C.





___

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

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

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

This email sent to [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  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: Style Question

2008-06-28 Thread Sam Mo

On Jun 28, 2008, at 4:54 AM, Robert Claeson wrote:


On 28 Jun 2008, at 06:30, Alex Wait wrote:

I have noticed, coming from C++ and Visual Studio (at school), a  
couple

style differences

if (value) {
   //do something
}

insteasd of

if (value)
{
   //do something
}

Also since I am using this style, XCode doesn't tab in for me when  
I type {
then a return. This is the style I "taught" and I would like to  
continue the

good habits
during the summer.


I learned C on Unix long before Microsoft had started producing  
Windows 1.0. The first style was the first style I learned. I  
believe it's called the K&R style (from the inventors of C) and it  
also seems to be the preferred style in Java if you look in Sun's  
Java documentation. When I then learned C++ back in 1988 (from  
Bjarne Stroustrup, nonetheless), the K&R style was still the style  
being used.


The first time I came across the latter style was when I had to  
work on some Windows C and C++ style. I believe the style was more  
or less invented by Microsoft. Most of the Unix/Linux/Cocoa code  
I've worked on has used the K&R style.


I got the impression that the latter style was rooted from Pascal (or  
even Algo) programmers where they usually place the "begin" and "end"  
on separate 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]


trackmouse problems in Leopard

2008-06-28 Thread Moray Taylor
Hi, hope someone can help...

I have an app that uses a custom NSCell that implements the 

- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView 
*)controlView untilMouseUp:(BOOL)untilMouseUp 

method.

In Tiger, this works just fine, if I build targeting the 10.5 API, it does not 
work, the method does not get called at all, I can put an NSLog right at the 
start, and it never happens.

If I build targeting 10.4, it works great, even if the host machine is running 
Leopard, so it seems its an API difference.

If anyone can shed any light on this, I'd be eternally grateful!

Thanks a lot

Moray


  __
Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at 
Yahoo! http://uk.docs.yahoo.com/ymail/new.html
___

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

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

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

This email sent to [EMAIL PROTECTED]


Newbie Confused by ABMutableMultiValue and how to store emails and phone numbers using them.

2008-06-28 Thread Papa-Raboon
Hi again Cocoa geniuses,I am trying to get my head around the basics of the
AddressBook
framework. It seems there are not many examples of how to set/store email
addresses and phone numbers in the addressbook. I understand I need to
use ABMutableMultiValue to set my phone numbers and email addresses as
I do the actual fields of the addresses (home or work) but I can't
seem to figure out how it's done for either email addresses or phone
numbers.
I have this to set the home address:

homeAddr = [NSMutableDictionary dictionary];
[homeAddr setValue:myStreet forKey:kABAddressStreetKey];
[homeAddr setValue:myCity forKey:kABAddressCityKey];
[homeAddr setValue:myCounty forKey:kABAddressStateKey];
[homeAddr setValue:myPostcode forKey:kABAddressZIPKey];

multivalue = [[ABMutableMultiValue alloc] init];
[multivalue addValue:homeAddr withLabel:kABAddressHomeLabel];
[person setValue:multivalue forProperty:kABAddressProperty];
[multivalue release];

This all seems to work beautifully but I can't for the life of me
figure out how to do the same for the email addresses and telephone
numbers.

If anyone knows how to do this would it be possible to get the heads up from
someone please
as it's driving e nuts. As a complete newbie to Cocoa, MVC and OOP I
understand examples better
than verbose descriptions and that's where Apple's documentation seems a
little sparse :-)

Cheers

Paul Randall
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: [NSMutableAttributedString] How is NSBaseURLDocumentOption supposed to work?

2008-06-28 Thread Stéphane Sudre

On Jun 26, 2008, at 12:38 AM, Stéphane Sudre wrote:

When reading a html document into a NSMutableAttributedString (or  
NSTextStorage) using


- (BOOL)readFromURL:(NSURL *)url options:(NSDictionary *)options  
documentAttributes:(NSDictionary **)dict,


what value are you supposed to set for NSBaseURLDocumentOption?

When I test this with HTML files that use a separate file  
referenced by a relative path, it causes an exception in  
NSPathStore2 absoluteURL if I set the NSBaseURLDocumentOption of  
the parent folder of url (as NSURL).


This is done on Mac OS X 10.4.11.

Is CSS not supported?



OK, someone kindly pointed me off-list that I was using a NSString  
instead of a NSURL.


I'm still wondering which URL is supposed to be used:

- the document itself

or

- the parent folder of the document

?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Ken Thomases

On Jun 28, 2008, at 3:10 AM, Charles Srstka wrote:


On Jun 28, 2008, at 1:57 AM, Ken Thomases wrote:

That depends on how the bar class from your OP (or one of its  
superclasses) implemented bind:toObject:withKeyPath:options:.  That  
code may not have checked the passed-in binding name, and may have  
unconditionally added itself as an observer of ivar_controller for  
the key path "selection.displayName".  That would have guaranteed  
that bar would receive  
observeValueForKeyPath:ofObject:change:context: messages whenever  
foo's displayName property was changed in a KVO-conforming manner.   
(For example, if, in listing 2 of the how-it-works document, the  
check of the binding name against "angle" were omitted.)


Then, what happens next is up to bar's implementation of  
observeValueForKeyPath:ofObject:change:context:.  If it blindly did  
[self setTitle:[object valueForKeyPath:keyPath]], then that would  
explain it.  (For example, if, in listing 4, the test of context  
were omitted.)


The superclass would be NSView, which doesn't declare  
bind:toObject:withKeyPath:options: in its header file, nor does  
NSResponder, so it's likely NSObject's implementation, whatever it  
does. Interestingly, NSObject's header file doesn't declare this as  
a method either, although NSKeyValueBinding.h declares it as a  
category on NSObject, which is apparently why the compiler doesn't  
complain.


Yeah, it surprises me, too, that NSObject has an implementation of  
bind:toObject:withKeyPath:options:.  I had thought that it was just  
part of an informal protocol -- that is, that it was declared in a  
category on NSObject, but never implemented except by specific classes  
which adopted that protocol.  However, I did a symbol dump of the  
AppKit framework and I see that there is, in fact, an implementation.   
I have no idea what it could be doing.



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


Time to build a test project...

... time passes ...

OK.  So, from what I can see, bindings do work with just KVC/KVO, but  
they are inherently one-way.  That is, the following:


[thing1 bind:@"property1" toObject:thing2  
withKeyPath:@"property2" options:nil];


means that thing1's property1 should update itself with the value from  
thing2's property2 whenever thing2's property2 changes.  It does not  
imply that thing2's property2 will be updated if thing1's property1  
changes.  If you want that, then you should set it up explicitly:


[thing2 bind:@"property2" toObject:thing1  
withKeyPath:@"property1" options:nil];


From my brief testing, this does not produce infinitely looping  
mutual updates.


However, it seems as though a binding name is _not_ a key path as  
described in the documentation; it's just a key.  Trying to use a key  
path resulted in exceptions.


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 odd that there's no clear, definitive statement about what  
happens when you bind the properties of two non-view, non-NSController- 
derived classes together.  As I said above, there is a definite  
statement that you can do it, just not what happens if you do.  The  
fact that bind:toObject:withKeyPath:options: is only documented as  
part of an informal protocol and not on NSObject itself implies that  
there's no default implementation, and yet there is.


I'm quite perplexed.



Oh well, thanks for your patience with my questions.


Thank you for your persistence in asking.  It's helped me learn, or at  

DnD for NSBrowser in 10.4

2008-06-28 Thread Micha Fuhrmann

Dear all,

does anyone know some ready to use NSMatrix subclass code that  
incorporates DnD?


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 [EMAIL PROTECTED]


Re: Style Question

2008-06-28 Thread Robert Claeson


On 28 Jun 2008, at 06:30, Alex Wait wrote:

I have noticed, coming from C++ and Visual Studio (at school), a  
couple

style differences

if (value) {
   //do something
}

insteasd of

if (value)
{
   //do something
}

Also since I am using this style, XCode doesn't tab in for me when I  
type {
then a return. This is the style I "taught" and I would like to  
continue the

good habits
during the summer.


I learned C on Unix long before Microsoft had started producing  
Windows 1.0. The first style was the first style I learned. I believe  
it's called the K&R style (from the inventors of C) and it also seems  
to be the preferred style in Java if you look in Sun's Java  
documentation. When I then learned C++ back in 1988 (from Bjarne  
Stroustrup, nonetheless), the K&R style was still the style being used.


The first time I came across the latter style was when I had to work  
on some Windows C and C++ style. I believe the style was more or less  
invented by Microsoft. Most of the Unix/Linux/Cocoa code I've worked  
on has used the K&R style.


I personally prefer the K&R style as it is more compact. I can get a  
better sense of the code on a screenful, while a larger portion of the  
screen estate is consumed by syntactics (curly braces) that really  
doesn't add much of a value in the latter style.


But it's mostly a matter of personal preference. Cocoa doesn't care  
and neither does Xcode. You should be able to set up Xcode to indent  
properly for you even when using the latter style. If it can't, file a  
bug report on bugreporter.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 [EMAIL PROTECTED]


Re: Core data question in multiwindow doc app

2008-06-28 Thread Steven Hamilton



On 28/06/2008, at 2:41 PM, Chris Hanson wrote:


On Jun 27, 2008, at 7:25 PM, Steven Hamilton wrote:

	[[NSNotificationCenter defaultCenter] addObserver:self  
selector:@selector(buildSourceList)  
name:@"NSManagedObjectContextObjectsDidChangeNotification" object: 
[self.document managedObjectContext]];


Notification names should always use the global variables declared  
for them, not a constant string.


There is never any guarantee that the value of a notification name  
is identical to its name.


Whether this is your issue, I don't know.  How did you create your  
document's window controllers and ensure that it knows about them?


Thanks. That seems to have fixed it. This also gives me a big clue to  
a similar bug I've to chase next.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Charles Srstka

On Jun 28, 2008, at 1:57 AM, Ken Thomases wrote:

That depends on how the bar class from your OP (or one of its  
superclasses) implemented bind:toObject:withKeyPath:options:.  That  
code may not have checked the passed-in binding name, and may have  
unconditionally added itself as an observer of ivar_controller for  
the key path "selection.displayName".  That would have guaranteed  
that bar would receive  
observeValueForKeyPath:ofObject:change:context: messages whenever  
foo's displayName property was changed in a KVO-conforming manner.   
(For example, if, in listing 2 of the how-it-works document, the  
check of the binding name against "angle" were omitted.)


Then, what happens next is up to bar's implementation of  
observeValueForKeyPath:ofObject:change:context:.  If it blindly did  
[self setTitle:[object valueForKeyPath:keyPath]], then that would  
explain it.  (For example, if, in listing 4, the test of context  
were omitted.)


The superclass would be NSView, which doesn't declare  
bind:toObject:withKeyPath:options: in its header file, nor does  
NSResponder, so it's likely NSObject's implementation, whatever it  
does. Interestingly, NSObject's header file doesn't declare this as a  
method either, although NSKeyValueBinding.h declares it as a category  
on NSObject, which is apparently why the compiler doesn't complain.


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.


Oh well, thanks for your patience with my questions.

Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to deal with a MenuItem with both a binded state property and an action method

2008-06-28 Thread Ken Thomases

On Jun 28, 2008, at 2:41 AM, Joan Lluch (casa) wrote:

The problem remains because when the user selects the menuItem the  
following happens:


FIRST- myAction is executed (possibly setting menuState to an  
appropiate  value)
SECOND - setMenuState is executed with a value contrary to the last  
one, so if I had set it to NO in myAction, it is called now with  
YES, destroying completely the intended behaviour. The menu item  
then shows the wrong state in the running app.


From where is this second call to setMenuState: coming?

Put a breakpoint on it and backtrace.  In Xcode's Breakpoints window  
(Run > Show > Breakpoints), toggle open the breakpoint's disclosure  
triangle.  Click the plus button to add a debugger command.  Enter  
"bt" as the command.  Enable the "Log" checkbox beneath the debugger  
command field.  Click the checkbox in the continue (▐▶) column, so  
that the program automatically continues after the breakpoint fires.   
With this setup, the debugger console will get a backtrace every time  
your setMenuState: method is called, but it won't annoying break the  
flow of your application or require you to hit continue each time.


Cheers,
Ken___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Checking availability of host/website

2008-06-28 Thread Omar Qazi


On Jun 28, 2008, at 12:36 AM, Michael Kaye wrote:


I have implemented an SCNetworkReachAbility based method to test  
firstly whether a network is available, but I was wondering in your  
opinion what is the best way to check that the remote host/website  
is responding to requests?



It depends on what your definition of availability is. If you want to  
ping the server you can wrap a ping command through NSTask. If you  
want to check if it responds to connections, NSURLConnection is for  
you. If you want to check if the system is connected to the internet  
you would use the api for that.


You probably just want to open an NSURLConnection and see if it  
doesn't accept the connection within a second or whatever.


Omar Qazi
Hello, Galaxy!
1.310.294.1593



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 [EMAIL PROTECTED]

  1   2   >