Re: Authenticate Password.

2008-07-29 Thread Macarov Anatoli
My program requests user's password for further work. Tha's why I'd like to 
check password, if the user has entered it correctly. And for this I use 
Authorization Service.

On Mon, Jul 28, 2008 at 7:24 AM, Macarov Anatoli
<[EMAIL PROTECTED]> wrote:

> With the help of this procedure I check whether the password has been
entered correctly. But the code works only for the user with admins rights. How
do I check the password being a standard user?

You should "never" ask the user for their user password. Why are you
doing this?

-Shawn


  
Вы уже с Yahoo!? 
Испытайте обновленную и улучшенную. Yahoo! Почту! http://ru.mail.yahoo.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: Storing values in dictionary with their address as the key

2008-07-29 Thread Stuart Rogers


If I wanted to store an object in a dictionary and set its key as  
the

object's memory address - how would I go about doing this?


I'm racking my brains trying to think of a good reason to do this  
and am

drawing a blank. I can, however, think of myriad bad reasons.


 Agreed - I can't help but wonder about class clusters but I can't
think of a direct reason why this would be a 'problem area'. It's just
the first thing that popped into my head. :-)


Maybe I'm misunderstanding, but this strikes me as a clunky way
of implementing a set.

Stuart

___

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

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

2008-07-29 Thread Phil
On Tue, Jul 29, 2008 at 7:31 PM, Macarov Anatoli
<[EMAIL PROTECTED]> wrote:
> My program requests user's password for further work. Tha's why I'd like to 
> check password, if the user has entered it correctly. And for this I use 
> Authorization Service.
>

What further work? If you're wanting to peform priveleged operations,
you should let Authorization Services handle prompting the user for
their password and validating it.

Phil
___

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

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


[ANNOUNCE] CocoaHeads Frankfurt

2008-07-29 Thread Torsten Curdt
Just a reminder. Next Monday we will have the second CocoaHeads in  
Frankfurt.


 CocoaHeads Frankfurt,
 Monday, 04.08.2008 20:00 at Club Voltaire

We are starting a little later at 8pm as requested. Please register if  
you plan to attend. More details at


 http://upcoming.yahoo.com/event/871648/
 http://vafer.org/blog/20080729104806

To stay up-to-date with future meetings please join the group on  
upcoming


 http://upcoming.yahoo.com/group/4810/

and subscribe to the group feeds via iCal or RSS.

 iCal webcal://upcoming.yahoo.com/calendar/v2/group/4810/9266a3a167
 RSS http://upcoming.yahoo.com/syndicate/v2/group/4810/9266a3a167

Hope to see you there!

cheers
--
Torsten
http://vafer.org/blog
___

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

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

2008-07-29 Thread Steven Noyes
You might consider changing how you store data just a little bit.   
Instead of having two arrays, a single array with arrays as objects.   
For example, you currently have:


Array 1  Array 2
-  ---
|   | | |
-  ---
-  ---
|   | | |
-  ---
-  ---
|   | | |
-  ---
-  ---
|   | | |
-  ---

And you want the order of the two to remain the same.  I would propose  
what you really want is:


Container array

||
|-  ---   |
||   | -| |   | objectAtIndex:0 is  
an array of two items and so on.

|-  ---   |
|-  ---   |
||   | -| |   |
|-  ---   |
|-  ---   |
||   | -| |   |
|-  ---   |
|-  ---   |
||   | -| |   |
|-  ---   |


And then you sort  (using sortUsingSelector:) the Container Array.   
Your selector would be within a category of NSMutalbeArray and compare  
what you want to compare for the sort.


To get to objects in Array, you would use [[containerArray  
objectAtindex:index] objectAtIndex:0] VS [Array 1 objectAtIndex:index].


You could also model the items as a new class (perhaps a bit cleaner  
and easier to maintain) but this might not be what you want.


Steven

On Jul 28, 2008, at 10:08 AM, Jeff LaMarche wrote:


Hey all...

I've got two arrays that are related, so that object 0 in one array  
corresponds to object 0 in the other array. I'd like to implement a  
sort based on the values in one array, but to  reorder both array so  
that the order of the two arrays stays in sync and that object x in  
one array continues to correspond to the same thing as object x in  
the other array after the sort.


I've got a general idea of how to implement the sort, but since I  
know that there are a few places in the system where array pairs are  
used like this, I wanted to see if there was any out-of-the-box way  
of handling this scenario - I'd hate to reinvent the wheel if it's  
not necessary. Does anyone know if there is any easy way to do this?


TIA,
Jeff

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Storing values in dictionary with their address as the key

2008-07-29 Thread Manfred Schwind
If I wanted to store an object in a dictionary and set its key as  
the object's memory address - how would I go about doing this?



NSObject *myObject = [[NSObject alloc] init];
[dictionary setValue:myObject forKey:[NSString  
stringWithFormat:@"%x", &myObject]];



Just remove the "&" before myObject in your code. You stored the  
address of the myObject variable (that's on the stack) as key into the  
dictionary instead of the address of the objects it points to.


But: This does not make any sense to me. A dictionary is used to store  
objects with a key and retrieve them later with that key. But if the  
key is the address of the object, you don't need a dictionary at all,  
because if you already know the address (your "key") you can just use  
that address to "retrieve" the object. So there is no reason to look  
that up in a dictionary. E.g. if you look up the object for key  
"123456" you get back a pointer to 123456. That's information you  
already have in your hands and you don't need the dictionary at all.


I would really like to know a meaningful situation for such a  
scenario. Maybe I just can not think of one. Or maybe you just  
simplified your problem. I don't know.


Regards,
Manfred Schwind
--
http://mani.de - friendly software
iVolume - listen to music freehand
LittleSecrets - the encrypted notepad

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: [Newbie] Communication between two Views?

2008-07-29 Thread I. Savant
> I'm trying to avoid "who said what" discussions on this list these days ;)

  Though I see your emoticon, I don't really understand this statement
- if there's confusion about a post, quoting is the easiest way to
clear it up, which is why it's a regular practice in e-mail / mailing
lists.

> I merely thought you were recommending the use of a single
> controller for a master-detail view, in which case the point about one
> controller needing to access the selection of another would be moot.

  No, not necessarily - I don't have enough information about the OP's
project. I was merely mentioning that your assertion that views should
communicate with controllers via the model layer (which is what your
original message seemed to imply) is incorrect as stated because it
implies this is *always* (or even "usually") the case.

  Further, I was suggesting that your blanket statement that
controllers shouldn't communicate with one-another (generally or not)
is incorrect (or at least inaccurate) because such an approach is a
matter of design, whether because of your 'tastes' or functional
requirements.

> Your design decisions may vary.

  Indeed. A lack of concrete specifications in the OP's project or our
examples so far makes design debates pointless in this discussion. I
just want to make sure that if we make assertions, we do so without
ambiguity. Anything less may make someone else's life a whole lot
harder than it needs to be.

  No harm was intended on my part.

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Storing values in dictionary with their address as the key

2008-07-29 Thread Nathan Vander Wilt
What about using CFDictionary ? You can create a dicitonary with a  
callback that support address (NULL for example).


I'll echo this; it's a really handy technique that I use frequently  
(you can even use integers as keys!).


WARNING: Just in case, there is a major warning here. You should  
avoid NS/CF bridge when inserting/removing value in a dictionary as  
the semantic is not the same. NSDictionary always try to copy the  
key whatever the calback is (or at least did it the last time I try).


Right, -[NSDictionary setObject:forKey:] on a CFDictionary created  
with a custom retain callback will invoke copyWithZone: before  
calling your retain callback.  Apple claims this is not a bug.   
Getting/removing values with objectForKey:/removeObjectForKey:  
should work, though; if it doesn't, I'd like to know.



Yes, accessing and removing keys should work fine. For immutable keys  
(you weren't planning on changing a key behind NSDictionary's back  
anyway, right) a copy is often just implemented as a retain. Since  
toll-free bridged NSDictionary must provide CFDictionary retain/ 
release callbacks to work right on the Core Foundation side of things,  
it must be copying the key, adding it to the array (where it is  
retained by the callback), and then releasing it's local reference.  
Take out steps one and three, which are equivalent to a retain  
followed by a release, and nothing should change as far as object  
accessing or removal.


While for new code in Leopard+ apps you might want to look into  
NSMapTable with the flags Mike suggested, I just was dealing with  
NSMutableDictionary's key copying off-list last night and didn't see  
that suggestion. What I did is just added a category on  
NSMutableDictionary:


@interface NSMutableDictionary (TLMutableDictionaryNoncopiedKeys)
- (void)setObject:(id)anObject forUncopiedKey:(id)aKey;
@end

@implementation NSMutableDictionary (TLMutableDictionaryNoncopiedKeys)

/* NSMutableDictionary copies its keys. When we use pointer-equality  
for certain types' comparision,
 this breaks those types' keys. Fortunately, CFMutableDictionary does  
not assume NSString-ish keys,
 and the copying behaviour is implemented within the - 
[NSMutableDictionary addObject:forKey:]
 method itself (see http://www.cocoabuilder.com/archive/message/cocoa/2008/4/2/203028 
 and links

 for details).
 If we just bridge to Core Foundation when adding keys, everything  
else should work properly.

 */

- (void)setObject:(id)anObject forUncopiedKey:(id)aKey {
CFMutableDictionaryRef selfCF = (CFMutableDictionaryRef)self;
Boolean keyAlreadySet = CFDictionaryContainsKey(selfCF, aKey);
if (keyAlreadySet) {
CFDictionaryReplaceValue(selfCF, aKey, anObject);
}
else {
CFDictionaryAddValue(selfCF, aKey, anObject);
}
}

@end


Replacing this single method was enough for me, since in most cases in  
my code where the "stringish" (that is, assuming copied keys will  
still compare equal) behaviour is not desirable, I am creating an  
empty dictionary and populating it with just that one method.  
Otherwise, many other methods (especially NSDictionary's initializers  
and convenience initializers) would all need "uncopiedKey" overrides,  
and some of these could theoretically end up being much less efficient  
than the methods they replaced. However, if you can't use just the  
above method to insert keys, then other solutions like CFDictionary  
and NSMapTable (especially) might not work much better for you  
anyway...so this seems like a pretty decent solution for many cases.


hope this helps,
-natevw
___

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

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


NSArrayController selection for remove: ... how does it know?

2008-07-29 Thread Roland King
I started over a couple of weeks ago with the new Hillegass book,  
trying to make sure I understood things properly this time and of  
course I'm now stuck.


I'm at the 'RaiseMan' chapter now. This is where Hillegass introduces  
a NSArrayController and its use with an NSTableView. Here are the  
major pieces.


MyDocument exposes an 'employees' property, a NSMutableArray, that's  
an array of 'Person' objects, each with a personName and expectedRaise  
property.


You drop in an NSArrayController and bind its Content Array to the  
File's Owner.employees. Ok that makes sense, you've bound the content  
array of the NSArrayController to the NSMutableArray in your document,  
the model, where all the Person's are held. That's the model connection.


Then you drop an NSTableView onto the document window, plus Add and  
Delete buttons. You bind the Value of each of the columns of the  
NSTableView to the arrangedObjects.personName and  
arrangedObjects.expectedRaise of the NSArrayController .. this sort of  
makes sense, that's the data for each column.


The Add button triggers the add: action of the NSArrayController and  
the Delete button triggers the remove: action of the NSArrayController.


'Add' I basically understand. The ArrayController receives an add:, it  
makes a new Person, adds it to the end of the MutableArray and by the  
magic of bindings the NSTableColumns find out and the NSTableView gets  
redrawn.


'Delete' however I don't understand. Hitting the button triggers the  
remove: action in the NSArrayController which deletes the selected  
entry from the NSMutableArray but ... how does it know which one to  
delete? I haven't told the NSArrayController what NSTableView it's  
attached to, or if it's attached to one at all. I bound the  
NSTableColumns to arrangedObjects. on the NSArrayController, but  
that's the wrong way around, and those are the columns anyway, not the  
NSTableView itself.


In the previous chapter in the book the exercise was basically to  
write something similar by hand, the NSTableView was an outlet of the  
controller and when remove: was triggered, you looked up the current  
selection using the outlet and knew what to delete, made total sense.  
But with the NSArrayController, there's no outlet, there's no visible  
binding between the controller and the view, so how does it know what  
the current selection is?


[ Supplementary question - when used in 'hand written' code you supply  
a dataSource for the NSTableView. When used with bindings, that's nil.  
I wondered how that worked too. If there is a nil dataSource does the  
underlying implementation of the NSTableView assume its NSTableColumns  
are bound and basically becomes its own dataSource? ]





___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSArrayController selection for remove: ... how does it know?

2008-07-29 Thread Felix Franz


On 29.07.2008, at 18:01, Roland King wrote:

I started over a couple of weeks ago with the new Hillegass book,  
trying to make sure I understood things properly this time and of  
course I'm now stuck.


I'm at the 'RaiseMan' chapter now. This is where Hillegass  
introduces a NSArrayController and its use with an NSTableView. Here  
are the major pieces.


MyDocument exposes an 'employees' property, a NSMutableArray, that's  
an array of 'Person' objects, each with a personName and  
expectedRaise property.


You drop in an NSArrayController and bind its Content Array to the  
File's Owner.employees. Ok that makes sense, you've bound the  
content array of the NSArrayController to the NSMutableArray in your  
document, the model, where all the Person's are held. That's the  
model connection.


Then you drop an NSTableView onto the document window, plus Add and  
Delete buttons. You bind the Value of each of the columns of the  
NSTableView to the arrangedObjects.personName and  
arrangedObjects.expectedRaise of the NSArrayController .. this sort  
of makes sense, that's the data for each column.


The Add button triggers the add: action of the NSArrayController and  
the Delete button triggers the remove: action of the  
NSArrayController.


'Add' I basically understand. The ArrayController receives an add:,  
it makes a new Person, adds it to the end of the MutableArray and by  
the magic of bindings the NSTableColumns find out and the  
NSTableView gets redrawn.


'Delete' however I don't understand. Hitting the button triggers the  
remove: action in the NSArrayController which deletes the selected  
entry from the NSMutableArray but ... how does it know which one to  
delete? I haven't told the NSArrayController what NSTableView it's  
attached to, or if it's attached to one at all. I bound the  
NSTableColumns to arrangedObjects. on the NSArrayController,  
but that's the wrong way around, and those are the columns anyway,  
not the NSTableView itself.


In the previous chapter in the book the exercise was basically to  
write something similar by hand, the NSTableView was an outlet of  
the controller and when remove: was triggered, you looked up the  
current selection using the outlet and knew what to delete, made  
total sense. But with the NSArrayController, there's no outlet,  
there's no visible binding between the controller and the view, so  
how does it know what the current selection is?


If you bind a NSTableColumn to an NSArrayController the NSTableView's  
selectionIndexes-binding
is bound automatically to the NSArrayController. (As mentioned in the  
Binding Reference: )


Now the NSArrayController selection is in sync with the NSTableView  
and remove: makes sense ...






[ Supplementary question - when used in 'hand written' code you  
supply a dataSource for the NSTableView. When used with bindings,  
that's nil. I wondered how that worked too. If there is a nil  
dataSource does the underlying implementation of the NSTableView  
assume its NSTableColumns are bound and basically becomes its own  
dataSource? ]


You are free to use both (bindings and datasource). Drag'n'Drop for  
example …



Cheers,

felix

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSArrayController selection for remove: ... how does it know?

2008-07-29 Thread I. Savant
> 'Delete' however I don't understand. Hitting the button triggers the remove:
> action in the NSArrayController which deletes the selected entry from the
> NSMutableArray but ... how does it know which one to delete? I haven't told
> the NSArrayController what NSTableView it's attached to, or if it's attached
> to one at all.

  The easy explanation first: You told the table columns what to
observe (the array controller's arranged objects array). In the
background, this automatically binds the table's selection to the
array controller's own selection. When the table's selection changes,
so does the array controller's (and vice-versa).

  To test this, create a second table and bind it the same way as the
first. Now select different rows in each table and observe how the new
selection in one table is mirrored by the other. This is because the
'common factor' is that they're both bound to the array controller's
selection.

> [ Supplementary question - when used in 'hand written' code you supply a
> dataSource for the NSTableView. When used with bindings, that's nil. I
> wondered how that worked too. If there is a nil dataSource does the
> underlying implementation of the NSTableView assume its NSTableColumns are
> bound and basically becomes its own dataSource? ]

  No, not really. The NSTableView knows enough to realize when to use
bindings or a data source (if either are present). For the record, you
can use a mix of bindings and the NSTableDataSource protocol.

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


help about the flat-namespace?

2008-07-29 Thread Leopard x86

Hi everyone.
I am going to use a foreign library named graphviz by AT&T research.  
There is example application written in Cocoa.
I am very lucky to build the library from the source and installed the  
needed libraries and header files.
But when I launched the application, the console dumped out the  
following information:

dyld: Symbol not found: __nl_msg_cat_cntr
  Referenced from: /usr/local/lib/graphviz/libgvplugin_pango.5.dylib
  Expected in: flat namespace

Can anyone tell me how to solve the flat namespace problem? Or if  
anyone in the list is also interested in developing graphviz-related  
applications, are you willing to discuss the problem with me?


Any help or guidance is GREATLY appreciated. Thank you very much in  
advance.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArrayController selection for remove: ... how does it know?

2008-07-29 Thread Roland King


On Jul 30, 2008, at 12:28 AM, I. Savant wrote:

'Delete' however I don't understand. Hitting the button triggers  
the remove:
action in the NSArrayController which deletes the selected entry  
from the
NSMutableArray but ... how does it know which one to delete? I  
haven't told
the NSArrayController what NSTableView it's attached to, or if it's  
attached

to one at all.


 The easy explanation first: You told the table columns what to
observe (the array controller's arranged objects array). In the
background, this automatically binds the table's selection to the
array controller's own selection. When the table's selection changes,
so does the array controller's (and vice-versa).

 To test this, create a second table and bind it the same way as the
first. Now select different rows in each table and observe how the new
selection in one table is mirrored by the other. This is because the
'common factor' is that they're both bound to the array controller's
selection.

[ Supplementary question - when used in 'hand written' code you  
supply a
dataSource for the NSTableView. When used with bindings, that's  
nil. I

wondered how that worked too. If there is a nil dataSource does the
underlying implementation of the NSTableView assume its  
NSTableColumns are

bound and basically becomes its own dataSource? ]


 No, not really. The NSTableView knows enough to realize when to use
bindings or a data source (if either are present). For the record, you
can use a mix of bindings and the NSTableDataSource protocol.

--
I.S.


thanks I.S. and Felix. Felix pointed out the one line in the  
documentation I probably wouldn't have recognised as vital. I did that  
second table trick whilst trying to figure it out, but didn't  
understand the relevance.


My misunderstanding here was thinking that the NSArrayController/ 
NSTableView were very generic total standalone objects and all their  
hookups would be done very explicitly. Now I see there's some  
expectations about NSArrayController/NSTableView being paired with  
each other and a number of bindings are set up behind the scenes to  
make things behave by default as you'd expect.


perhaps what I should have done is subclass the NSArrayController and  
NSLog the bind: and addObserver: messages, that might have given me a  
hint as to where to look.




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: [Newbie] Communication between two Views?

2008-07-29 Thread Adam R. Maxwell
 
On Tuesday, July 29, 2008, at 08:35AM, "I. Savant" <[EMAIL PROTECTED]> wrote:
>> I'm trying to avoid "who said what" discussions on this list these days ;)
>
>  Though I see your emoticon, I don't really understand this statement
>- if there's confusion about a post, quoting is the easiest way to
>clear it up, which is why it's a regular practice in e-mail / mailing
>lists.

The message you quoted doesn't appear to have shown up on the list, either due 
to moderation or because it was offlist.  From the context of a previous 
message, I infer that you are responding to Hamish, but since you (or your 
mailer) did not attribute the quote to anyone, we don't know for sure. 

-- 
Adam
___

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

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


Odd error when opening a nib file

2008-07-29 Thread JArod Wen

Hi jedis,

I met an odd error when opening a nib file, using the following code:

-(void)loadGraphicsController{
if (graphicsController == NULL) {
graphicsController = [[GraphicsController alloc] init];
		if (![NSBundle loadNibNamed:@"GraphWindow"  
owner:graphicsController]) {

 NSLog(@"Error loading GraphController");}
else{
NSLog(@"GraphController NIB Loaded"); 
}
}   
}

When it goes to [NSBundle loadNibNamed:owner:], there is an error  
showed in debug window:


Cannot create int from object  of class  
NSApplication


and the step-by-step debug after this line will jump to a method  
called [NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:].


Since there are several NSPopupButton in the nib file, and also  
NSCarbonMenuImpl is used when initializing the pop-up menu(reference: http://www.cocoadev.com/index.pl?NSCarbonMenuImpl) 
, is there anyway I can fix this error?


Thanks in advance!

---
JArod Wen




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Odd error when opening a nib file

2008-07-29 Thread Kyle Sluder
On Tue, Jul 29, 2008 at 1:12 PM, JArod Wen <[EMAIL PROTECTED]> wrote:
> Cannot create int from object  of class
> NSApplication

Did you mistakenly create an NSApplication in the nib?

--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: Odd error when opening a nib file

2008-07-29 Thread JArod Wen
The error has mysteriously gone after I deleted all the popup buttons  
and re-added them onto the interface again... The wildest reason I  
have on this odd error may be some improper configuration on the popup  
button.


Thanks anyway to Kyle, since at first I thought the problem should be  
something related to NSApplication.


On Jul 29, 2008, at 1:24 PM, Kyle Sluder wrote:


On Tue, Jul 29, 2008 at 1:12 PM, JArod Wen <[EMAIL PROTECTED]> wrote:

Cannot create int from object  of class
NSApplication


Did you mistakenly create an NSApplication in the nib?

--Kyle Sluder


---
JArod Wen




___

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

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

2008-07-29 Thread Bill Bumgarner

On Jul 29, 2008, at 10:57 AM, Nathaniel Gottlieb-Graham wrote:
Why do externs seem to have to be NSStrings?  Also, is this even the  
right way to go about having a read/write global  
NSMutableDictionary?  If not, how would I do this?


The variables cannot point to anything that isn't a constant.   @"foo  
bar" is a constant string and is handled differently by the compiler/ 
linker.   [[NSMutableDictionary dictionary] retain] is not a constant  
and, thus, cannot be used to directly initialize a variable at time of  
declaration within a global scope.


Instead, you need to initialize the variables as early as needed  
within your application.


This could be done in main().   Or it could be done in the +initialize  
for a class.


Or you could annotate a function as a constructor.  It will run before  
main().


static void __InitializeGlobalStuffMan(void) __attribute__  
((constructor));

void __InitializeGlobalStuffMan(void) {
myGlobalDictionary = [[NSMutableDictionary alloc] init];

}

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: Repositioning a content view w/in a window

2008-07-29 Thread Jonathan Hess


On Jul 28, 2008, at 3:29 PM, R.L. Grigg wrote:



On Jul 26, 2008, at 3:15 AM, Michael Ash wrote:


On Fri, Jul 25, 2008 at 11:08 PM, Henry McGilton (Starbase)
<[EMAIL PROTECTED]> wrote:

On Jul 25, 2008, at 6:50 PM, Michael Ash wrote:


In fact I would go so far as to say that if you ever use
-setContentView:, you are very probably doing it wrong. It is,  
for the

most part, not a very useful call, and you can accomplish the same
thing more naturally, easily, and flexibly by adding the view as a
subview to the content view instead.


Well, I would not go quite that far, although I agree with you
in principle for normal everyday stuff.I have some applications
which create bare windows --- no borders, controls, resizers,
shadows, and so on.The view that replaces the default window
content view does all the drawing.I don't see any value in
having a content view whose only purpose in life is to act as
a container for my drawing view.


Might come a day that you want two views in there, or you want to  
move

that one view around, and suddenly the value appears. Since it's no
harder to do things the "right" way, why not?


Okay, I'm a little bit confused. What is the "right" way?

I create a NSWindow and then I'm displaying a NSMatrix in that  
window. Now I need to move the NSMatrix around in the NSWindow.


Is something like this a decent Cocoa approach:

   // create the window
   myWindow = [[NSWindow alloc] initWithContentRect: ... ];
   // insert the existing matrix as it's content view
   [myWindow setContentView:myMatrix];
   // alter the position of the matrix
   NSPoint newPoint = ...
   [myMatrix setFrameOrigin:newPoint];
   [myWindow display];

Thx!
Russ


Hey Russ -

The location and size of the content view of the window is  
conceptually owned by the NSWindow instance. If you alter the origin,  
you're breaking the encapsulation provided by NSWindow and the  
NSWindow is likely to either break, or reset it, or both. You should  
leave the content view of the window in its default state as a vanilla  
NSView, and instead add your matrix to the window's content view. You  
can do that with something like this:


   myWindow = [[NSWindow alloc] initWithContentRect: ... ];
   // insert the existing matrix as it's content view
   [[myWindow contentView] addSubview:myMatrix];
   // alter the position of the matrix
   NSPoint newPoint = ...
   [myMatrix setFrameOrigin:newPoint];

I also removed the call to [myWindow display]. You should only ever  
call 'display' or 'displayIfNeeded' if you have a good reason to short  
circuit the normal view/window redrawing mechanism. Short circuiting  
the behavior can lead to poor performance if the window ends up  
accidently being drawn many times per event loop.


Good Luck -
Jon Hess







___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jhess%40apple.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: global NSMutableDictionary

2008-07-29 Thread Devon Ferns
I think you probably want to use the singleton design pattern rather 
than that global variable.


Devon.

Nathaniel Gottlieb-Graham wrote:
I am trying to implement a global variable that's an 
NSMutableDictionary.  Up until now I've achieved this by making 
globalVariables.h and .m files to hold globals that are imported by all 
my classes.  globalVariables defines externs, and I already have two 
extern NSStrings set up and working.  But as soon as I try to create an 
extern variable here that's *not* and NSString, the compiler errors with 
"Initializer element is not constant".  What does this mean?


Why do externs seem to have to be NSStrings?  Also, is this even the 
right way to go about having a read/write global NSMutableDictionary?  
If not, how would I do this?


Thanks!
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/dferns%40devonferns.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]


global NSMutableDictionary

2008-07-29 Thread Nathaniel Gottlieb-Graham
I am trying to implement a global variable that's an  
NSMutableDictionary.  Up until now I've achieved this by making  
globalVariables.h and .m files to hold globals that are imported by  
all my classes.  globalVariables defines externs, and I already have  
two extern NSStrings set up and working.  But as soon as I try to  
create an extern variable here that's *not* and NSString, the compiler  
errors with "Initializer element is not constant".  What does this mean?


Why do externs seem to have to be NSStrings?  Also, is this even the  
right way to go about having a read/write global NSMutableDictionary?   
If not, how would I do this?


Thanks!
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: global NSMutableDictionary

2008-07-29 Thread I. Savant
On Tue, Jul 29, 2008 at 1:57 PM, Nathaniel Gottlieb-Graham
<[EMAIL PROTECTED]> wrote:
> I am trying to implement a global variable that's an NSMutableDictionary.

  In addition to Bill's response, I'd like to take a different
direction. :-) Why are you trying to implement this as a global?
Typically (in the world of Cocoa), you'd have some central controller
that acts as your "app delegate". This controller would keep
references to things you might want to access from any part of your
app.

  Consider having a controller class designated as your app's
delegate. Assume your dictionary is an instance variable of that
controller called "fooDict". Your app delegate controller would
contain a convenience method to return (or create and return) that
dictionary:

- (NSMutableDictionary *)fooDict
{
  // Possibly create (and ensure retention of) fooDict here
  return fooDict;
}

  ... then, from anywhere in your app, you can ask the controller for
its fooDict like this:

id fooDict = [[NSApp delegate] fooDict];

  I hope this helps (or is at all relevant to your goal).

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: global NSMutableDictionary

2008-07-29 Thread Nathaniel Gottlieb-Graham
Holy moly, that's just what I needed.  This dictionary in fact  
originated in the controller app delegate, and I had no idea you could  
reference things inside the app delegate like that!  Thanks so much!



On Jul 29, 2008, at 2:16 PM, I. Savant wrote:


On Tue, Jul 29, 2008 at 1:57 PM, Nathaniel Gottlieb-Graham
<[EMAIL PROTECTED]> wrote:
I am trying to implement a global variable that's an  
NSMutableDictionary.


 In addition to Bill's response, I'd like to take a different
direction. :-) Why are you trying to implement this as a global?
Typically (in the world of Cocoa), you'd have some central controller
that acts as your "app delegate". This controller would keep
references to things you might want to access from any part of your
app.

 Consider having a controller class designated as your app's
delegate. Assume your dictionary is an instance variable of that
controller called "fooDict". Your app delegate controller would
contain a convenience method to return (or create and return) that
dictionary:

- (NSMutableDictionary *)fooDict
{
 // Possibly create (and ensure retention of) fooDict here
 return fooDict;
}

 ... then, from anywhere in your app, you can ask the controller for
its fooDict like this:

id fooDict = [[NSApp delegate] fooDict];

 I hope this helps (or is at all relevant to your goal).

--
I.S.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Where'd my debugging statements go?

2008-07-29 Thread Nathaniel Gottlieb-Graham
All of the sudden, Xcode (3.1) no longer logs any NSLog or printf  
statements to the console.  I have no idea what caused this, since it  
just randomly started happening after a compile, and even log  
statements which are *obviously* reachable don't output anything at  
all!  Help?


Thanks,
Nathaniel
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: [Newbie] Communication between two Views?

2008-07-29 Thread julius


On 29 Jul 2008, at 03:35,  julius <[EMAIL PROTECTED]> wrote

Subject: Re: [Newbie] Communication between two Views?
To: "Thomas Wickl" <[EMAIL PROTECTED]>
Cc: cocoa-dev@lists.apple.com
On 28 Jul 2008, at 16:39,  "Thomas Wickl" <[EMAIL PROTECTED]> wrote

Subject: [Newbie] Communication between two Views?

Can someone please give me an example?

No idea whether this is of use but an example of two logically
unconnected controllers talking to each other via notifications can be
found here. (this part of the site is still under construction so
kindly excuse glitches)

http://juliuspaintings.co.uk/cgi-bin/paint_css/animatedPaint/017-Comunicate-Two-Views.pl


I have another two examples that use IBOutlet as the key to getting  
the object's id:

http://juliuspaintings.co.uk/cgi-bin/paint_css/animatedPaint/018-NSButton-NSView.pl

and this one which provides two way coms by the additional expedient  
of a dummy class.

http://juliuspaintings.co.uk/cgi-bin/paint_css/animatedPaint/019-NSControl-NSView.pl

Again kindly excuse the glitches.
Julius


http://juliuspaintings.co.uk



___

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

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


getting the clicked-in view

2008-07-29 Thread James Maxwell
This is really silly, but how can I get a reference to the clicked-in  
view???


I don't have direct access to the event, but I can get it through  
NSApp. The problem is, there doesn't seem to be any method to just get  
a reference to the clicked view. This seems very strange to me, so I  
really hope I'm missing something very simple.


J.
___

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

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

2008-07-29 Thread Andy Lee

Does NSView's -hitTest: method help?

--Andy

On Jul 29, 2008, at 3:56 PM, James Maxwell wrote:

This is really silly, but how can I get a reference to the clicked- 
in view???


I don't have direct access to the event, but I can get it through  
NSApp. The problem is, there doesn't seem to be any method to just  
get a reference to the clicked view. This seems very strange to me,  
so I really hope I'm missing something very simple.


J.
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: bug in PhotoSearch

2008-07-29 Thread [EMAIL PROTECTED]

At 4:38 PM -0700 7/25/08, Corbin Dunn wrote:

On Jul 25, 2008, at 3:52 PM, [EMAIL PROTECTED] wrote:
also, is there a specific reason for caching the cell in 
iMouseCell? i've done away with the caching in my app (and thus 
also don't have to override preparedCellAtColumn:row:), and now all 
my problems have gone away? my guess is that u were caching the 
cell for performance reasons... is that correct? or am i opening 
myself up for a future problem?


Yes; tableview uses a single cell to "stamp" out each row in a given 
column. you might have trouble with the properties getting set if 
something else triggers that cell on a different row to redraw while 
the mouse is over the current cell.


corbin,
first off. thanx for your replies and for the demo!

i thought i understood this, but the more i thought about it, the 
less i understood!


it seems to me that all drawing of table cells will go first thru 
preparedCellAtColumn:row:, next to the delegate method 
tableView:willDisplayCell:forTableColumn:row:, then thru the table's 
drawRect: and finally to the appropriate cell's drawing methods 
(altho i may have the order wrong, and it may be that drawRect calls 
preparedCellAtColumn:row, 
tableView:willDisplayCell:forTableColumn:row:, and the cell's drawing 
methods). since the sample code's (and my) mouse entered/exit methods 
simply indicate that the cell rect needs to be displayed, drawing 
caused by entering/exiting a cell's tracking area will go thru the 
same sequence. (is this correct?) thus, unless some cell drawing is 
done outside the normal mechanism (via some direct draws or draws 
from another thread), there should be no reason to cache the cell.


so... (since i readily grant that u have much more knowledge than i 
do), what am i missing? :-)


thanx,
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: getting the clicked-in view

2008-07-29 Thread James Maxwell
Okay, I found a way around the problem... But it might still be handy  
to know how to do this, at some point...


On 29-Jul-08, at 12:56 PM, James Maxwell wrote:

This is really silly, but how can I get a reference to the clicked- 
in view???


I don't have direct access to the event, but I can get it through  
NSApp. The problem is, there doesn't seem to be any method to just  
get a reference to the clicked view. This seems very strange to me,  
so I really hope I'm missing something very simple.


J.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jbmaxwell%40rubato-music.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: getting the clicked-in view

2008-07-29 Thread Gary L. Wade
How do you know you got a click in a view?  In other words, at what stage are 
you in your application that you believe you got a click in a view?

>Okay, I found a way around the problem... But it might still be handy  
>to know how to do this, at some point...
>
>On 29-Jul-08, at 12:56 PM, James Maxwell wrote:
>
>> This is really silly, but how can I get a reference to the clicked- 
>> in view???
>>
>> I don't have direct access to the event, but I can get it through  
>> NSApp. The problem is, there doesn't seem to be any method to just  
>> get a reference to the clicked view. This seems very strange to me,  
>> so I really hope I'm missing something very simple.
>>
>> J.
___

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

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


private methods and variables

2008-07-29 Thread Torsten Curdt
This question is NOT about private APIs from Apple but more about how  
to organize structure my own code.


Especially for a framework I don't want to expose implementation  
details to the interface.

So while I found the suggestion to use a special category like:

 @interface MyClass
 -(void) publicMethod;
 @end

 @interface MyClass (Private)
 {
int privateVariable;
 }
 -(void) privateMethod;
 @end

I am not sure why that would be better than to just do

 @interface MyClass
 -(void) publicMethod;
 @end

 @implementation MyClass

 int privateVariable;
 -(void) privateMethod {
 }

 -(void) publicMethod {
 }

 @end

Any wise words?

cheers
--
Torsten
___

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

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

2008-07-29 Thread Michael Ash
On Tue, Jul 29, 2008 at 2:04 PM, Bill Bumgarner <[EMAIL PROTECTED]> wrote:
> On Jul 29, 2008, at 10:57 AM, Nathaniel Gottlieb-Graham wrote:
>>
>> Why do externs seem to have to be NSStrings?  Also, is this even the right
>> way to go about having a read/write global NSMutableDictionary?  If not, how
>> would I do this?
>
> The variables cannot point to anything that isn't a constant.   @"foo bar"
> is a constant string and is handled differently by the compiler/linker.
> [[NSMutableDictionary dictionary] retain] is not a constant and, thus,
> cannot be used to directly initialize a variable at time of declaration
> within a global scope.
>
> Instead, you need to initialize the variables as early as needed within your
> application.
>
> This could be done in main().   Or it could be done in the +initialize for a
> class.
>
> Or you could annotate a function as a constructor.  It will run before
> main().
>
> static void __InitializeGlobalStuffMan(void) __attribute__ ((constructor));
> void __InitializeGlobalStuffMan(void) {
>myGlobalDictionary = [[NSMutableDictionary alloc] init];
>
> }

Is this safe to do? I would be afraid that this might execute before
the ObjC runtime is initialized, leading to pain and possibly hilarity
when the objc_msgSends execute. Of course you would know better than I
would about whether that's actually the case.

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: private methods and variables

2008-07-29 Thread Bill Bumgarner

On Jul 29, 2008, at 2:02 PM, Torsten Curdt wrote:

@interface MyClass
-(void) publicMethod;
@end

@interface MyClass (Private)
{
int privateVariable;
}
-(void) privateMethod;
@end

I am not sure why that would be better than to just do

@interface MyClass
-(void) publicMethod;
@end

@implementation MyClass

int privateVariable;
-(void) privateMethod {
}

-(void) publicMethod {
}

@end

Any wise words?


privateVariable is a global in your second example.

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: Storing values in dictionary with their address as the key

2008-07-29 Thread Nathan Vander Wilt

On Jul 29, 2008, at 8:58 AM, Nathan Vander Wilt wrote:
Right, -[NSDictionary setObject:forKey:] on a CFDictionary created  
with a custom retain callback will invoke copyWithZone: before  
calling your retain callback.  Apple claims this is not a bug.   
Getting/removing values with objectForKey:/removeObjectForKey:  
should work, though; if it doesn't, I'd like to know.



Yes, accessing and removing keys should work fine. For immutable  
keys (you weren't planning on changing a key behind NSDictionary's  
back anyway, right) a copy is often just implemented as a retain.  
Since toll-free bridged NSDictionary must provide CFDictionary  
retain/release callbacks to work right on the Core Foundation side  
of things, it must be copying the key, adding it to the array (where  
it is retained by the callback), and then releasing it's local  
reference. Take out steps one and three, which are equivalent to a  
retain followed by a release, and nothing should change as far as  
object accessing or removal.



Actually, that category thing is a no-go if you intend to archive your  
dictionary! I repeat: beware of the code I posted thread previous!


While this is an implementation detail that could change, - 
[NSDictionary initWithCoder:] calls some internal dictionary class's - 
initWithObjects:forKeys:count: that also copies the keys. This leads  
me to suspect that NS[Mutable]Dictionary may recopy keys in other  
places at whim as well. I am not sure what happens if you try to  
unarchive a CFDictionary that was archived as an NSDictionary, but  
I've got better things to do than mess with a class that clearly was  
not designed for what I'm trying to use it for.


If you want to use non-copied/pointer-equivalent objects as keys,  
especially if there is any chance you're going to be doing any  
archiving, skip NSMutableDictionary. Use NSMapTable instead, which  
thankfully also supports NSCoding.


hth,
-natevw
___

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

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

2008-07-29 Thread Corbin Dunn

howdy ken,




it seems to me that all drawing of table cells will go first thru  
preparedCellAtColumn:row:, next to the delegate method  
tableView:willDisplayCell:forTableColumn:row:, then thru the table's  
drawRect: and finally to the appropriate cell's drawing methods  
(altho i may have the order wrong, and it may be that drawRect calls  
preparedCellAtColumn:row,  
tableView:willDisplayCell:forTableColumn:row:, and the cell's  
drawing methods).


You can find out by breaking on your methods and looking at the  
backtrace for any particular method (or, break on appkit methods - you  
just won't have source). It works as follows:


table needs to draw, thus, the following calls happen (simplified  
model):

   drawRect() {
for (each row to draw) {
drawRow(row) {
cell = preparedCellAtRow() {
setup the cell's properties
call willDisplayCell.. last
}
[cell drawInRect..]
}
}
}


since the sample code's (and my) mouse entered/exit methods simply  
indicate that the cell rect needs to be displayed, drawing caused by  
entering/exiting a cell's tracking area will go thru the same  
sequence. (is this correct?) thus, unless some cell drawing is done  
outside the normal mechanism (via some direct draws or draws from  
another thread), there should be no reason to cache the cell.


It's not necessarily another thread, but something else, ie: a view  
behind your tableview, could (for some reason) need to be redrawn, and  
the table would subsequently need to be redrawn at that part.


Basically, if it works for the cases your using, then there is no  
reason to copy the cell. But, in the end, copying the cell is very  
lightweight.


--corbin




so... (since i readily grant that u have much more knowledge than i  
do), what am i missing? :-)


thanx,
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: global NSMutableDictionary

2008-07-29 Thread Kirk Kerekes

Consider class methods instead of globals. See:



Unmentioned there is the additional advantage of lazy initialization:  
(composed in Mail)


+ (NSMutableDictionay *) myGlobalDict
{
static NSMutableDictionary * result = nil;
if(!result)
{
result = [[self myComplicatedGlobalFactoryMethod] retain]
}
return result;
}

Caveat: Multi-threaded access may require additional precautions,  
depending on sequence.



___

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

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

2008-07-29 Thread Ken Thomases

On Jul 29, 2008, at 4:02 PM, Torsten Curdt wrote:

This question is NOT about private APIs from Apple but more about  
how to organize structure my own code.


Especially for a framework I don't want to expose implementation  
details to the interface.

So while I found the suggestion to use a special category like:

@interface MyClass
-(void) publicMethod;
@end

@interface MyClass (Private)
{
int privateVariable;


This is an instance variable.  There's one per instance.




}
-(void) privateMethod;
@end

I am not sure why that would be better than to just do

@interface MyClass
-(void) publicMethod;
@end

@implementation MyClass

int privateVariable;


There is only one of these across the entire program.  It's not an  
instance variable.  It's as close as Objective-C gets to what would be  
a "class variable" in another language.  (Although it should probably  
be declared "static" to limit its linkage to this translation unit.)




-(void) privateMethod {
}

-(void) publicMethod {
}

@end


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: private methods and variables

2008-07-29 Thread Torsten Curdt


@implementation MyClass

int privateVariable;


There is only one of these across the entire program.  It's not an  
instance variable.  It's as close as Objective-C gets to what would  
be a "class variable" in another language.  (Although it should  
probably be declared "static" to limit its linkage to this  
translation unit.)




-(void) privateMethod {
}

-(void) publicMethod {
}

@end


Thanks guys. I basically though that there was a difference between:

@implementation MyClass
 int privateVariable;
@end

and

 int privateVariable;
@implementation MyClass
@end

the first being being an ivar. The second just being a global.
But IIUC now - there really is no difference. That correct?

cheers
--
Torsten
___

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

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

2008-07-29 Thread Kyle Sluder
On Tue, Jul 29, 2008 at 7:30 PM, Torsten Curdt <[EMAIL PROTECTED]> wrote:
> @implementation MyClass
>  int privateVariable;
> @end
>
> and
>
>  int privateVariable;
> @implementation MyClass
> @end
>
> the first being being an ivar. The second just being a global.
> But IIUC now - there really is no difference. That correct?

Did you intend for the first example's ivar to be contained within
braces?  In that case, you were right the first time.

--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: private methods and variables

2008-07-29 Thread Ken Thomases

On Jul 29, 2008, at 6:30 PM, Torsten Curdt wrote:


Thanks guys. I basically though that there was a difference between:

@implementation MyClass
int privateVariable;
@end

and

int privateVariable;
@implementation MyClass
@end

the first being being an ivar. The second just being a global.
But IIUC now - there really is no difference. That correct?


Correct.

On a somewhat-related subject, there _is_ a difference between:

@implementation MyClass
void someFunction(/* ... */)
{
/* ... */
}
@end

and:

void someFunction(/* ... */)
{
/* ... */
}

@implementation MyClass
@end


In the former, someFunction is considered to be a part of the  
implementation of the class and is permitted to access private and  
protected ivars of any MyClass instance it may get its hands on.  In  
the latter, someFunction has no particular special relationship to  
MyClass.


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: private methods and variables

2008-07-29 Thread Ken Thomases

On Jul 29, 2008, at 6:53 PM, Kyle Sluder wrote:

On Tue, Jul 29, 2008 at 7:30 PM, Torsten Curdt <[EMAIL PROTECTED]>  
wrote:

@implementation MyClass
int privateVariable;
@end

and

int privateVariable;
@implementation MyClass
@end

the first being being an ivar. The second just being a global.
But IIUC now - there really is no difference. That correct?


Did you intend for the first example's ivar to be contained within
braces?  In that case, you were right the first time.


You can't add additional ivars in an @implementation block.  You can  
only redundantly mirror the ivar declarations that were in the  
@interface block which is a waste of typing and doesn't accomplish  
what he was trying to do: declare private instance variables that  
wouldn't appear in the header.


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]


Showing another sheet in openPanelDidEnd

2008-07-29 Thread Kenny Carruthers
	Does anyone know why any attempts to show a second sheet immediately  
after an NSOpenPanel has been dismissed causes the parent window to  
disappear?


The user flow is as follows:

- Show Import Window
- Show NSOpenPanel via [panel beginSheetForDirectory...]
(Panel is properly displayed)

- User either accepts or cancels the file panel
- My openPanelDidEnd method is properly called with the correct result  
from the File Panel


- If I now try showing a new sheet, my main Import Window will hide  
and I'll be left with just my new sheet on the screen.


If I skip the File Panel operation, then my sheet is correctly shown,  
so that's working properly. Since the File Panel is not completely  
dismissed inside openPanelDidEnd I wonder if something weird isn't  
going on with [NSApp beginSheet...] whereby it can't show the new  
sheet because the File Panel is still being "rolled up" inside  
openPanelDidEnd. NSApp appears to be smart enough to not let you show  
to sheets on one window, I get a system beep when trying to do that,  
but maybe it's confused here because the File Panel has been dismissed  
but is still be animated while my code executes to show the second  
sheet. Maybe there's a way to know when the File Panel has been full  
dismissed?


Thoughts?

Thanks for any help,
Kenny
___

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

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

2008-07-29 Thread Erik Buck

@implementation MyClass
  int privateVariable;   // this is an instance variable
@end


and

int privateVariable;   // this is a global variable
@implementation MyClass
@end

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Showing another sheet in openPanelDidEnd

2008-07-29 Thread Ken Thomases

On Jul 29, 2008, at 7:11 PM, Kenny Carruthers wrote:

	Does anyone know why any attempts to show a second sheet  
immediately after an NSOpenPanel has been dismissed causes the  
parent window to disappear?


The user flow is as follows:

- Show Import Window
- Show NSOpenPanel via [panel beginSheetForDirectory...]
(Panel is properly displayed)

- User either accepts or cancels the file panel
- My openPanelDidEnd method is properly called with the correct  
result from the File Panel


- If I now try showing a new sheet, my main Import Window will hide  
and I'll be left with just my new sheet on the screen.


If I skip the File Panel operation, then my sheet is correctly  
shown, so that's working properly. Since the File Panel is not  
completely dismissed inside openPanelDidEnd I wonder if something  
weird isn't going on with [NSApp beginSheet...] whereby it can't  
show the new sheet because the File Panel is still being "rolled up"  
inside openPanelDidEnd. NSApp appears to be smart enough to not let  
you show to sheets on one window, I get a system beep when trying to  
do that, but maybe it's confused here because the File Panel has  
been dismissed but is still be animated while my code executes to  
show the second sheet. Maybe there's a way to know when the File  
Panel has been full dismissed?


Thoughts?


Did you explicitly close the first sheet in your did-end method,  
before attempting to show the second sheet?  You have to do that  
yourself.  It isn't automatically closing for you.


See this: 
http://developer.apple.com/documentation/Cocoa/Conceptual/Sheets/Tasks/UsingCascadingSheets.html

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: private methods and variables

2008-07-29 Thread Erik Buck

On Jul 29, 2008, at 7:19 PM, Erik Buck wrote:



@implementation MyClass
 int privateVariable;   // this is an instance variable
@end


and

int privateVariable;   // this is a global variable
@implementation MyClass
@end



Never mind.  both declarations above are global variables.

@interface MyClass : NSObject
{
 int privateVariable;   // this is an instance variable
}

@end


and

extern int privateVariable;   // this is a global variable

@interface MyClass : NSObject
{
}

@end
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: private methods and variables

2008-07-29 Thread Kyle Sluder
On Tue, Jul 29, 2008 at 7:58 PM, Ken Thomases <[EMAIL PROTECTED]> wrote:
> On Jul 29, 2008, at 6:53 PM, Kyle Sluder wrote:
>> Did you intend for the first example's ivar to be contained within
>> braces?  In that case, you were right the first time.
>
> You can't add additional ivars in an @implementation block.  You can only
> redundantly mirror the ivar declarations that were in the @interface block
> which is a waste of typing and doesn't accomplish what he was trying to do:
> declare private instance variables that wouldn't appear in the header.

Yeah, my brain saw @interface.  Seen the right pattern too much.  :P

--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: private methods and variables

2008-07-29 Thread Torsten Curdt

Thanks for the clarification folks!

On Jul 30, 2008, at 01:58, Ken Thomases wrote:


On Jul 29, 2008, at 6:53 PM, Kyle Sluder wrote:

On Tue, Jul 29, 2008 at 7:30 PM, Torsten Curdt <[EMAIL PROTECTED]>  
wrote:

@implementation MyClass
int privateVariable;
@end

and

int privateVariable;
@implementation MyClass
@end

the first being being an ivar. The second just being a global.
But IIUC now - there really is no difference. That correct?


Did you intend for the first example's ivar to be contained within
braces?  In that case, you were right the first time.


You can't add additional ivars in an @implementation block.  You can  
only redundantly mirror the ivar declarations that were in the  
@interface block which is a waste of typing and doesn't accomplish  
what he was trying to do: declare private instance variables that  
wouldn't appear in the header.


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]


Detecting platform architecture within Cocoa app?

2008-07-29 Thread Jack Skellington
Hello List

Is there a way to determine if an App is running on Intel or PPC
from within the App?

/Dacobi

___

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

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

2008-07-29 Thread Robert Lang
I think that's because when you compile the code, if one of your methods
forward references a private method and you haven't declared it in the
interface, you will get a warning.

Also, when you declare privateVariable in the implementation block you are
not declaring it as an instance variable of MyClass but instead as a normal
C variable in global scope.

Best,
Robert

On Tue, Jul 29, 2008 at 10:02 PM, Torsten Curdt <[EMAIL PROTECTED]> wrote:

> This question is NOT about private APIs from Apple but more about how to
> organize structure my own code.
>
> Especially for a framework I don't want to expose implementation details to
> the interface.
> So while I found the suggestion to use a special category like:
>
>  @interface MyClass
>  -(void) publicMethod;
>  @end
>
>  @interface MyClass (Private)
>  {
>int privateVariable;
>  }
>  -(void) privateMethod;
>  @end
>
> I am not sure why that would be better than to just do
>
>  @interface MyClass
>  -(void) publicMethod;
>  @end
>
>  @implementation MyClass
>
>  int privateVariable;
>  -(void) privateMethod {
>  }
>
>  -(void) publicMethod {
>  }
>
>  @end
>
> Any wise words?
>
> cheers
> --
> Torsten
>
>
___

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

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

2008-07-29 Thread Hamish Allan
-- Forwarded message --
From: Hamish Allan <[EMAIL PROTECTED]>
Date: Tue, Jul 29, 2008 at 5:09 PM
Subject: Re: [Newbie] Communication between two Views?
To: "I. Savant" <[EMAIL PROTECTED]>
Cc: CocoaDev list 


On Tue, Jul 29, 2008 at 4:34 PM, I. Savant <[EMAIL PROTECTED]> wrote:

> I was merely mentioning that your assertion that views should
> communicate with controllers via the model layer (which is what your
> original message seemed to imply) is incorrect as stated because it
> implies this is *always* (or even "usually") the case.

Ah, I read it as "that's not always the case: consider the following example".

>  Further, I was suggesting that your blanket statement that
> controllers shouldn't communicate with one-another (generally or not)
> is incorrect (or at least inaccurate) because such an approach is a
> matter of design, whether because of your 'tastes' or functional
> requirements.

Sure. I should have been more explicit about that. I got the
impression from the OP that he was talking about mediating controllers
(in which case I would argue that my rule of thumb is well-aligned
with the principles of MVC) rather than co-ordinating controllers.

>  Indeed. A lack of concrete specifications in the OP's project or our
> examples so far makes design debates pointless in this discussion. I
> just want to make sure that if we make assertions, we do so without
> ambiguity. Anything less may make someone else's life a whole lot
> harder than it needs to be.

I think it's plain what the OP was trying to do: tie the detail in a
master-detail interface to an object newly added to the collection.
However, as he seems to be using some sort of custom navigation
controller, I can't be sure ;)

>  No harm was intended on my part.

Nor mine!

Hamish
___

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

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

2008-07-29 Thread Torsten Curdt

But wait ...this works OK for methods. But what about adding ivars?

 @interface MyClass (Private)
 {
 int myvar;
 }

 - (int) myvar;

 @end

This gives a syntax error. Looking through some docs it seems I cannot  
add ivars through a category.

So how can I have private ivars that don't show up in the interface?

cheers
--
Torsten
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Detecting platform architecture within Cocoa app?

2008-07-29 Thread Steve Christensen

On Jul 29, 2008, at 12:56 PM, Jack Skellington wrote:


Is there a way to determine if an App is running on Intel or PPC
from within the App?


Depending on what you're trying to do, you can go at least a couple  
routes at build time.


If you only care about endianness:

#ifdef __BIG_ENDIAN__
#ifdef __LITTLE_ENDIAN__


If you care about the actual architecture:

#ifdef __ppc__  // 32-bit PPC
#ifdef __ppc64__// 64-bit PPC
#ifdef __i386__ // 32-bit Intel
#ifdef __x86_64__   // 64-bit Intel


There are also parallel ones defined in /usr/include/ 
TargetConditionals.h:


#if TARGET_RT_LITTLE_ENDIAN
#if TARGET_RT_BIG_ENDIAN

#if TARGET_CPU_PPC
#if TARGET_CPU_PPC64
#if TARGET_CPU_X86
#if TARGET_CPU_X86_64

___

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

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


method naming

2008-07-29 Thread Torsten Curdt

Class A has method

 - (void) something:(Someclass*)s;

Class B has method

 - (BOOL) something:(Someclass*)s;

Why on earth am I getting a warning

 warning: multiple methods named '-something:' found
 using...
 also found...

They are on different objects. Should be obvious there is no problem.
Is this really just a "careful - you sure you picked the right one?"
Or what am I missing?

cheers
--
Torsten
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Repositioning a content view w/in a window

2008-07-29 Thread R.L. Grigg

On Jul 28, 2008, at 11:48 PM, Jonathan Hess wrote:


On Jul 28, 2008, at 3:29 PM, R.L. Grigg wrote:


On Jul 26, 2008, at 3:15 AM, Michael Ash wrote:


On Fri, Jul 25, 2008 at 11:08 PM, Henry McGilton (Starbase)
<[EMAIL PROTECTED]> wrote:

On Jul 25, 2008, at 6:50 PM, Michael Ash wrote:


In fact I would go so far as to say that if you ever use
-setContentView:, you are very probably doing it wrong. It is,  
for the

most part, not a very useful call, and you can accomplish the same
thing more naturally, easily, and flexibly by adding the view as a
subview to the content view instead.


Well, I would not go quite that far, although I agree with you
in principle for normal everyday stuff.I have some applications
which create bare windows --- no borders, controls, resizers,
shadows, and so on.The view that replaces the default window
content view does all the drawing.I don't see any value in
having a content view whose only purpose in life is to act as
a container for my drawing view.


Might come a day that you want two views in there, or you want to  
move

that one view around, and suddenly the value appears. Since it's no
harder to do things the "right" way, why not?


Okay, I'm a little bit confused. What is the "right" way?

I create a NSWindow and then I'm displaying a NSMatrix in that  
window. Now I need to move the NSMatrix around in the NSWindow.


Is something like this a decent Cocoa approach:

   // create the window
   myWindow = [[NSWindow alloc] initWithContentRect: ... ];
   // insert the existing matrix as it's content view
   [myWindow setContentView:myMatrix];
   // alter the position of the matrix
   NSPoint newPoint = ...
   [myMatrix setFrameOrigin:newPoint];
   [myWindow display];

Thx!
Russ


Hey Russ -

The location and size of the content view of the window is  
conceptually owned by the NSWindow instance. If you alter the  
origin, you're breaking the encapsulation provided by NSWindow and  
the NSWindow is likely to either break, or reset it, or both. You  
should leave the content view of the window in its default state as  
a vanilla NSView, and instead add your matrix to the window's  
content view. You can do that with something like this:


   myWindow = [[NSWindow alloc] initWithContentRect: ... ];
   // insert the existing matrix as it's content view
   [[myWindow contentView] addSubview:myMatrix];
   // alter the position of the matrix
   NSPoint newPoint = ...
   [myMatrix setFrameOrigin:newPoint];

I also removed the call to [myWindow display]. You should only ever  
call 'display' or 'displayIfNeeded' if you have a good reason to  
short circuit the normal view/window redrawing mechanism. Short  
circuiting the behavior can lead to poor performance if the window  
ends up accidently being drawn many times per event loop.


Good Luck -
Jon Hess


Thanks, Jon!  Now that I understand to leave the NSWindow's content  
view alone, but just and my own subview to it, I have things working  
smoothly. I can resize and reposition the NSMatrix anywhere on (or  
off!) the window, which is what my goal was.


Thanks all for your patience,
Russ

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Detecting platform architecture within Cocoa app?

2008-07-29 Thread Torsten Curdt

Have a look here:

http://vafer.org/gitweb/FeedbackReporter.git?a=blob;f=Sources/Main/SystemDiscovery.m;h=417d8a1f0b71224b5bb2271028926d4c5874c497;hb=63855ef8957a393a2aebd091b421f8b310395d04

Endian-ness testing is also here:

http://vafer.org/gitweb/uif2iso4mac.git?a=blob;f=Sources/MyDocument.m;h=82a2ddc8614b8d5fd6536fd2b418ab1d3beeb550;hb=6d0582e95d20375d943d8ec4103dc841bfc9083b

HTH

cheers
--
Torsten

On Jul 30, 2008, at 03:44, Steve Christensen wrote:


On Jul 29, 2008, at 12:56 PM, Jack Skellington wrote:


Is there a way to determine if an App is running on Intel or PPC
from within the App?


Depending on what you're trying to do, you can go at least a couple  
routes at build time.


If you only care about endianness:

#ifdef __BIG_ENDIAN__
#ifdef __LITTLE_ENDIAN__


If you care about the actual architecture:

#ifdef __ppc__  // 32-bit PPC
#ifdef __ppc64__// 64-bit PPC
#ifdef __i386__ // 32-bit Intel
#ifdef __x86_64__   // 64-bit Intel


There are also parallel ones defined in /usr/include/ 
TargetConditionals.h:


#if TARGET_RT_LITTLE_ENDIAN
#if TARGET_RT_BIG_ENDIAN

#if TARGET_CPU_PPC
#if TARGET_CPU_PPC64
#if TARGET_CPU_X86
#if TARGET_CPU_X86_64

___

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

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

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

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: method naming

2008-07-29 Thread Roland King


|-Wselector |(Objective-C and Objective-C++ only)
   Warn if multiple methods of different types for the same selector
   are found during compilation. The check is performed on the list of
   methods in the final stage of compilation. Additionally, a check is
   performed for each selector appearing in a |@selector(...)|
   expression, and a corresponding method for that selector has been
   found during compilation. Because these checks scan the method table
   only at the end of compilation, these warnings are not produced if
   the final stage of compilation is not reached, for example because
   an error is found during compilation, or because the -fsyntax-only
   option is being used.

same selector - return types are different.

The selector is only the 'something:' bit, it doesn't encode the return 
type or the argument types, so in dynamic binding selectors are required 
to have the same signature.



Torsten Curdt wrote:


Class A has method

 - (void) something:(Someclass*)s;

Class B has method

 - (BOOL) something:(Someclass*)s;

Why on earth am I getting a warning

 warning: multiple methods named '-something:' found
 using...
 also found...

They are on different objects. Should be obvious there is no problem.
Is this really just a "careful - you sure you picked the right one?"
Or what am I missing?

cheers
--
Torsten
___

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

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

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

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: private methods and variables

2008-07-29 Thread Charles Steinman
--- On Tue, 7/29/08, Torsten Curdt <[EMAIL PROTECTED]> wrote:

> But wait ...this works OK for methods. But what about adding
> ivars?
> 
>   @interface MyClass (Private)
>   {
>   int myvar;
>   }
> 
>   - (int) myvar;
> 
>   @end
> 
> This gives a syntax error. Looking through some docs it
> seems I cannot  
> add ivars through a category.
> So how can I have private ivars that don't show up in
> the interface?

You can't without hacks like putting a byte blob or pointer at the bottom of 
your class and filling that with extra ivars. Apple does this in its frameworks 
to maintain binary compatibility while still being able to change the structure 
of a class. But unless backward binary compatibility is a concern for you, it's 
easier just to use @private if the variables must be private rather than 
protected.

Cheers,
Chuck


  
___

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

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


NSTextFieldCell - Kidnapped Focus Ring!

2008-07-29 Thread Seth Willits


I cannot for the life of me get an NSTextFieldCell (in my custom view)  
to show a focus ring when editing!! Is there something stupidly simple  
that I'm missing?


[editingTextFieldCell setShowsFirstResponder:YES];
[editingTextFieldCell setFocusRingType:NSFocusRingTypeDefault];

I could assume from this that it's the view's responsibility to draw  
the focus ring, but the documentation* and my previous experience  
strongly suggests otherwise.




This is driving me insane...

--
Seth Willits



*Second section on this page:
http://developer.apple.com/documentation/Cocoa/Conceptual/ControlCell/Articles/ManipulateCellControl.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: private methods and variables

2008-07-29 Thread Ken Thomases

On Jul 29, 2008, at 8:22 PM, Torsten Curdt wrote:


So how can I have private ivars that don't show up in the interface?


You can use the pImpl (pointer-to-implementation) idiom for classes  
that you're writing yourself:


@class MyPrivateStuff;
@interface MyClass : NSObject
{
MyPrivateStuff* pImpl;
}

/* ... */

@end


Then, in your .m file:

@interface MyPrivateStuff : NSObject
{
id foo;
NSString* bar;
/* ... */
};
@end

@implementation MyPrivateStuff
/* ... */
@end

@implementation MyClass

- (id) init
{
if (self = [super init])
{
pImpl = [[MyPrivateStuff alloc] init];
/* ... */
}
}

@end



For classes which you are not writing yourself, you can still extend  
them with categories.  For properties, you add the usual accessor  
methods, which is straightforward with a category.  Providing per- 
instance backing storage for the properties is more complicated.  One  
technique is to use a "category variable" (like the "class variable"  
we were discussing earlier; really just a static file-scope variable)  
to keep an associative collection which maps from "self" to a mutable  
dictionary of property values.  NSMapTable is a good candidate for  
this sort of collection.


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: method naming

2008-07-29 Thread Charles Steinman
--- On Tue, 7/29/08, Torsten Curdt <[EMAIL PROTECTED]> wrote:

> Class A has method
> 
>   - (void) something:(Someclass*)s;
> 
> Class B has method
> 
>   - (BOOL) something:(Someclass*)s;
> 
> Why on earth am I getting a warning
> 
>   warning: multiple methods named '-something:'
> found
>   using...
>   also found...
> 
> They are on different objects. Should be obvious there is
> no problem.
> Is this really just a "careful - you sure you picked
> the right one?"
> Or what am I missing?

The compiler doesn't know what class the object belongs to. You're sending the 
message either to a variable of type id or the result of a method that returned 
id. The id type can hold any class, so if there are two identically named 
methods with different signatures (BOOL return type vs. void, for instance), it 
doesn't have enough information to pick the right signature.

Cheers,
Chuck


  
___

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

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

2008-07-29 Thread Greg Parker

Michael Ash wrote:

On Tue, Jul 29, 2008 at 2:04 PM, Bill Bumgarner <[EMAIL PROTECTED]> wrote:
Or you could annotate a function as a constructor.  It will run  
before main().
static void __InitializeGlobalStuffMan(void) __attribute__  
((constructor));

void __InitializeGlobalStuffMan(void) {
   myGlobalDictionary = [[NSMutableDictionary alloc] init];
   
}



Is this safe to do? I would be afraid that this might execute before
the ObjC runtime is initialized, leading to pain and possibly hilarity
when the objc_msgSends execute.


It's safe, usually.

The runtime always goes first. You can't run code that uses a class  
before the runtime sets up that class. However, if the class has +load  
methods or C/C++ constructors of its own, then it may be possible to  
use the class before it is ready for you.


The initialization order is complicated, but in general:
1. All libraries you link to are ready for use before any of your code  
runs.
2. All of your own classes are prepared by the runtime before any of  
your code runs.
3. All of your +load methods are called before any of your C/C++  
constructors.

4. Superclass +load always runs before subclass +load.

It is possible for one of your constructors or +load methods to use  
another one of your classes before its own +load is called, so be  
careful if you have complicated constructor work or constructor work  
in more than one place.



--
Greg Parker [EMAIL PROTECTED] Runtime Wrangler


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Detecting platform architecture within Cocoa app?

2008-07-29 Thread Ken Thomases

On Jul 29, 2008, at 8:44 PM, Steve Christensen wrote:


On Jul 29, 2008, at 12:56 PM, Jack Skellington wrote:


Is there a way to determine if an App is running on Intel or PPC
from within the App?


Depending on what you're trying to do, you can go at least a couple  
routes at build time.


If you only care about endianness:

#ifdef __BIG_ENDIAN__
#ifdef __LITTLE_ENDIAN__


If you care about the actual architecture:

#ifdef __ppc__  // 32-bit PPC
#ifdef __ppc64__// 64-bit PPC
#ifdef __i386__ // 32-bit Intel
#ifdef __x86_64__   // 64-bit Intel


There are also parallel ones defined in /usr/include/ 
TargetConditionals.h:


#if TARGET_RT_LITTLE_ENDIAN
#if TARGET_RT_BIG_ENDIAN

#if TARGET_CPU_PPC
#if TARGET_CPU_PPC64
#if TARGET_CPU_X86
#if TARGET_CPU_X86_64


Note that all of these detect the compile-time targeted architecture.   
In rare case (e.g. Rosetta), this may be different than the actual  
architecture of the machine at runtime.  Generally, you probably don't  
care.  (A PPC binary running on an Intel Mac should probably not do  
anything differently than it would on a real PPC Mac.)


If you do care, see this: 
http://developer.apple.com/documentation/MacOSX/Conceptual/universal_binary/universal_binary_exec_a/chapter_950_section_7.html

That describes a technique using the sysctl API.  That API can also be  
used to determine lots of other aspects of the runtime environment, too.


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: Detecting platform architecture within Cocoa app?

2008-07-29 Thread Phil
On Wed, Jul 30, 2008 at 7:56 AM, Jack Skellington <[EMAIL PROTECTED]> wrote:
> Is there a way to determine if an App is running on Intel or PPC
> from within the App?
>

Gestalt() is still good for this, using the gestaltSysArchitecture selector.


Phil
___

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

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


Checking for hackintosh

2008-07-29 Thread John Joyce

Does anybody have a means or a tool for checking for hackintoshes?
I really don't approve of such things and would like to leave clever  
messages on my own software if it is run on a hackintosh.

___

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

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

2008-07-29 Thread Torsten Curdt
The compiler doesn't know what class the object belongs to. You're  
sending the message either to a variable of type id or the result of  
a method that returned id.The id type can hold any class, so if  
there are two identically named methods with different signatures  
(BOOL return type vs. void, for instance), it doesn't have enough  
information to pick the right signature.


That would make sense but it was complaining on

  [NSApp reportException: x];

And some other class just has

 -(BOOL)reportException:(NSException*)e;

So I did't get why this should be ambiguous because NSApp obviously  
can't be of type id. Well turns out - it actually is. And now it all  
makes sense again :)


I've just replaced [NSApp ..] with [[NSApplication  
sharedApplication] ...]


Thanks guys!

cheers
--
Torsten
___

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

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

2008-07-29 Thread Torsten Curdt

Thanks for that!

Really interesting - but also sounds really terrible :)

Makes you wonder why stuff like hasn't been fixed in Objective-C 2.0.

cheers
--
Torsten

On Jul 30, 2008, at 04:03, Ken Thomases wrote:


On Jul 29, 2008, at 8:22 PM, Torsten Curdt wrote:


So how can I have private ivars that don't show up in the interface?


You can use the pImpl (pointer-to-implementation) idiom for classes  
that you're writing yourself:


@class MyPrivateStuff;
@interface MyClass : NSObject
{
MyPrivateStuff* pImpl;
}

/* ... */

@end


Then, in your .m file:

@interface MyPrivateStuff : NSObject
{
id foo;
NSString* bar;
/* ... */
};
@end

@implementation MyPrivateStuff
/* ... */
@end

@implementation MyClass

- (id) init
{
if (self = [super init])
{
pImpl = [[MyPrivateStuff alloc] init];
/* ... */
}
}

@end



For classes which you are not writing yourself, you can still extend  
them with categories.  For properties, you add the usual accessor  
methods, which is straightforward with a category.  Providing per- 
instance backing storage for the properties is more complicated.   
One technique is to use a "category variable" (like the "class  
variable" we were discussing earlier; really just a static file- 
scope variable) to keep an associative collection which maps from  
"self" to a mutable dictionary of property values.  NSMapTable is a  
good candidate for this sort of collection.


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: method naming

2008-07-29 Thread Bill Bumgarner

On Jul 29, 2008, at 7:41 PM, Torsten Curdt wrote:
So I did't get why this should be ambiguous because NSApp obviously  
can't be of type id. Well turns out - it actually is. And now it all  
makes sense again :)


I've just replaced [NSApp ..] with [[NSApplication  
sharedApplication] ...]


Glad you have a solution!

NSApp is of type (id) because it is not uncommon -- though not the  
rule, either -- that applications will subclass NSApplication as their  
primary application class (settable in the build settings inspector of  
your Application's target in XCode).


Thus, by typing it of type (id), the compiler will complain of  
ambiguities like the one you encountered.


In general, there shouldn't be any such ambiguities.  Objective-C does  
not mangle the names together with the argument types.   There is a  
single flat namespace for all method names in your application's  
runtime.   The "name" is just the selector, no argument types.


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: private methods and variables

2008-07-29 Thread Bill Bumgarner

On Jul 29, 2008, at 7:45 PM, Torsten Curdt wrote:

Thanks for that!

Really interesting - but also sounds really terrible :)

Makes you wonder why stuff like hasn't been fixed in Objective-C 2.0.


It has been in the modern runtime -- the runtime used in on 64 bits  
and "other places".  In that environment, the runtime can and will  
@synthesize instance variables and it is possible to add instance  
variables in a private way (but not supported entirely in syntax).


As well, the modern runtime allows a superclass to add instance  
variables without recompiling subclasses.


It isn't fixed in the 32 bit runtime because we couldn't figure out a  
way to do so that both preserved binary compatibility and used a  
finite amount of memory / CPU.


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]

Simple Core Data Question

2008-07-29 Thread Dave DeLong
Hi everyone,

I'm taking a stab at Core Data and am starting to grok how it works.
I've built a couple of small test apps to try different configurations
of entities and relationships, and whatnot.  However, I've come up
against a snag.

Here's the layout:  I've got two entitles, "State" and "City".
"State" has one attribute, "name" (a string), and a to-many
relationship to City.  City has a name and a description (also a
string).  It has a relationship to State (not to-many) with the
inverse relationship set to the State's "cities" relationship.

I've built an interface in IB:  I have a tableView that lists all the
States, and then a tableView that lists all the cities in the selected
state.  However, when I try to add a textfield that's bound to
CitiesArrayController.selection.description, I get an exception
thrown.  The printout in the console reads:
CoreData Test 3[16798:10b] An uncaught exception was raised
CoreData Test 3[16798:10b] Cannot create BOOL from object ( ) of class NSCFArray
CoreData Test 3[16798:10b] *** Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'Cannot create
BOOL from object ( ) of class NSCFArray'

The stack trace reveals:
#0  0x94facff4 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ ()
#1  0x917310fb in objc_exception_throw ()
#2  0x94facf2b in +[NSException raise:format:arguments:] ()
#3  0x94facf6a in +[NSException raise:format:] ()
#4  0x92442c50 in _NSHandleBindingException ()
#5  0x91fdd12f in _NSBoolFromValue ()
#6  0x91fdcb06 in -[NSEditableBinder
_setStatesImmediatelyInObject:mode:triggerRedisplay:] ()
#7  0x91fdc9b1 in -[NSEditableBinder
_observeValueForKeyPath:ofObject:context:] ()
#8  0x91fd9e77 in -[NSBinder _performConnectionEstablishedRefresh] ()
#9  0x91fd20e8 in -[NSObject(NSKeyValueBindingCreation)
bind:toObject:withKeyPath:options:] ()
#10 0x9200e71e in -[NSNibBindingConnector establishConnection] ()
#11 0x91de5aa4 in -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] ()
#12 0x91ddbe12 in loadNib ()
#13 0x91ddb774 in +[NSBundle(NSNibLoading)
_loadNibFile:nameTable:withZone:ownerBundle:] ()
#14 0x91ddb3b7 in +[NSBundle(NSNibLoading)
loadNibFile:externalNameTable:withZone:] ()
#15 0x91ddb2f5 in +[NSBundle(NSNibLoading) loadNibNamed:owner:] ()
#16 0x91ddafa4 in NSApplicationMain ()
#17 0x2594 in main (argc=1, argv=0xb67c) at
/Users/dave/Developer/Cocoa/CoreData Test 3/main.m:13

Any ideas why adding the description field and binding it to the
selection.description might be related to this error?  Or perhaps I'm
looking in the wrong spot?

Any insight is greatly appreciated.  =)

Thanks!

Dave DeLong
___

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

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

2008-07-29 Thread Ken Thomases

On Jul 29, 2008, at 10:19 PM, Bill Bumgarner wrote:

It isn't fixed in the 32 bit runtime because we couldn't figure out  
a way to do so that both preserved binary compatibility and used a  
finite amount of memory / CPU.


Well, there's always 6-way Universal binaries.  ;P

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: private methods and variables

2008-07-29 Thread Bill Bumgarner

On Jul 29, 2008, at 8:41 PM, Ken Thomases wrote:

On Jul 29, 2008, at 10:19 PM, Bill Bumgarner wrote:
It isn't fixed in the 32 bit runtime because we couldn't figure out  
a way to do so that both preserved binary compatibility and used a  
finite amount of memory / CPU.


Well, there's always 6-way Universal binaries.  ;P


Heh -- true enough -- but it is hard to justify the cost of mapping in  
yet-another-complete-set-of-system dylibs for such purposes.


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: Simple Core Data Question

2008-07-29 Thread Dave DeLong
Well, after trying again (for the third time), it suddenly started
working and I have no idea why.  My ego doesn't want me to admit that
I was binding to the wrong view, but I'll bet that's what it was.

Thanks anyway!

Dave
___

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

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

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

This email sent to [EMAIL PROTECTED]


CSV parsing (large files)

2008-07-29 Thread Jacob Bandes-Storch
I've got several large-size CSV files (a total of about 1.25 million  
lines, and an average of maybe 10 or so columns) that I want to parse  
into a 2D array. I found some parsing code that uses NSScanner, and it  
works fine with small files, but it's very resource-intensive and slow  
with large files. Should I try and optimize it more, or try using C  
instead of Objective-C for parsing, or what?


The ultimate goal here is to convert the CSV files into a SQLite  
database. Should I even be doing it this way? Maybe just one row into  
the database at a time? I'd like to hear people's opinions. Thanks in  
advance!

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: CSV parsing (large files)

2008-07-29 Thread Simone Tellini


Il giorno 30/lug/08, alle ore 06:55, Jacob Bandes-Storch ha scritto:

I've got several large-size CSV files (a total of about 1.25 million  
lines, and an average of maybe 10 or so columns) that I want to  
parse into a 2D array. I found some parsing code that uses  
NSScanner, and it works fine with small files, but it's very  
resource-intensive and slow with large files. Should I try and  
optimize it more, or try using C instead of Objective-C for parsing,  
or what?


The ultimate goal here is to convert the CSV files into a SQLite  
database. Should I even be doing it this way? Maybe just one row  
into the database at a time? I'd like to hear people's opinions.  
Thanks in advance!


for that kind of job, I'd stick to C, probably using strtok().

Keep a prepared SQLite insert statement and reuse it for all the  
lines, binding the parameters for each line. Don't load the whole file  
in memory: it's just a waste of memory and time to allocate it.  
Instead parse a line at a time.


Also, you might want to issue "PRAGMA synchronous = NORMAL" or "PRAGMA  
synchronous = OFF" before everything else (look at its meaning at http://www.sqlite.org/pragma.html)


--
Simone Tellini
http://tellini.info



___

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

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