Re: wasting space?

2008-10-04 Thread Quincey Morris

On Oct 4, 2008, at 16:39, Thomas Schönfeld wrote:

I used the "example", but the "extra" method setoutString is kinda  
useless. After a bit thinking I did this (see below). I didn't  
use the "extra" method and it works fine. So my question is, did I  
just do something not-Cocoa-like and am I still thinking to much C?  
Did i found a better/shorter way or did I made a fundamental mistake?

...
	[outtextField setStringValue:[NSString stringWithFormat: @"%d", 
[userString length]]];


I don't think you've done anything wrong, nor was the 'setOutString'  
approach wrong either (since it "conveniently" logged the string too).


However, if you're interested in code brevity, then this is shorter  
and should produce the same results:


[outtextField setIntValue: [userString length]];

or, in Objective-C 2.0 syntax:

outtextField.intValue = userString.length;

which seems, to me at least, quite a lot easier to read than what you  
started with.


It's worth noting that this whole approach (setting a field in the  
user interface), though not wrong, is rather un-Cocoa-like. It would  
be much more usual to define the count of characters as a numeric  
property (for example), and bind the text field to it, using a numeric  
formatter to format the number if you wished. But perhaps you are  
still a couple a chapters away from using bindings.



___

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

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

2008-10-04 Thread Jens Beuckenhauer

Hello,

I have created a project in that I found a memory leak. The leak  
seems to be located in a XIB file?!?


In the XIB file 'MainView' is an ImageView that shows an image file  
(TIFF file) that is set via the IB inspector panel. In no way is  
the ImageView connected via an outlet or action with any of my  
classes. If I delete this ImageView the only memory leak in my  
project is gone.



You mention that you've found a memory leak, but not what type of  
memory / object that you're leaking. Could you clarify? It would  
also be interesting to know how you find memory leaks.


I use Xcode and Instruments to find the memory leaks. I start the  
application with "Run with performance tool (leaks)" and check the  
leaks instrument. For finding all memory leaks, I try to use to my  
applicaion in a way, so that all pieces of my code get called. This  
takes a bit of time, but shows me, that my entire code is leak free,  
except one leak that will be automatically be generated in the  
starting process of the application.


THE LEAK: It is a "GeneralBlock-48", of Event Type "Malloc" in  
"libTIFF.dylib". The responsible caller is "setByteArray". The library  
and "setByteArray" are not implemented by my self (so it must be Apple  
stuff).
And as said: I can comment out all possible things of my code with /*  
xxx */ , so that my application has nearly no function and the leak is  
there. I can delete every object in IB except for the ImageView and  
the leak is also there.
But: If I simply delete the ImageView the leak is gone. Adding another  
ImageView also works leak free. But in the moment I set the image to  
"mainimage.tiff" via the inspector panel, the leak is back.


And: I checked with a fresh projekt only having an ImageView with an  
image. Surely there is NO leak... So it must be something with my  
project.


Help would be great, because I don't know what to do...

Jens
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Can I put UTIs in NSFilesPromisePboardType promise drag array?

2008-10-04 Thread Nathan Vander Wilt


On Oct 4, 2008, at 8:31 PM, Jim Correia wrote:


On Oct 4, 2008, at 10:45 PM, Nathan Vander Wilt wrote:

HFS types seem to be well deprecated in nearly every other area,  
the drag destination guides don't encourage checking the types anyway


Can you post a reference?

You generally should check the type in the drag, and not offer to  
accept a drag which you can't accept.


As to HFS types being deprecated, the documentation at http://developer.apple.com/documentation/Carbon/Conceptual/understanding_utis/understand_utis_intro/chapter_1_section_1.html 
 says they were "originally designed for Mac OS 9 and earlier".


Beyond that, I think I'll have to mostly concede this point. You are  
right that the HIG encourages rejecting drags based on file types  
(though in the case of a non-promise drag this can take an extremely  
non-deterministic amount of time). For what it's worth, the sample  
code at http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/Tasks/DraggingFiles.html 
 does not check types, but the text above does mention "The  
destination can then accept or reject a drag operation based on the  
contents of the types array."



and the API itself doesn't facilitate easy checking especially  
given the fact that strings already are *either* extensions or  
legacy type codes with no programmatic distinction.


Due to the convention for how HFS types are encoding, it is possible  
to programatically distinguish the two, if you need to do so.


I'm not sure what you mean here. The documentation for promise drags  
says to encode the OSType using NSFileTypeForHFSTypeCode() which in my  
testing just turns the "characters" the programmer sees in their  
source into a string (ie 'uint' becomes @"uint"). As extensions could  
be any number of characters, how would I know if "docx" is the  
exension of a new Office document or maybe some old OSType code  
registered decades ago for a totally different format?




Plus who really wants to keep comparing strings (eg 'txt' vs. 'TXT'  
vs. 'TEXT' times every other supported format) when they could be  
using UTTypeConformsTo instead? :-)


Nobody really wants to keep supporting legacy standards when there  
are new better ones. However, if you want to interoperate with stuff  
which uses those legacy standards, you have to.


Until such time as NSPasteboard does implicit translation of UTIs  
put in NSFilesPromisePboardType, any client only expecting to see  
traditional types might fail. Only you can decide if you need to  
interoperate with such clients.


As it turns outs, I've hedged my bets. I conservatively only put  
traditional types when writing NSFilesPromisePboardType, but  
correctly handle UTIs when receiving the drag. I don't know how many  
other clients are as flexible.


What initially bothered me about the lack of UTI support was that I  
have no idea what the HFS types were, except for 'GIFf' and 'TEXT'  
which show up as canonical OSType examples throughout the docs. Of  
course, since I can use extensions that's mostly a a non-issue, though  
I do wonder what I'd do if another app gives me HFS types instead of  
extensions. You're probably right, though, if I'm the only one putting  
UTI strings into the promise array it might as well be haiku or ASCII  
art instead.


thanks,
-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: Best way to implement a "dynamic" panel

2008-10-04 Thread Jerry Krinock


On 2008 Oct, 04, at 10:07, Andreas Eriksson wrote:


I'm wondering what's the best way to implement a panel with a very
dynamic layout, similar to the iCal panel used to edit events? I need
the panel to resize, and other controls to move as other controls are
inserted, removed, or resized.


Well, I don't know if it's the ^best^ way, but I've written a custom  
"alert" window which does this.  As far as the dynamic layout, before  
invoking -display, it starts at x=0, adds a margin, then marches  
across, setting the x-origin of each subview.  Then it does the same  
thing on the y-axis.  It is quite brute-force, but it works.  Does  
anyone know a better way?


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: premature dealloc of the datasource of a NSTableView crashes my application

2008-10-04 Thread Michael Ash
On Sat, Oct 4, 2008 at 4:01 PM, Dr. Rolf Jansen <[EMAIL PROTECTED]> wrote:
> Mac OS X 10.5.5, Xcode 3.1.1, PowerBook G4.
>
> I have developed a Document Based Cocoa application, and the main document
> window contains a simple datasource based NSTableView. After I recently
> re-built everything with Xcode 3.1.1, my application crashes when I close
> any document window. Everything document, datasource, tableview are
> instantiated in the NIB file that is owned by the document object.
>
> It took me some time to find out what is going on, anyway I am quite sure
> that the reason for the crash is a premature dealloc of the datasource of
> the NSTableView, in the course of closing the document window. In order to
> prevent my application from crashing, I overwrote -[NSObject dealloc] of the
> datasource to the following:
>
> - (void)dealloc
> {
>   return;
>   [super dealloc]; // this prevents the warning that
> }   // [super dealloc] is not called.
>
>
> Unbelievable, but true - I checked this several times, that this prevents my
> application from crashing.

Not sure why you think this is unbelievable. Unlike in some other
languages, memory allocation and deallocation in Objective-C are
regular messages just like any other. Here, you are intercepting the
-dealloc method and preventing it from getting to the NSObject
implementation of it, which is where it actually destroys your object.
So your object never gets destroyed, and your app never crashes. Of
course this is a terrible workaround because generally you want
objects to go away eventually.

> - what determines the order of dealloc of
>  NIB instances once a document closes?

A lot of complicated things that you shouldn't rely on. (Basically it
will depend on exactly what's retaining everything and in what order
things get released, which in turn can depend on things like hash
table ordering.)

> - is it possible that this order changed
>  somehow between Xcode 3.1.1 and Xcode 3.1

It's possible that this order changed somehow between one run of your
app and the next! Do not rely on it.

> - can I set the dealloc sequence somehow myself,
>  e.g. by dragging the objects of the NIB
>  into a certain order?

Absolutely not. Write your code to work with any order. In this case,
what you should do is write your data source to nil out the table's
reference to it when it goes away:

- (void)dealloc {
[tableView setDataSource:nil];
[super dealloc];
}

> Probably not exactly related to this, I experience another issue of
> premature dealloc, that also occurred only recently, without changing any
> code of my application.
>
> The document has one independent main document window and it can open many
> dependent windows. When closing the main window, then the document and with
> that the dependent windows are forced to close too
> (-[MainDocWindowController setShouldCloseDocument:YES]). All of a sudden, my
> application deallocs the document object and its instances first, and then
> the dependent window objects. Also because of this my application started to
> crash, because for cleaning up, the dependent window objects are still
> needing to access some resources of the document object, that unfortunately
> has been dealloced prematurely.

If they need to access these resources then they should retain them.
If you need an object to stay alive, *make* it stay alive. Don't
assume that other bits of the system will do this for you.

> Any ideas, on how I can enforce the previous more logical dealloc sequence -
> the dependent window objects first, then the main window object, and finally
> the document object itself?

You can't.

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: Can I put UTIs in NSFilesPromisePboardType promise drag array?

2008-10-04 Thread Jim Correia

On Oct 4, 2008, at 10:45 PM, Nathan Vander Wilt wrote:

HFS types seem to be well deprecated in nearly every other area, the  
drag destination guides don't encourage checking the types anyway


Can you post a reference?

You generally should check the type in the drag, and not offer to  
accept a drag which you can't accept.


and the API itself doesn't facilitate easy checking especially given  
the fact that strings already are *either* extensions or legacy type  
codes with no programmatic distinction.


Due to the convention for how HFS types are encoding, it is possible  
to programatically distinguish the two, if you need to do so.


Plus who really wants to keep comparing strings (eg 'txt' vs. 'TXT'  
vs. 'TEXT' times every other supported format) when they could be  
using UTTypeConformsTo instead? :-)


Nobody really wants to keep supporting legacy standards when there are  
new better ones. However, if you want to interoperate with stuff which  
uses those legacy standards, you have to.


Until such time as NSPasteboard does implicit translation of UTIs put  
in NSFilesPromisePboardType, any client only expecting to see  
traditional types might fail. Only you can decide if you need to  
interoperate with such clients.


As it turns outs, I've hedged my bets. I conservatively only put  
traditional types when writing NSFilesPromisePboardType, but correctly  
handle UTIs when receiving the drag. I don't know how many other  
clients are as flexible.


- Jim
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Memory Leak in XIB file?

2008-10-04 Thread j o a r


On Oct 4, 2008, at 12:29 PM, Jens Beuckenhauer wrote:

I have created a project in that I found a memory leak. The leak  
seems to be located in a XIB file?!?


In the XIB file 'MainView' is an ImageView that shows an image file  
(TIFF file) that is set via the IB inspector panel. In no way is the  
ImageView connected via an outlet or action with any of my classes.  
If I delete this ImageView the only memory leak in my project is gone.



You mention that you've found a memory leak, but not what type of  
memory / object that you're leaking. Could you clarify? It would also  
be interesting to know how you find memory leaks.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa Programming for Mac OsX Third Edition eBook search

2008-10-04 Thread David Orriss Jr
Given how many chapters there are you'd probably use up all of your
available PDF credits that way just to get a copy of the book
(presuming you've had your account for a few months).

But yes, that's probably the only readily available option at this
point (aside from just buying a print version of the book).

On Sat, Oct 4, 2008 at 6:55 PM, Jason Stephenson <[EMAIL PROTECTED]> wrote:
> Jamie Daniel wrote:
>>
>> Anyone know where I can get the above book in eBook ?
>>
>
> If you have a Safari account (http://safari.oreilly.com/) and enough
> download tokens, you could download each chapter as a PDF. Other than that,
> I don't know how you could get a Mac-compatible copy of the book.
>
> Jason
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/codethought%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>



-- 
David Orriss Jr.

My blog: http://www.codethought.com/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]


wasting space?

2008-10-04 Thread Thomas Schönfeld

Hi.
I am new to Cocoa as well as mailing lists. So please tell me, if I am  
doing something "unpolite". And please excuse my bad writing. I am not  
a native english speaking person.


I started with "Cocoa® Programming for Mac® OS X, Third Edition" a few  
days ago. The challenges seem to be not so easy. I looked around an  
found this...

http://www.cocoabuilder.com/archive/message/cocoa/2008/7/16/213146
... for one of the challenges (chapter 5). Now I am wondering, because  
it seems to me the "example" is "wasting code". I used the "example",  
but the "extra" method setoutString is kinda useless. After a bit  
thinking I did this (see below). I didn't use the "extra" method  
and it works fine. So my question is, did I just do something not- 
Cocoa-like and am I still thinking to much C? Did i found a better/ 
shorter way or did I made a fundamental mistake?


CountController.m--
@implementation CountContoller
- (id)init
{
  if(self = [super init])  // single = is intentional
NSLog(@"-[%@ init]", [self className]);
  return self;  
}

- (IBAction)countIt:(id)sender;
{   
NSString *userString;
NSLog(@"Counting char");
userString = [intextField stringValue];
	[outtextField setStringValue:[NSString stringWithFormat: @"%d", 
[userString length]]];

}
//deleted/unused setOutString code here...
@end

CountController.h
#import 

@interface CountContoller : NSObject
{
IBOutlet NSTextField *intextField;
IBOutlet NSTextField *outtextField;
}
- (IBAction)countIt:(id)sender;
//-(void) setOutString: (NSString*)outString;

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


Memory Leak in XIB file?

2008-10-04 Thread Jens Beuckenhauer

Hello,

I have created a project in that I found a memory leak. The leak seems  
to be located in a XIB file?!?


In the XIB file 'MainView' is an ImageView that shows an image file  
(TIFF file) that is set via the IB inspector panel. In no way is the  
ImageView connected via an outlet or action with any of my classes. If  
I delete this ImageView the only memory leak in my project is gone.


If I then drop a new fresh ImageView in the XIB file there is also no  
leak. But simply setting the image via the IB inspector panel to the  
TIFF file 'regenerates' the memory leak...


Any idea what that can be?

Thanks for your help...

Jens
___

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

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

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

This email sent to [EMAIL PROTECTED]


premature dealloc of the datasource of a NSTableView crashes my application

2008-10-04 Thread Dr. Rolf Jansen

Mac OS X 10.5.5, Xcode 3.1.1, PowerBook G4.

I have developed a Document Based Cocoa application, and the main  
document window contains a simple datasource based NSTableView. After  
I recently re-built everything with Xcode 3.1.1, my application  
crashes when I close any document window. Everything document,  
datasource, tableview are instantiated in the NIB file that is owned  
by the document object.


It took me some time to find out what is going on, anyway I am quite  
sure that the reason for the crash is a premature dealloc of the  
datasource of the NSTableView, in the course of closing the document  
window. In order to prevent my application from crashing, I overwrote - 
[NSObject dealloc] of the datasource to the following:


- (void)dealloc
{
   return;
   [super dealloc]; // this prevents the warning that
}   // [super dealloc] is not called.


Unbelievable, but true - I checked this several times, that this  
prevents my application from crashing.



Questions:

- what determines the order of dealloc of
  NIB instances once a document closes?

- is it possible that this order changed
  somehow between Xcode 3.1.1 and Xcode 3.1

- can I set the dealloc sequence somehow myself,
  e.g. by dragging the objects of the NIB
  into a certain order?


Probably not exactly related to this, I experience another issue of  
premature dealloc, that also occurred only recently, without changing  
any code of my application.


The document has one independent main document window and it can open  
many dependent windows. When closing the main window, then the  
document and with that the dependent windows are forced to close too (- 
[MainDocWindowController setShouldCloseDocument:YES]). All of a  
sudden, my application deallocs the document object and its instances  
first, and then the dependent window objects. Also because of this my  
application started to crash, because for cleaning up, the dependent  
window objects are still needing to access some resources of the  
document object, that unfortunately has been dealloced prematurely.


Any ideas, on how I can enforce the previous more logical dealloc  
sequence - the dependent window objects first, then the main window  
object, and finally the document object itself?


Many thanks for any response.

Best regards

Rolf Jansen

___

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

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


Best way to implement a "dynamic" panel

2008-10-04 Thread Andreas Eriksson
Hi,

I'm wondering what's the best way to implement a panel with a very
dynamic layout, similar to the iCal panel used to edit events? I need
the panel to resize, and other controls to move as other controls are
inserted, removed, or resized.

In Qt, I guess I would use the layout classes to do this, but I can't
find anything similar in Cocoa.

Thankful for any suggestions!

Regards,

Andreas
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Can I put UTIs in NSFilesPromisePboardType promise drag array?

2008-10-04 Thread Nathan Vander Wilt

On Oct 1, 2008, at 3:09 PM, Jim Correia wrote:

On Oct 1, 2008, at 5:27 PM, Nathan Vander Wilt wrote:

I am initiating a promise drag by adding an array of strings to my  
pasteboard using for the NSFilesPromisePboardType. The  
documentation states that "the types can be specified as filename  
extensions or as HFS file types encoded [as strings]". Is there any  
reason to not build an array of UTIs instead?


I don't believe that works. I thought I filed a bug about it, but  
cannot quickly locate it.


If you find definitively one way or the other, I'd appreciate your  
discovery. (It would require special support in the pasteboard for  
translation because legacy clients would only expect the extension  
or HFS type. Even just the extension is problematic for Carbon  
clients.)


Thanks for the advice, I've taken the liberty of posting back to the  
list as well.


I haven't experimented a ton, as the Finder and iPhoto both seem to  
accept (at least initially, in the case of iPhoto) any promise drag  
regardless of what I stuff into the array, and I hadn't many ideas of  
other programs to try it on. Despite Postel's principle, I'm tempted  
to use UTIs anyway, at least until we get bug reports of our app not  
playing nicely with another.


HFS types seem to be well deprecated in nearly every other area, the  
drag destination guides don't encourage checking the types anyway, and  
the API itself doesn't facilitate easy checking especially given the  
fact that strings already are *either* extensions or legacy type codes  
with no programmatic distinction. Plus who really wants to keep  
comparing strings (eg 'txt' vs. 'TXT' vs. 'TEXT' times every other  
supported format) when they could be using UTTypeConformsTo instead? :-)


thanks,
-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]


Adding sublayer causes dropped frames?

2008-10-04 Thread Britt Durbrow

Hi -

I'm having a weird problem with Core Animation. What I've got is a  
small particle system, with one layer per particle. There are only  
10-20 particles in the system at any given time. The system updates  
the layers at 60 Hz from an NSTimer, and disables automatic animations  
during the update.


What seems to be happening is that every time a new particle is added,  
a few frames get dropped from the display (but, not the calculations).  
Logging the time delta's between timer firings shows that the timer is  
not missing firings. Turning off layer additions for new particles  
prevents the problem (i.e, the particles - with all the associated  
infrastructure, collision handling, etc - are instantiated, and added  
to the system, only the addSublayer call is skipped). It's like adding  
the layer suppresses the redraw of the view for a few cycles... ?!?


Anybody have any ideas?


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Should not use mogenerator in Mac OS 10.5+ ?

2008-10-04 Thread Jerry Krinock


On 2008 Oct, 04, at 18:08, mmalc crawford wrote:


On Oct 4, 2008, at 4:11 PM, Jerry Krinock wrote:


And although the "dynamically" generated methods are "efficient", I  
assumed that they are still not as efficient as a hard-coded method.


Why?



Why are you insisting on hanging yourself?


Thank you for the answers, mmalc.

If you don't mind, just to be clear, I'd like to rephrase your answer  
to my question of whether  I should use mogenerator in a 10.5+ project  
like this:


On 2008 Oct, 04, at 18:08, mmalc crawford meant:


 "No."


and as to my second question, "Why?"

The dynamically generated methods are at least as efficient, maybe  
more efficient, than methods generated by mogenerator.



If I got it wrong, mmalc, or if anyone read a different  
interpretation, let us know.


Jerry

___

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

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

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

This email sent to [EMAIL PROTECTED]


NSURLConnection willSendRequest: not behaving as expected on a 302 response - no further response after nil return

2008-10-04 Thread Steve Mykytyn

I'm using NSURLConnection to contact a URL that returns a 302
response along with some data, and then returns a 200 response with
some different data.  I want to stop it at the 302 response and get
the data that comes along with the 302 response.

To make this happen I understand the delegate method [NSURLConnection
connection: willSendRequest: redirectResponse:] should return nil.

To quote the documentation:

"Alternatively, the delegate method can return nil to cancel the
redirect, and the connection will continue to process. This has
special relevance in the case where redirectResponse is not nil. In
this case, any data that is loaded for the connection will be sent to
the delegate, and the delegate will receive a
connectionDidFinishLoading or connection:didFailLoadingWithError:
message, as appropriate."

Using tcpdump I can see the 302 response come back, along with the
expected data, but I never receive anything from further from
NSURLConnection after I return the nil above.  No "didReceiveData:"
or "connectionDidFinishLoading:" or
"connection:didFailLoadingWithError:" - zip, zilch, nada.

The code works fine for receiving 200 responses etc.

Suggestions please?



Slightly edited code below.

#pragma mark NSURLConnection delegate methods

- (NSCachedURLResponse *)connection:(NSURLConnection *)connection
willCacheResponse:(NSCachedURLResponse *)cachedResponse {

return nil; //  NEVER cache responses
}

- (void)connection:(NSURLConnection *)connection didReceiveData:
(NSData *)data {

@try {
if ( connection && responseData ) [responseData 
appendData:data];
}
@catch ( NSException *e ) {

NSLog(@"exception during didReceiveData: %@", e);
}
}

- (NSURLRequest *)connection:(NSURLConnection *)connection
willSendRequest:(NSURLRequest *)request redirectResponse:
(NSURLResponse *)redirectResponse {

if(redirectResponse) {

NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)
redirectResponse;   
statusCode = [httpResponse statusCode];
if (statusCode==302) newRequest = nil; // go for the first 
return only
}

return request;
}


- (void)connection:(NSURLConnection *)connection didReceiveResponse:
(NSURLResponse *)response {

@try {

NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;

statusCode = [httpResponse statusCode];

if (httpResponse) { // we know this is an NSHTTPURLResponse 
since
we sent it to an http:// URL

if (pageRequest==1) { // this is the first page request 
- which
should just get the redirect info and go from there

statusCode = [httpResponse statusCode];

if (statusCode==302) {

if( connection && responseData ) 
[responseData setLength:0];

}

}
else if (pageRequest==2) { // this is the second page 
request

statusCode = [httpResponse statusCode];

if (statusCode==200) { // success ...


if( connection && responseData ) 
[responseData setLength:0];

}
}
}
}
@catch ( NSException *e ) {

NSLog(@"exception during didReceiveResponse: %@", e);
}
}


- (void)connectionDidFinishLoading:(NSURLConnection *)connection{

@try {

NSString *tempString = [[NSString alloc] 
initWithData:responseData
encoding:NSMacOSRomanStringEncoding];

[dict setValue:responseData forKey:@"body"];
[dict setValue:tempString forKey:@"bodyString"];

[tempString release];

//  [connection release];connection=nil;
[responseData release];

}
@catch ( NSException *e ) {

NSLog(@"exception during pageRequest %d 
connectionDidFinishLoading:
%@",pageRequest, e);
}
}

___

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

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

Help/Unsubscribe/Update your S

Re: Cocoa Programming for Mac OsX Third Edition eBook search

2008-10-04 Thread Jason Stephenson

Jamie Daniel wrote:


Anyone know where I can get the above book in eBook ?



If you have a Safari account (http://safari.oreilly.com/) and enough 
download tokens, you could download each chapter as a PDF. Other than 
that, I don't know how you could get a Mac-compatible copy of the book.


Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa Programming for Mac OsX Third Edition eBook search

2008-10-04 Thread David Orriss Jr
I ran into the same thing.  Probably one of my biggest complaints
about Addison is that the ebooks they do are digitally signed and that
the ONE platform Acrobat reader doesn't support for digitally signed
ebooks (aside from a beta reader if you dig around) is the Mac.
Rather ironic given the subject matter of the book.

On Fri, Oct 3, 2008 at 11:56 AM, Jamie Daniel <[EMAIL PROTECTED]> wrote:
> Greetings,
> Does anyone know where I can find / get the "Cocoa Programming for Mac OsX 
> Third Edition" in eBook. I have a trip I am going on and I would like to take 
> a few books with me - in eBook for space of course.
>
> it seems every place I find wants me to read it online - or download their 
> stupid reader, which doesn't support OS X 10.5
>
> I find that stupid. A book about Mac programming, not supported on a Mac.
>
> But I digress.
>
> Anyone know where I can get the above book in eBook ?
>
> Thanks,
> Jamie
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/codethought%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>



-- 
David Orriss Jr.

My blog: http://www.codethought.com/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: Should not use mogenerator in Mac OS 10.5+ ?

2008-10-04 Thread mmalc crawford


On Oct 4, 2008, at 4:11 PM, Jerry Krinock wrote:
So, I don't ^need^ mogenerator, although I still may want to use it  
in order to get type checking and generate code needed to avoid  
compiler warnings.




Why?  You get type checking and avoid compiler warnings by following  
the recommendations in the Programming Guide.



And although the "dynamically" generated methods are "efficient", I  
assumed that they are still not as efficient as a hard-coded method.



Why?

[3] This "Well, if you insist on hanging yourself.." idiom is  
familiar to me in reading Apple documentation.



Why are you insisting on hanging yourself?

mmalc

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Can't bind image cells in a table to file's owner?

2008-10-04 Thread Ken Tozier


On Oct 4, 2008, at 8:16 PM, Quincey Morris wrote:

After you choose File's Owner from the popup, and type the model key  
in the text field below, press Return or Tab, and verify that the  
check mark next to File's Owner has become checked. If you click  
away without committing the edit, the changes are lost.


That's what I was doing. In desperation, I deleted all the controllers  
and linked the gui objects directly to file's owner and for some  
reason it all started to work perfectly. What is it about a controller  
that could cause this failure when directly linking works? I tried  
setting the controller content both through an option-drag and through  
bindings, no luck.


Although I have it working for the short term, I'd like to "do  
bindings right" by using controllers. Any Ideas?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Can't bind image cells in a table to file's owner?

2008-10-04 Thread Quincey Morris

On Oct 4, 2008, at 15:59, Ken Tozier wrote:

... I can't bind any controllers to file's owner. I can bind some of  
the gui object values directly to files owner but controllers always  
unbind spontaneously whenever I click on another object in the  
interface and back to the controller. What could be causing this?  
I'm at my wit's end.


After you choose File's Owner from the popup, and type the model key  
in the text field below, press Return or Tab, and verify that the  
check mark next to File's Owner has become checked. If you click away  
without committing the edit, the changes are lost.



___

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

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


Should not use mogenerator in Mac OS 10.5+ ?

2008-10-04 Thread Jerry Krinock
When developing NSManagedObjects for Mac OS 10.4, after about 25 trips  
to Xcode's menu Design > Data Model > Copy Method -tions to  
Clipboard, my wrist got sore and I started using mogenerator [1].


Now, developing for Mac OS X 10.5+, I read that "On Mac OS X v10.5,  
Core Data dynamically generates efficient public and primitive get and  
set attribute accessor methods and relationship accessor methods for  
managed object classes."


So, I don't ^need^ mogenerator, although I still may want to use it in  
order to get type checking and generate code needed to avoid compiler  
warnings.  And although the "dynamically" generated methods are  
"efficient", I assumed that they are still not as efficient as a hard- 
coded method.  But then, further down, in two highlighted "dire  
warning" boxes, I read ...


"Important: You are strongly encouraged to use dynamic properties  
(that is, properties whose implementation you specify as @dynamic)  
instead of creating custom implementations for standard or primitive  
accessor methods."


But I don't see any reasons given.  Paradoxically these boxes seemed  
to be followed by instructions detailing how to do what was just  
recommended against doing [3], including code examples of standard  
accessors which look like what I get out of mogenerator.


My questions: Am I being "strongly encouraged" to ^not^ use  
mogenerator in a 10.5+ app?  Why?


Thanks,

Jerry Krinock

[1] http://rentzsch.com/code/mogenerator_v1.5  (Be sure to use the  
installer, don't just build the tool.)


[2] In "Core Data Programming Guide" > "Managed Object Accessor Methods"
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html#/ 
/apple_ref/doc/uid/TP40002154


[3] This "Well, if you insist on hanging yourself.." idiom is familiar  
to me in reading Apple documentation.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Can't bind image cells in a table to file's owner?

2008-10-04 Thread Ken Tozier
After two more hours of futzing, I find that I can't bind any  
controllers to file's owner. I can bind some of the gui object values  
directly to files owner but controllers always unbind spontaneously  
whenever I click on another object in the interface and back to the  
controller. What could be causing this? I'm at my wit's end.




On Oct 4, 2008, at 4:56 PM, Ken Tozier wrote:


Hi

My file's owner class has a method to return a file icon but I'm  
finding that when I do the following, it reverts back to "shared  
user defaults" whenever I select other things in the user interface.


Here are my bind settings

Value
Bind to: file's owner
Model Key Path: fileIcon

and here's the accessor method
- (NSImage *) fileIcon;

How come this won't stick?

Thanks for any help

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSGlyph

2008-10-04 Thread Graff

On Oct 4, 2008, at 11:59 AM, hatzicware wrote:


I can't figure out how NSGlyph works in methods like this:

[path appendBezierPathWithGlyph:'x' inFont:[NSFont userFontOfSize:
14.0]]

(Of course 'path' is an NSBezierPath.)

What I get on the screen is not an '+', but an upper-case "H" in some
outline font. And when I put in explicit Unicodes, I don't get the
expected symbol either.

NSGlyph is declared as an unsigned int. But how is it connected to
displayed characters?



You need to use the NSFont method -glyphWithName:

NSFont *aFont = [NSFont userFontOfSize:14.0];

[path appendBezierPathWithGlyph:[aFont glyphWithName:@"plus"]
 inFont:aFont];

NSGlyph is just an unsigned int that represents the index of the glyph  
in that font.  In order to get that index you need to use  
glyphWithName.  However, this requires you to know the actual name of  
the glyph, not what character it represents.  For example the glyph  
name for "+" is "plus".


If you are just trying to draw text then easiest thing to do is use  
one of the NSString draw methods.  If you really need the text as a  
path then you should read this section of the Cocoa Drawing Guide:




___

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

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


Can't bind image cells in a table to file's owner?

2008-10-04 Thread Ken Tozier

Hi

My file's owner class has a method to return a file icon but I'm  
finding that when I do the following, it reverts back to "shared user  
defaults" whenever I select other things in the user interface.


Here are my bind settings

Value
Bind to: file's owner
Model Key Path: fileIcon

and here's the accessor method
- (NSImage *) fileIcon;

How come this won't stick?

Thanks for any help

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Class Extensions (Re: Clueless about this warning)

2008-10-04 Thread Bill Bumgarner

On Oct 4, 2008, at 12:43 PM, Andrew Merenbach wrote:

On Oct 4, 2008, at 10:32 AM, Bill Bumgarner wrote:
Class extensions are also the one place where you can redeclare  
that a property is readwrite.


Hi! Â Bill makes a very well-written explanation, but I beg to  
append (in a very nit-picky fashion) to this point, if only for the  
sake of the archives. Â If one visits , one sees (under "Property Re-declaration") that:


If you declare a property in one class as readonly, you can  
redeclare it as readwrite in a class extension (see  
“Extensions”), a protocol, or a subclass


Correct.  Protocols and subclasses enable different behaviors from  
extensions.


Specifically --  a protocol effectively indicates that your class will  
implement some set of required or optional methods with the additional  
benefit of adding a bit of compile time and runtime accessible  
metadata to the class that says that it conforms to that protocol.


A subclass can override the readonly declaration of a property such  
that you can create immutable superclass / mutable subclass type  
relationships akin to various Foundation classes.


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: NSOutlineView assertion failures

2008-10-04 Thread Jeff Wilcox
Thanks Chris, see my last reply to myself.  I basically ended up doing  
what you are describing at found that this works.  Your explanation  
makes it a bit clearer as to why though.


Jeff

On Oct 4, 2008, at 1:00 PM, Chris Hanson wrote:


On Oct 3, 2008, at 10:48 PM, Jeff Wilcox wrote:

Not explicitly, but maybe.  This seems to be taking place when the  
content for the NSTreeController is changing (explicitly) in one  
thread, causing a reload in the outline view,  and in another  
thread the NSOutlineView's drawrect is getting called.  I can't say  
for sure that this accounts for all of the cases but that seems  
like a common theme.


Thoughts?


Don't do that.

You cannot change model or controller objects that are bound to in a  
thread other than the main thread and expect things to work.  The  
reason you can't is that Key-Value Observer notifications (the  
foundation of bindings) are posted *around* the change,  
synchronously, in the thread which is performing the change.


It looks like you're trying to force it to work by adding  
@synchronized blocks, but they're insufficient to do so.  This is  
because Cocoa doesn't provide the necessary hooks into NSTableView,  
NSTreeController or the bindings machinery where you could lock at  
every point you'd need to.


Ultimately, you need to accumulate the changes to make on your  
background thread, and then push them to the main thread to actually  
be applied.  If you're using Core Data and the SQLite persistent  
store this is straightforward because each thread can use its own  
managed object context atop the same coordinator, and saving in the  
background thread will generate a notification that you can use to  
inform the foreground thread to update.


 -- Chris



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSOutlineView assertion failures

2008-10-04 Thread Chris Hanson

On Oct 4, 2008, at 12:37 PM, Jeff Wilcox wrote:

I played around with what Uli seemed to be hinting at, and indeed it  
does seem that NSOutlineView is not particularly thread safe.


It's not a matter of whether a facility "seems" thread-safe.

In Cocoa, the rule is very simple:

  If it's not documented as being thread-safe, assume it's not.

The best thing to do is read the Cocoa threading guide.

  -- Chris


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSOutlineView assertion failures

2008-10-04 Thread Chris Hanson

On Oct 3, 2008, at 10:48 PM, Jeff Wilcox wrote:

Not explicitly, but maybe.  This seems to be taking place when the  
content for the NSTreeController is changing (explicitly) in one  
thread, causing a reload in the outline view,  and in another thread  
the NSOutlineView's drawrect is getting called.  I can't say for  
sure that this accounts for all of the cases but that seems like a  
common theme.


Thoughts?


Don't do that.

You cannot change model or controller objects that are bound to in a  
thread other than the main thread and expect things to work.  The  
reason you can't is that Key-Value Observer notifications (the  
foundation of bindings) are posted *around* the change, synchronously,  
in the thread which is performing the change.


It looks like you're trying to force it to work by adding  
@synchronized blocks, but they're insufficient to do so.  This is  
because Cocoa doesn't provide the necessary hooks into NSTableView,  
NSTreeController or the bindings machinery where you could lock at  
every point you'd need to.


Ultimately, you need to accumulate the changes to make on your  
background thread, and then push them to the main thread to actually  
be applied.  If you're using Core Data and the SQLite persistent store  
this is straightforward because each thread can use its own managed  
object context atop the same coordinator, and saving in the background  
thread will generate a notification that you can use to inform the  
foreground thread to update.


  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Class Extensions (Re: Clueless about this warning)

2008-10-04 Thread Andrew Merenbach


On Oct 4, 2008, at 10:32 AM, Bill Bumgarner wrote:

Class extensions are also the one place where you can redeclare that  
a property is readwrite.


Hi!  Bill makes a very well-written explanation, but I beg to append  
(in a very nit-picky fashion) to this point, if only for the sake of  
the archives.  If one visits , one sees (under "Property Re-declaration") that:


If you declare a property in one class as readonly, you can  
redeclare it as readwrite in a class extension (see “Extensions”), a  
protocol, or a subclass



Cheers,
Andrew


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: NSOutlineView assertion failures

2008-10-04 Thread Jeff Wilcox
I played around with what Uli seemed to be hinting at, and indeed it  
does seem that NSOutlineView is not particularly thread safe.  If you  
update the content for the NSTreeController that is the data source  
for the outline view outside of the main thread it blows up as I  
described, and does so pretty consistently.  Once I forced the update  
to be done only on the main thread the issue went away.


Jeff

On Oct 3, 2008, at 10:48 PM, Jeff Wilcox wrote:

Not explicitly, but maybe.  This seems to be taking place when the  
content for the NSTreeController is changing (explicitly) in one  
thread, causing a reload in the outline view,  and in another thread  
the NSOutlineView's drawrect is getting called.  I can't say for  
sure that this accounts for all of the cases but that seems like a  
common theme.


Thoughts?

On Oct 3, 2008, at 6:10 PM, Uli Kusterer wrote:


On 04.10.2008, at 03:00, Jeff Wilcox wrote:
I seemed to be able to make this go away by subclassing the  
outline view and locking it down before starting a reload or  
evaluating the number of rows (found mostly by lots or trial and  
error) with the following:



Wait, you're not calling numberOfRows and reloadData on an outline  
view from another thread, are you?


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de







___

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

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

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

2008-10-04 Thread James Maxwell

Thanks, Keary.

I eventually found the article you linked me to and worked it out. I  
think I've done everything correctly, in that I am pointing the  
"choices" to an array of objects, and using the "name" property to  
display in the popup... It seems to be okay, but I won't really know  
until I get it properly connected to a testable build (it works  
graphically, but I can't be certain it's actually selecting the right  
thing). Thanks for the tip, though!


But I've got an even more mysterious problem now... My preferences  
window (the window I was working on) will only open once!... I'm  
totally baffled. I can open it once per run of the app, but if I close  
it, then it's gone for good. Totally frustrating...
I have to admit that I kind of dread opening Interface Builder. I  
enjoy graphically creating interfaces with it, but I find the  
"connections" to my code totally confusing. If you have any ideas (or  
if anyone else has) as to why my preferences window appears only once  
please give me a heads-up. I'm in absolute disbelief! :-|


cheers,

J.


On 4-Oct-08, at 11:03 AM, Keary Suska wrote:



On Oct 3, 2008, at 2:17 PM, James Maxwell wrote:

This doesn't seem like a big deal, but I'm pretty confused. I want  
to set this up using bindings, but I'm note sure how I populate the  
popup in column 2, and I'm also unclear on who manages storing the  
index of the popup selection? Do I need to have a method to handle  
this in my XObject class, or is this something NSArrayController  
does?



A popup in a table cell is handled much the same as a standard  
NSPopupButton. Although I hope you have already read "Cocoa Bindings  
Programming Topics" completely, here is a link to the specific  
section that addresses your need: 


What you need to determine up front is what value or object  
represents the "key" to the relationship between the column 2 value  
and the "choices". I do not recommend using anything based on the  
arrangement of items, such as selection index, as the approach isn't  
extensible. Remember that this key must be a unique object, and that  
every data row must use the same object for its equivalent value.  
This is really important, and is an issue not easily gleaned from  
the documentation: the object used in your data row as the value  
must be the exact same object as is found in the "choices" array.  
Being equal is not sufficient.


HTH,

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



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: file fixtures for unit testing

2008-10-04 Thread Chris Hanson

On Oct 4, 2008, at 3:59 AM, Colin Barrett wrote:

On Fri, Oct 3, 2008 at 10:01 PM, Brent Hargrave  
<[EMAIL PROTECTED]> wrote:
To unit test an XML parsing method, I would like keep a dummy XML  
file in a
project directory and import it into my FooTests class as a fixture  
of

sorts.  What is the right way to do this sort of thing?


Add it to the project, and then add it to the test's target. You
should then be able to reference it using -[NSBundle
pathForResource:ofType:]. I'm not 100% that's the way OCUnit/SenTest
targets work, but it would surprise me if they worked otherwise.


That is the way they work.

Remember that in a non-main bundle, you'll probably want to use  
something like [NSBundle bundleForClass:[self class]] rather than  
[NSBundle mainBundle] to get the bundle to load a resource from.


 -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSGlyph

2008-10-04 Thread Douglas Davidson


On Oct 4, 2008, at 11:59 AM, [EMAIL PROTECTED] wrote:


I can't figure out how NSGlyph works in methods like this:

	[path appendBezierPathWithGlyph:'x' inFont:[NSFont userFontOfSize: 
14.0]]


(Of course 'path' is an NSBezierPath.)

What I get on the screen is not an '+', but an upper-case "H" in  
some outline font. And when I put in explicit Unicodes, I don't get  
the expected symbol either.


NSGlyph is declared as an unsigned int. But how is it connected to  
displayed characters?


You should take a look at some of the text system conceptual  
documentation, such as http://developer.apple.com/documentation/Cocoa/Conceptual/TextLayout/TextLayout.html 
.


Glyph are not characters, and in general they do not have a simple  
relationship to characters.  A glyph is an individual displayable  
element in a particular font, and its numerical value is an index into  
the font's glyph repertoire; this numerical value does not in general  
have meaning outside of the context of that particular font.


The Cocoa text system converts characters into glyphs as needed for  
text display; in general, NSLayoutManager manages this process, with  
the help of two auxiliary classes, NSGlyphGenerator and NSTypesetter.   
The first of these performs a first-pass conversion of characters to  
glyphs, while the second makes any contextual adjustments that are  
necessary as the text is laid out.  The final mapping between glyphs  
and characters need not be one-to-one; for example, even with Latin- 
script text, in many fonts the two characters "fi" will be represented  
by a single "fi" ligature glyph.  Other scripts, or specialized fonts,  
can produce much more complicated character-glyph mappings.


Try taking a look at the "SpeedometerView" example on  
developer.apple.com.  It includes among other things a mechanism for  
producing bezier paths from arbitrary text, in the SpeedyCategories.m  
file.


Douglas Davidson

___

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

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

2008-10-04 Thread hatzicware

Sorry, that method should have looked like this:

	[path appendBezierPathWithGlyph:'+' inFont:[NSFont userFontOfSize: 
14.0]]




On 4 Oct, 2008, at 11:59, [EMAIL PROTECTED] wrote:


I can't figure out how NSGlyph works in methods like this:

	[path appendBezierPathWithGlyph:'x' inFont:[NSFont userFontOfSize: 
14.0]]


(Of course 'path' is an NSBezierPath.)

What I get on the screen is not an '+', but an upper-case "H" in  
some outline font. And when I put in explicit Unicodes, I don't get  
the expected symbol either.


NSGlyph is declared as an unsigned int. But how is it connected to  
displayed characters?



___

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

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


NSGlyph

2008-10-04 Thread hatzicware

I can't figure out how NSGlyph works in methods like this:

	[path appendBezierPathWithGlyph:'x' inFont:[NSFont userFontOfSize: 
14.0]]


(Of course 'path' is an NSBezierPath.)

What I get on the screen is not an '+', but an upper-case "H" in some  
outline font. And when I put in explicit Unicodes, I don't get the  
expected symbol either.


NSGlyph is declared as an unsigned int. But how is it connected to  
displayed characters?


dkj
___

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

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

2008-10-04 Thread Brad Gibbs
I had no knowledge of or experience with programming when I started  
last April.  I started with Kochan's Objective-C book, then Hillegass  
Third Edition, then XCode Unleashed.  That happened to be the order in  
which they were released, but it was a good way to go -- I felt one  
led right into the other.


Safari has a beta version of Objective-C 2.0 available now as a PDF.   
It's not complete, but there's enough there to make it worth a look.


Also, Pragmatic Programmer's has a beta version of Cocoa Programming:  
A Quick Start Guide for Developers.  I think you'd still want to be  
familiar with Kochan's material before starting this book, but you  
might read through it before starting Hillegass to get a 50,000-ft  
view of Cocoa before diving down to the 10,000-ft. view offered in  
Hillegass.  XCode Unleashed gets further down into the mechanics of  
XCode, version control, etc.


Apple's documentation and sample code are helpful, but, for me, I  
needed a good understanding of Kochan's material and some of Hillegass  
before Apple's documentation made any sense, even the conceptual docs  
on Objective-C 2.0 or Cocoa.


I'd like to find a good book on object-oriented design and how to go  
about designing classes, etc., if anyone has any ideas...




On Oct 4, 2008, at 6:12 AM, Jason Stephenson wrote:


Rob Keniger wrote:

On 04/10/2008, at 9:46 AM, mmalc crawford wrote:
Start with Programming in Objective-C by Stephen Kochan (depending  
on how quickly you want to get underway, you may consider waiting  
for the second edition):




I totally agree with mmalc, this is the first book you should buy.  
Despite what others have said, I highly recommend that you do NOT  
start with Kernigan and Richie, it's simply not the best learning  
tool for getting into Mac programming. K&R is extremely dry and  
although it teaches you plain C, you don't need to know most of the  
stuff in that book to write good Objective-C.
Stephen Kochan's book teaches you everything you need to know about  
programming in Objective-C, including the bits of the C language  
you need to know and none of the bits you don't. It is also one of  
the most well-written technical books I have ever read.


Ditto.

Plus, I'd like to add that Kochan also introduces you to the basic  
programming concepts along the way. He doesn't just teach the  
language or the Objective-C idioms, but several chapters discuss  
things like basic data types and looping. So, you'll not learn just  
Objective-C the language, but you'll get a fairly decent  
introduction to the basics to be an effective programmer in any  
language.


Kernighan and Ritchie don't do this in their small book. They assume  
you already know the basics of programming, and they are only  
interested in introducing you to the C language. It would help to  
have some basic programming knowledge: data structures, looping,  
recursion, etc. *before* reading K&R.


I've never read it, but I imagine that the book on C by Kochan (http://search.barnesandnoble.com/Programming-in-C/Stephen-G-Kochan/e/9780672326660/?itm=1 
) is equally as good as his book on Objective-C.



Once you've read the Kochan book you should get Aaron Hillegass'  
"Cocoa Programming for Mac OS X", which goes beyond the Objective-C  
language to teach you the mechanics of working with the Cocoa  
frameworks.



Ditto, and Fritz Anderson's Xcode Unleashed is another good choice  
for a second or third book. It covers the Xcode 3 programming  
environment in a bit more detail than Hillegass's book, and has some  
excellent chapters on using libraries and private frameworks.


Jason
___

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

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

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


Class Extensions (Re: Clueless about this warning)

2008-10-04 Thread Bill Bumgarner

On Oct 4, 2008, at 7:49 AM, Jonathan del Strother wrote:

To avoid those warnings, the method declaration or definition needs to
appear before it's used. Â I usually add a private category at the top
of my .m files where you can declare private methods - something like
this :

@interface BigLetterView ()
- (void)prepareAttributes;
@end


Exactly the correct solution.

But a bit of clarification.

What you have declared is not really a category.  It is an extension  
to the class BigLetterView.


If you were to change it to:

@interface BigLetterView ()
- (void)prepareAttributes;
- (void)foobarbaz;
@end

The compiler would complain about the lack of the implementation of - 
foobarbaz in class BigLetterView.


However, if you had declared the above as a category:

@interface BigLetterView (MySuperSecretSauce)
- (void)prepareAttributes;
- (void)foobarbaz;
@end

The compiler would *not* complain (unless you used '@implementation  
BigLetterView (SuperSecretSauce)' to encapsulate the implementation).


That is, class extensions let you privately declare a set of methods  
that *must* be implemented in the @implementation for the class.  They  
are specifically designed to enable the compiler to more retentively  
check that you have implemented what you said you would implement.


Class extensions are also the one place where you can redeclare that a  
property is readwrite.  If you wanted to declare that a property was  
publicly readable, but you want it to be readwrite internally, and you  
want to take advantage of method (and iVar on Modern ABI) synthesis,  
you would:


@interface BigLetterView: NSObject
@property(readonly) NSString *label;
@end

@interface BigLetterView
@property(readwrite) NSString *label;
@end

@implementation BigLetterView
@synthesize label; // synthesizes both -label and -setLabel:
@end

Note that the above assumes modern ABI (64 bit & iPhone Objective-C  
2.0 runtimes) and that you are compiling in GC only mode (otherwise,  
the compiler will complain that you didn't specify a storage modifier).


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: Python, Mac OS X 10.5.5 and CoreGraphics

2008-10-04 Thread Bill Bumgarner

On Oct 4, 2008, at 7:13 AM, Ronny Reichmann wrote:
I'm running the systems Python on both Macs. Funnily enough, the  
problem I described isn't appearing on my MacBook. The two versions  
of Python on the MacBook and the stationary Mac are not the same.  
Both systems are set to automatic system-update and are running the  
newest Mac OS.


It seems that something I installed on one machine broke this  
functionality. But how can I find back to standard-conditions?


Python hasn't been updated in a software update, IIRC (though I might  
be mistaken on that).


Try going to a terminal and doing:

%  which python
/usr/bin/python

If that shows the same path on both machines, then you have modules  
installed -- likely in /Library/Python -- that are conflicting w/the  
system modules on one machine.


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]

[Moderator] Re: UINavigationItem backButtonTitle property is missing?

2008-10-04 Thread Scott Anguish


Please re-read http://developer.apple.com/iphone/program/. The new  
list rules will be posted when the new program terms are.



For the moment this is still not for public discussion on this list.


Thanks

scott
[moderator]

On 4-Oct-08, at 11:47 AM, Steve Wart wrote:


Hi,

I'm working through the iPhone UINavigationController tutorial and  
noticed

that the class reference for UINavigationItem contains the following


___

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

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

2008-10-04 Thread Steve Wart
Sorry about that. I should have checked the discussion thread.

On Sat, Oct 4, 2008 at 9:23 AM, Roland King <[EMAIL PROTECTED]> wrote:

> no iPhone discussions allowed here yet.
>
>
> On Oct 4, 2008, at 11:47 PM, Steve Wart wrote:
>
>  Hi,
>>
>> I'm working through the iPhone UINavigationController tutorial and noticed
>> that the class reference for UINavigationItem contains the following
>>
>
>
___

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

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

2008-10-04 Thread Roland King

no iPhone discussions allowed here yet.

On Oct 4, 2008, at 11:47 PM, Steve Wart wrote:


Hi,

I'm working through the iPhone UINavigationController tutorial and  
noticed

that the class reference for UINavigationItem contains the following


___

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

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


UINavigationItem backButtonTitle property is missing?

2008-10-04 Thread Steve Wart
Hi,

I'm working through the iPhone UINavigationController tutorial and noticed
that the class reference for UINavigationItem contains the following

*backButtonTitle*
The title to use when this item is represented by a back button on the
navigation bar.

@property(nonatomic, copy) NSString *backButtonTitle

*Discussion*
When this item is the back item of the navigation bar—when it is the next
item below the top item—it may be represented as a back button on the
navigation bar. Use this property to specify a title for the back button.
The default value is the navigation item's title.

*Availability*
Available in iPhone OS 2.0 and later.
*See Also*
  @property backItem
  @property hidesBackButton
*Declared In*
UINavigationBar.h

However, this property does not seem to be declared in UINavigationItem.h
(the private attribute _backButtonTitle is declared).

I've encountered this in both the 2.0 and 2.1 versions of the SDK.

Am I missing something? Is there a workaround that someone can suggest?

Thanks,
Steve
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Customize NSScroller

2008-10-04 Thread Mr. Gecko

Never mind I found out how
- (void)drawKnob {
NSRect position = [self rectForPart:NSScrollerKnob];
NSImage *topImg = [NSImage imageNamed:@"kt"];
[topImg setFlipped:YES];
NSSize topImgSize = [topImg size];
	[topImg drawInRect:NSMakeRect(position.origin.x, position.origin.y,  
topImgSize.width, topImgSize.height)

   fromRect:NSMakeRect(0, 0, topImgSize.width, 
topImgSize.height)
  operation:NSCompositeSourceOver
   fraction:1.0];

NSImage *centerImg = [NSImage imageNamed:@"kc"];
NSSize centerImgSize = [centerImg size];
int i = 0;
	for (i = (position.origin.y+12); i < (position.origin.y +  
(position.size.height-12)); i += centerImgSize.height) {
		[centerImg drawInRect:NSMakeRect(position.origin.x, i,  
position.size.width, centerImgSize.height)
 fromRect:NSMakeRect(0, 0, centerImgSize.width,  
centerImgSize.height)

operation:NSCompositeSourceOver
 fraction:1.0];
}

NSImage *bottomImg = [NSImage imageNamed:@"kb"];
[bottomImg setFlipped:YES];
NSSize bottomImgSize = [bottomImg size];
	[bottomImg drawInRect:NSMakeRect(position.origin.x, position.origin.y+ 
(position.size.height-12), bottomImgSize.width, bottomImgSize.height)
		   fromRect:NSMakeRect(0, 0, bottomImgSize.width,  
bottomImgSize.height)

  operation:NSCompositeSourceOver
   fraction:1.0];
}
On Oct 4, 2008, at 3:08 AM, Mr. Gecko wrote:

Hello I have been working on making a custom NSScroller and so far I  
got a lot done. the only thing I am having trouble with is drawing  
the knob.
I have three images top, center, and bottom. how can i put that  
together to make a scroll bar.

Top and Bottom width is 15 and height is 12.
Center width is 15 and height is 1.

Thanks,
Mr. Gecko


___

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

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

2008-10-04 Thread Andre Masse
Ah! That's it! I forgot about this order of declaration in C source  
files.


Thanks,

Andre Masse


On Oct 4, 2008, at 10:49, Jonathan del Strother wrote:


I'm guessing that the times where it doesn't warn occur after "-
(void)prepareAttributes" ?
To avoid those warnings, the method declaration or definition needs to
appear before it's used.  I usually add a private category at the top
of my .m files where you can declare private methods - something like
this :

@interface BigLetterView ()
- (void)prepareAttributes;
@end

@implementation BigLetterView
- (id)initWithFrame:(NSRect)rect {
...
}
-(void)prepareAttributes {
...
}
@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: Clueless about this warning

2008-10-04 Thread Jonathan del Strother
On Sat, Oct 4, 2008 at 3:43 PM, Andre Masse <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Can someone explain to me why I get this compiler warning (BigLetterView is
> a subclass of NSView):
>
> 'BigLetterView' may not respond to '-prepareAttributes'
>
>
>
> - (id)initWithFrame:(NSRect)rect {
>
>if(![super initWithFrame:rect]) {
>return nil;
>}
>NSLog(@"intializing view");
>[self prepareAttributes]; // < warning on this line
>bgColor = [[NSColor yellowColor] retain];
>string = @" ";
>
>return self;
> }
>
> while later in the same source file, the following method is defined:
>
> - (void)prepareAttributes
> {
>NSLog(@"prepareAttributes called");
>attributes = [[NSMutableDictionary alloc] init];
>[attributes setObject:[NSFont fontWithName:@"Helvetica" size:75]
> forKey:NSFontAttributeName];
>[attributes setObject:[NSColor redColor]
> forKey:NSForegroundColorAttributeName];
> }
>
> I know I can fix this easily by declaring prepareAttributes in the header
> file or in an @interface block in the '.m' file, but I'm curious why I get
> this warning if an only if I make the call in the initWithFrame method.
> Calling [self prepareAttributes] in any other method doesn't generate any
> warning.
>
> Does calling an instance method in the initialization phase require
> something special?
>


I'm guessing that the times where it doesn't warn occur after "-
(void)prepareAttributes" ?
To avoid those warnings, the method declaration or definition needs to
appear before it's used.  I usually add a private category at the top
of my .m files where you can declare private methods - something like
this :

@interface BigLetterView ()
- (void)prepareAttributes;
@end

@implementation BigLetterView
- (id)initWithFrame:(NSRect)rect {
...
}
-(void)prepareAttributes {
...
}
@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]


Clueless about this warning

2008-10-04 Thread Andre Masse

Hi,

Can someone explain to me why I get this compiler warning  
(BigLetterView is a subclass of NSView):


'BigLetterView' may not respond to '-prepareAttributes'



- (id)initWithFrame:(NSRect)rect {

if(![super initWithFrame:rect]) {
return nil;
}   
NSLog(@"intializing view");
[self prepareAttributes]; // < warning on this line
bgColor = [[NSColor yellowColor] retain];
string = @" ";

return self;
}

while later in the same source file, the following method is defined:

- (void)prepareAttributes
{
NSLog(@"prepareAttributes called");
attributes = [[NSMutableDictionary alloc] init];
	[attributes setObject:[NSFont fontWithName:@"Helvetica" size:75]  
forKey:NSFontAttributeName];
	[attributes setObject:[NSColor redColor]  
forKey:NSForegroundColorAttributeName];

}

I know I can fix this easily by declaring prepareAttributes in the  
header file or in an @interface block in the '.m' file, but I'm  
curious why I get this warning if an only if I make the call in the  
initWithFrame method. Calling [self prepareAttributes] in any other  
method doesn't generate any warning.


Does calling an instance method in the initialization phase require  
something special?


Thanks,

Andre Masse

___

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

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

2008-10-04 Thread Graham Cox


On 5 Oct 2008, at 12:07 am, Mr. Gecko wrote:

 ran the time test on my play playlist function and it was time =  
-0.005 sec which is more than fast enough



Cool! You get the result back before you sent the query - that is  
fast! ;-)


G.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Re: Python, Mac OS X 10.5.5 and CoreGraphics

2008-10-04 Thread Ronny Reichmann

On Oct 3, 2008, at 5:02 PM, Ronny Reichmann wrote:

Hello there,

unfortunately none of the examples in /Developer/Examples/Quartz/ 
Python/ work anymore. I don't know if recently, I just encountered  
it today. According to your answer, there should be wrappers as  
part of PyObjC. Unfortunately the graphics examples from the PyObjC- 
website don't work either. In order to know what is wrong I would  
like to find out, if I'm probably having something running that's  
preventing my code and those examples from working properly.  
Especially before filing a bug, of course.


The Quartz based Python stuff predates PyObjC shipping with Mac OS X  
and is done in isolation; it is the SWIG wrapper based stuff.


If both it and the PyObjC based stuff is broken, then that raises a  
question -- are you running w/the system provided Python, or did you  
install some other Python distribution or update?


I'm running the systems Python on both Macs. Funnily enough, the  
problem I described isn't appearing on my MacBook. The two versions of  
Python on the MacBook and the stationary Mac are not the same. Both  
systems are set to automatic system-update and are running the newest  
Mac OS.


It seems that something I installed on one machine broke this  
functionality. But how can I find back to standard-conditions?



b.bum

___

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

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

2008-10-04 Thread Mr. Gecko

Ok thanks for the tips
I ran the time test on my play playlist function and it was time =  
-0.005 sec which is more than fast enough for me. especially when my  
computer is 733Mhz.


On Oct 4, 2008, at 4:26 AM, has wrote:



On 4 Oct 2008, at 03:54, Mr. Gecko wrote:

I am not using AppleScript to do this, I am using AppleEvents, as  
you can see in code below.


Aware of that. You'll often find that folks use the name  
"AppleScript" as a catch-all term for anything relating to Apple  
event IPC. It's easy to lapse into the habit; apologies if it caused  
any confusion.


Anyway, regardless of whether you use AppleScript or C to build and  
send events, the underlying RPC+query semantics are the same as  
they're defined by the Apple Event Manager and by the event handling  
code in scriptable applications. The AppleScript language sticks a  
thin layer of syntactic sugar [1] over the existing Apple Event  
Manager API in order to make it easier to use, but the way it  
behaves is virtually [2] identical.




This is way faster than using AppleScript.


It's the extra overhead of calling into the AS component that slows  
things down, particularly if you're compiling from source each time.  
There shouldn't actually be much speed difference between  
AppleScript and other APIs where building and sending events is  
concerned; it's the one area where AppleScript's performance is  
about as good as it can be. AS, appscript and SB all seem to be  
about equal here; the Carbon C API might be a little faster as it's  
closest to the metal, but I doubt the difference is significant by  
the time you've packed your Cocoa values into AEDescs and back.



BTW, regardless of what API you use, you can also speed up or slow  
things down massively depending on the number of Apple events you  
use to perform a given task. This can be particularly noticeable  
with iTunes, since playlists can often run into thousands of tracks.  
Apple event IPC traditionally optimises for fewer, more complex  
events over many simple ones, so each event you send is relatively  
expensive but, depending on the application, you can often perform  
multiple operations in a single event. For example:



#import 
#import "ITGlue/ITGlue.h"

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

	ITApplication *itunes = [ITApplication applicationWithBundleID:  
@"com.apple.itunes"];



// This sends 3 Apple events:

NSDate *time1 = [NSDate date];

	ITReference *tracksRef = [[[itunes playlists] byName: @"stress  
test"] tracks];


NSArray *names = [[tracksRef name] getList];
NSArray *albums = [[tracksRef album] getList];
NSArray *artists = [[tracksRef artist] getList];

printf("time 1 = %.3f sec\n", -[time1 timeIntervalSinceNow]);


	// This sends N * 3 + 1 Apple events (where N is the number of  
tracks in the playlist):


NSDate *time2 = [NSDate date];

	NSArray *tracksList = itunes playlists] byName: @"stress test"]  
tracks] getList];


NSEnumerator *iterator = [tracksList objectEnumerator];
ITReference *track;
while (track = [iterator nextObject]) {
NSString *name = [[track name] getItem];
NSString *artist = [[track artist] getItem];
NSString *album = [[track album] getItem];
}

printf("time 2 = %.3f sec\n", -[time2 timeIntervalSinceNow]);

[pool drain];
return 0;
}

gives the following times for a 4000-track playlist:

time 1 = 0.137 sec
time 2 = 5.779 sec

and for a 40,000-track playlist:

time 1 = 2.116 sec
time 2 = 82.634 sec

I'm not sure which approach EyeTunes uses, but it's something to  
bear in mind if performance is an issue for you.



I would prefer using AppleEvents because it is the right way to  
communicate with different things in the os, using cocoa.


It's all Apple events under the hood. Some APIs just make them  
easier to work with than others.


HTH

has

[1]  Plus a few magical behaviours such as 'implicit gets' which do  
unfortunately muddy comprehension a bit. But I won't claim that  
AppleScript is a perfect pedagogical tool, just a convenient one.


[2] See [1].
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: file fixtures for unit testing

2008-10-04 Thread Timothy Reaves


On Oct 4, 2008, at 1:01 AM, Brent Hargrave wrote:

To unit test an XML parsing method, I would like keep a dummy XML  
file in a

project directory and import it into my FooTests class as a fixture of
sorts.  What is the right way to do this sort of thing?



	Put the file into the Resources folder, and add it to the test  
target.  This insures that the file gets copied into the .app during  
the build.  In the test, you do this:
NSString *filename = [[NSBundle bundleForClass:[self class]]  
pathForResource:@"TestXML1" ofType:@"xml"];


	Now, having said that, I'll also say that you do not need to read in  
XML files to test an XML parser, and that in general, it's a bad idea  
for tests to rely on files.  My ID3 parser has 100% test coverage, and  
doesn't require a single file.


___

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

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


NSNetService connection difficulty

2008-10-04 Thread Cate Tony
I've created a small server that appears to set up and publish itself.  
I then created a small client app that 'sees' the server but fails to  
connect. The error I'm getting is: Address family not supported by  
protocol family. The address->sa_family is AF_INET. The socket type  
is: SOCK_STREAM.


Relevant code (I think):

remoteSocket = socket(socketAddress->sa_family, SOCK_STREAM, 0);
if ( remoteSocket > 0 )
	remoteFile = [[NSFileHandle alloc]  
initWithFileDescriptor:remoteSocket closeOnDealloc:YES];


if ( remoteFile ){
	connectResult = connect(remoteSocket, (struct sockaddr  
*)&socketAddress, sizeof(*socketAddress));

NSLog (@"%s\n", strerror (errno));
}

Some questions:
How do I tell what protocols an address family supports (or vise versa)?
Do I have to add support for the family to the protocol? If so, any  
pointers to how?

Am I missing something simple or obvious?

Tony
3CAAM
___

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

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

2008-10-04 Thread Jason Stephenson

Rob Keniger wrote:

On 04/10/2008, at 9:46 AM, mmalc crawford wrote:

Start with Programming in Objective-C by Stephen Kochan (depending on 
how quickly you want to get underway, you may consider waiting for the 
second edition):


 

 




I totally agree with mmalc, this is the first book you should buy. 
Despite what others have said, I highly recommend that you do NOT start 
with Kernigan and Richie, it's simply not the best learning tool for 
getting into Mac programming. K&R is extremely dry and although it 
teaches you plain C, you don't need to know most of the stuff in that 
book to write good Objective-C.


Stephen Kochan's book teaches you everything you need to know about 
programming in Objective-C, including the bits of the C language you 
need to know and none of the bits you don't. It is also one of the most 
well-written technical books I have ever read.


Ditto.

Plus, I'd like to add that Kochan also introduces you to the basic 
programming concepts along the way. He doesn't just teach the language 
or the Objective-C idioms, but several chapters discuss things like 
basic data types and looping. So, you'll not learn just Objective-C the 
language, but you'll get a fairly decent introduction to the basics to 
be an effective programmer in any language.


Kernighan and Ritchie don't do this in their small book. They assume you 
already know the basics of programming, and they are only interested in 
introducing you to the C language. It would help to have some basic 
programming knowledge: data structures, looping, recursion, etc. 
*before* reading K&R.


I've never read it, but I imagine that the book on C by Kochan 
(http://search.barnesandnoble.com/Programming-in-C/Stephen-G-Kochan/e/9780672326660/?itm=1) 
is equally as good as his book on Objective-C.



Once you've read the Kochan book you should get Aaron Hillegass' "Cocoa 
Programming for Mac OS X", which goes beyond the Objective-C language to 
teach you the mechanics of working with the Cocoa frameworks.



Ditto, and Fritz Anderson's Xcode Unleashed is another good choice for a 
second or third book. It covers the Xcode 3 programming environment in a 
bit more detail than Hillegass's book, and has some excellent chapters 
on using libraries and private frameworks.


Jason
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSTreeController rearrangeObjects doesn't always trigger sorting

2008-10-04 Thread Alexey Zakhlestin
I see this behaviour since 10.5.3. (10.5.2 was ok)

My solution is manual re-sorting, for now.

On Tue, Jul 29, 2008 at 2:41 AM, Jonathan Fewtrell
<[EMAIL PROTECTED]> wrote:
> I know that similar issues have been raised in the past, but I haven't been
> able to find a clear solution.
>
> I have a Core Data app with an NSOutlineView controlled by an entity-mode
> NSTreeController bound to the managed object context. The NSTreeController
> has sort descriptors based on certain attributes of the model object.
>
> Sorting does take place when the frameworks seem to think fit (for example
> when a document is opened), but if I call -rearrangeObjects to force a sort
> programmatically nothing happens. Actually, if I tick 'Uses Lazy Fetching'
> in the controller's IB attributes, the view will sort the first level of
> nodes, but not the deeper levels.
>
> Sorting was working fine in earlier versions of the OS. I'm now in 10.5.4
> and I'm not certain which version introduced this problem.
>
> Any suggestions? I am conscious of the slightly strange wording of the
> documentation of this method, which is much less clear cut than that of the
> NSArrayController equivalent. It almost suggests that the method will only
> work in subclasses. If so, I don't understand why.
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/indeyets%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>



-- 
Alexey Zakhlestin
http://blog.milkfarmsoft.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: file fixtures for unit testing

2008-10-04 Thread Colin Barrett
On Fri, Oct 3, 2008 at 10:01 PM, Brent Hargrave <[EMAIL PROTECTED]> wrote:
> To unit test an XML parsing method, I would like keep a dummy XML file in a
> project directory and import it into my FooTests class as a fixture of
> sorts.  What is the right way to do this sort of thing?

Add it to the project, and then add it to the test's target. You
should then be able to reference it using -[NSBundle
pathForResource:ofType:]. I'm not 100% that's the way OCUnit/SenTest
targets work, but it would surprise me if they worked otherwise.

Hope that helps,
-Colin
___

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

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

2008-10-04 Thread Graham Cox


On 4 Oct 2008, at 6:48 am, [EMAIL PROTECTED] wrote:

I am trying to create an application that will load an XML file into  
an

array when you press the load button, and save when you press a save
button.  However, I don't see any examples online or in my books that
suggest how to handle dataOfType or readFromData on a button click.



Well, why would you expect to, really? Books can't be expected to  
cover every possible way to configure an app, especially if it's a bit  
non-standard, as here.


You could declare action methods in your controller to respond to the  
buttons, then call the relevant methods from there. Or hook the  
buttons to the action methods that the usual Save and Open menu items  
are connected to (you can find out what these are by exploring the  
standard items in IB).


On a general note, sample code/how-tos and documentation can only go  
so far in teaching you how to do stuff. At some point, you are  
expected to "get it" and synthesise new solutions for your specific  
situation yourself. That's true of everything you've ever learned, not  
just programming.


cheers, Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Fwd: Python, Mac OS X 10.5.5 and CoreGraphics

2008-10-04 Thread Ronny Reichmann



Von: Ronny Reichmann <[EMAIL PROTECTED]>
Datum: 4. Oktober 2008 12:44:26 MESZ
An: Bill Bumgarner <[EMAIL PROTECTED]>
Betreff: Re: Python, Mac OS X 10.5.5 and CoreGraphics

Am 04.10.2008 um 04:29 schrieb Bill Bumgarner:


On Oct 3, 2008, at 5:02 PM, Ronny Reichmann wrote:

Hello there,

unfortunately none of the examples in /Developer/Examples/Quartz/ 
Python/ work anymore. I don't know if recently, I just encountered  
it today. According to your answer, there should be wrappers as  
part of PyObjC. Unfortunately the graphics examples from the  
PyObjC-website don't work either. In order to know what is wrong I  
would like to find out, if I'm probably having something running  
that's preventing my code and those examples from working  
properly. Especially before filing a bug, of course.


The Quartz based Python stuff predates PyObjC shipping with Mac OS  
X and is done in isolation; it is the SWIG wrapper based stuff.


If both it and the PyObjC based stuff is broken, then that raises a  
question -- are you running w/the system provided Python, or did  
you install some other Python distribution or update?


I'm running the systems Python on both Macs. Funnily enough, the  
problem I described isn't appearing on my MacBook. The two versions  
on the MacBook and the stationary Mac are not the same. Both  
computers are set to automatic system-update and are running the  
newest Mac OS.


It seems that something I installed on one machine broke this  
functionality. But how can I find back to standard-conditions?



b.bum





___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Accessing IB >Inspector > Identity > Interface Builder Identity > name programatically?

2008-10-04 Thread Graham Cox


On 4 Oct 2008, at 6:27 pm, Ken Tozier wrote:

I created a custom view with several subviews some of which I gave  
names in the "Identity > Interface Builder Identity > name" tab. Is  
there any way to reference these items by their given name if the  
nib is loaded programatically using NSNib?



In a word, no.

These labels appear to serve no purpose except to help you tell things  
apart within IB itself.


If you need to access individual views, just create an IBOutlet for  
each one in File's Owner and hook them up in IB.



hth,

Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Bizarre [NSWindowController window] returning null

2008-10-04 Thread Ken Tozier

Bingo! Thanks Roland.

On Oct 4, 2008, at 6:15 AM, Roland King wrote:

did you connect the window outlet of Files Owner in interface  
builder to the window?


On Oct 4, 2008, at 6:08 PM, Ken Tozier wrote:

I created the following NSWindowController subclass which loads and  
displays a window without problem, but am finding that whenever I  
try to actually access the window with [NSWindowController window]  
it always returns null.


- (id) init
{
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
	NSString *nibPath = [bundle pathForResource: @"PMScriptPalette"  
ofType: @"nib"];


self = [super initWithWindowNibPath: nibPath owner: self];
if (self)
{
NSLog(@"[self window]: %@", [self window]);
		NSLog(@"[[self window] contentView]: %@", [[self window]  
contentView]);

}

return self;
}

I added another test in a "show" method but still get null

- (void) show
{
NSLog(@"show: [self window]: %@", [self window]);
[[self window] orderFront: self];
}

Anyone know why this might be happening?

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/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: Bizarre [NSWindowController window] returning null

2008-10-04 Thread Roland King
did you connect the window outlet of Files Owner in interface builder  
to the window?


On Oct 4, 2008, at 6:08 PM, Ken Tozier wrote:

I created the following NSWindowController subclass which loads and  
displays a window without problem, but am finding that whenever I  
try to actually access the window with [NSWindowController window]  
it always returns null.


- (id) init
{
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
	NSString *nibPath = [bundle pathForResource: @"PMScriptPalette"  
ofType: @"nib"];


self = [super initWithWindowNibPath: nibPath owner: self];
if (self)
{
NSLog(@"[self window]: %@", [self window]);
		NSLog(@"[[self window] contentView]: %@", [[self window]  
contentView]);

}

return self;
}

I added another test in a "show" method but still get null

- (void) show
{
NSLog(@"show: [self window]: %@", [self window]);
[[self window] orderFront: self];
}

Anyone know why this might be happening?

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


Bizarre [NSWindowController window] returning null

2008-10-04 Thread Ken Tozier
I created the following NSWindowController subclass which loads and  
displays a window without problem, but am finding that whenever I try  
to actually access the window with [NSWindowController window] it  
always returns null.


- (id) init
{
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
	NSString *nibPath = [bundle pathForResource: @"PMScriptPalette"  
ofType: @"nib"];


self = [super initWithWindowNibPath: nibPath owner: self];
if (self)
{
NSLog(@"[self window]: %@", [self window]);
		NSLog(@"[[self window] contentView]: %@", [[self window]  
contentView]);

}

return self;
}

I added another test in a "show" method but still get null

- (void) show
{
NSLog(@"show: [self window]: %@", [self window]);
[[self window] orderFront: self];
}

Anyone know why this might be happening?

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: Play Playlist in iTunes

2008-10-04 Thread has


On 4 Oct 2008, at 03:54, Mr. Gecko wrote:

I am not using AppleScript to do this, I am using AppleEvents, as  
you can see in code below.


Aware of that. You'll often find that folks use the name "AppleScript"  
as a catch-all term for anything relating to Apple event IPC. It's  
easy to lapse into the habit; apologies if it caused any confusion.


Anyway, regardless of whether you use AppleScript or C to build and  
send events, the underlying RPC+query semantics are the same as  
they're defined by the Apple Event Manager and by the event handling  
code in scriptable applications. The AppleScript language sticks a  
thin layer of syntactic sugar [1] over the existing Apple Event  
Manager API in order to make it easier to use, but the way it behaves  
is virtually [2] identical.




This is way faster than using AppleScript.


It's the extra overhead of calling into the AS component that slows  
things down, particularly if you're compiling from source each time.  
There shouldn't actually be much speed difference between AppleScript  
and other APIs where building and sending events is concerned; it's  
the one area where AppleScript's performance is about as good as it  
can be. AS, appscript and SB all seem to be about equal here; the  
Carbon C API might be a little faster as it's closest to the metal,  
but I doubt the difference is significant by the time you've packed  
your Cocoa values into AEDescs and back.



BTW, regardless of what API you use, you can also speed up or slow  
things down massively depending on the number of Apple events you use  
to perform a given task. This can be particularly noticeable with  
iTunes, since playlists can often run into thousands of tracks. Apple  
event IPC traditionally optimises for fewer, more complex events over  
many simple ones, so each event you send is relatively expensive but,  
depending on the application, you can often perform multiple  
operations in a single event. For example:



#import 
#import "ITGlue/ITGlue.h"

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

	ITApplication *itunes = [ITApplication applicationWithBundleID:  
@"com.apple.itunes"];



// This sends 3 Apple events:

NSDate *time1 = [NSDate date];

	ITReference *tracksRef = [[[itunes playlists] byName: @"stress test"]  
tracks];


NSArray *names = [[tracksRef name] getList];
NSArray *albums = [[tracksRef album] getList];
NSArray *artists = [[tracksRef artist] getList];

printf("time 1 = %.3f sec\n", -[time1 timeIntervalSinceNow]);


	// This sends N * 3 + 1 Apple events (where N is the number of tracks  
in the playlist):


NSDate *time2 = [NSDate date];

	NSArray *tracksList = itunes playlists] byName: @"stress test"]  
tracks] getList];


NSEnumerator *iterator = [tracksList objectEnumerator];
ITReference *track;
while (track = [iterator nextObject]) {
NSString *name = [[track name] getItem];
NSString *artist = [[track artist] getItem];
NSString *album = [[track album] getItem];
}

printf("time 2 = %.3f sec\n", -[time2 timeIntervalSinceNow]);

[pool drain];
return 0;
}

gives the following times for a 4000-track playlist:

time 1 = 0.137 sec
time 2 = 5.779 sec

and for a 40,000-track playlist:

time 1 = 2.116 sec
time 2 = 82.634 sec

I'm not sure which approach EyeTunes uses, but it's something to bear  
in mind if performance is an issue for you.



I would prefer using AppleEvents because it is the right way to  
communicate with different things in the os, using cocoa.


It's all Apple events under the hood. Some APIs just make them easier  
to work with than others.


HTH

has

[1]  Plus a few magical behaviours such as 'implicit gets' which do  
unfortunately muddy comprehension a bit. But I won't claim that  
AppleScript is a perfect pedagogical tool, just a convenient one.


[2] See [1].
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

___

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

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

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

This email sent to [EMAIL PROTECTED]


Accessing IB >Inspector > Identity > Interface Builder Identity > name programatically?

2008-10-04 Thread Ken Tozier

Hi

I created a custom view with several subviews some of which I gave  
names in the "Identity > Interface Builder Identity > name" tab. Is  
there any way to reference these items by their given name if the nib  
is loaded programatically using NSNib?


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]


Customize NSScroller

2008-10-04 Thread Mr. Gecko
Hello I have been working on making a custom NSScroller and so far I  
got a lot done. the only thing I am having trouble with is drawing the  
knob.
I have three images top, center, and bottom. how can i put that  
together to make a scroll bar.

Top and Bottom width is 15 and height is 12.
Center width is 15 and height is 1.

Thanks,
Mr. Gecko
___

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

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


file fixtures for unit testing

2008-10-04 Thread Brent Hargrave
To unit test an XML parsing method, I would like keep a dummy XML file in a
project directory and import it into my FooTests class as a fixture of
sorts.  What is the right way to do this sort of thing?

Many thanks!

JB
___

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

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

2008-10-04 Thread Rob Keniger


On 04/10/2008, at 5:06 PM, Kyle Sluder wrote:

Basically, is there any way for me to load that second NIB file  
(using
something like 'loadNibNamed:' or the like) and then get the menu  
that I

have connected to the File's Owner 'menu' outlet


Sure.  You've already described how to do it.



What he said; look at the -loadNibNamed:owner: method of NSBundle.

--
Rob Keniger



___

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

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

2008-10-04 Thread Kyle Sluder
On Sat, Oct 4, 2008 at 12:01 AM, Kevin Ferguson <[EMAIL PROTECTED]> wrote:
> Basically, is there any way for me to load that second NIB file (using
> something like 'loadNibNamed:' or the like) and then get the menu that I
> have connected to the File's Owner 'menu' outlet

Sure.  You've already described how to do it.

--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: NSCoding protocol

2008-10-04 Thread Graham Cox


On 4 Oct 2008, at 9:29 am, [EMAIL PROTECTED] wrote:

But now I'm confused about how to de-allocate MyClass. Given this in  
its initialisation:


S1 = @"a string";
S2 = [[NSString alloc] init];
S3 = [NSString string];

I would only release S2 in the dealloc method. But if the class has  
been unarchived, won't I leak memory with S1 and S3 when the class  
is released?



An approach that might help clarify this is to have accessor methods  
to set each string, rather than assign them directly in the  
initWithCoder method. Then you can write something like:


[self setFirstString:[coder decodeObjectForKey:@"blah"]];

then there's no special case when dearchiving compared with setting  
the string from any other place. And of course, the accesssor method  
would, as is the norm, retain the object.



Sending -retain to a constant literal string is fine, so you don't  
need to treat those as a special case either. So again:


[self setFirstString:@"Initial Value"];

is fine, even if the -setFirstString method retains the string, as it  
should.



hth,

Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: A way to use multiple colours with one NSBezierPath?

2008-10-04 Thread Graham Cox


On 4 Oct 2008, at 1:54 pm, Michael Robinson wrote:


I would like to draw one path, which is used as a border.

I naively assumed I could change the colour of the path as it is  
constructed, but it seems this is not the case.


If I change the colour (using [[NSColor blackColor] set]; for  
example), this changes the colour for the entire path.


Basically what I would like to know is:

Is it possible to use multiple colours in one line, as in the  
following:


Bottom + BR + BL corners = black
Right = Orange
Top + TR + TL corners = black
Left = Orange

Yes, I know this would be hideous, it is just an example.

I was attempting this by using [[NSColor aColor] set];  after each  
path element is drawn, but it is causing the whole path to take the  
value of the last set colour.


I would also like to say that I really appreciate the incredible  
amount of quality suggestions and advice I have received from this  
list, you're all wonderfully talented and kind.
Without your help I would have bashed my computer into little pieces  
long ago.



NSBezierPath does not store information about its rendering appearance  
(except stroke width and a couple of other stroking parameters), it  
only stores the geometry. To achieve paths in different colours, you  
need to set the colour and draw each path.


To achieve what you describe above, you need to create separate paths  
for each differently coloured part of the object. You could also  
devise a class that "has a" path + a colour to make it a bit more  
convenient, but there's nothing like that built in.


hth,

Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]