Problem with NSWindow setFrame

2008-06-18 Thread kalpana k
Hi all,

I am working with dual monitor application. I want to extend the NSWindow to
dual monitor.
But the problem is that its height is not extending.
i.e. the height of the window is set to height of a single monitor.

for example :
Monitor 1 : origin:  (0,0) size : (1024, 640)  - Window is there in this
monitor.
Monitor 2 : origin(0,-768)   size : (1024, 768)

The arrangement is Monitor2 is below Monitor1.

window setFrame: NSMakeRect(0,0,1024,1200)

If I set the height of the frame to 1200, the resultant window height is 640
only.
Why this is happening?


Thanks,
Kalpana
___

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

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

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

This email sent to [EMAIL PROTECTED]


getting free space available in a drive

2008-06-18 Thread Angelo Chen
Hi,

how to get the total free space available in a drive? thanks,

Angelo

___
 YM - 離線訊息
 就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
 http://messenger.yahoo.com.hk
___

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

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

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

This email sent to [EMAIL PROTECTED]


Where does the undo manager come from?

2008-06-18 Thread Graham Cox
In a non-document based app, I can get the undo manager from any view,  
which appears to be inherited from NSResponder. The docs for that say:  
"NSResponder’s implementation simply passes this message to the next  
responder." But NSApplication, which I think is the next responder,  
doesn't have a public -undoManager of its own, again only what it  
inherits from NSResponder.


So my question is: in a non-document app, does a view's undo manager  
come from the app? If not, where from? and finally, is there a way to  
set the undo manager to some subclass of my own (easy in a document- 
based app, not so obvious here).


tia,

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]


Tab-based ("document"-based?) application

2008-06-18 Thread Jacob Bandes-Storch
I'm creating an application that will have an arbitrary number of  
basically identical windows (document-like) which each have tabs (or  
something of the sort) in them that represent the actual "documents,"  
per se. Would it be best to start out with a Document-Based  
Application or just a regular Cocoa application? Any tips on doing this?

___

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

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

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

This email sent to [EMAIL PROTECTED]


CFWriteStreamWrite Blocking if we give invalid Host.

2008-06-18 Thread SridharRao M
Hi,
I am using CFWriteStreamWrite to write some command on server and
using CFReadStreamRef
 to retrieve some value from server.
CFWriteStreamWrite is blocking if we give invalid host address,instead it
should return -1 as result.But it's blocking,
In the documentation it 's given as use CFWriteStreamCanAcceptBytes before
writing .If i use the same am always getting boolean value False.so i am not
able to write anything.

CFWriteStreamRef myWriteStream = Nil;

CFReadStreamRef myReadStream = Nil;

CFStreamCreatePairWithSocketToCFHost(kCFAllocatorDefault,host,SERVER_PORT
,&myReadStream,&myWriteStream);


if (myWriteStream != Nil && CFWriteStreamOpen (myWriteStream)==true &&
CFReadStreamOpen (myReadStream)==true){

CFIndex result = CFWriteStreamWrite ( myWriteStream, (UInt8*)&buffer, sizeof
(buffer));

}


Friends please help me if you know how to avoid blocking.
___

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

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

2008-06-18 Thread Michael Ash
On Wed, Jun 18, 2008 at 11:48 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> On Jun 18, 2008, at 2:41 PM, Michael Ash wrote:
>>
>> Although it partially defeats the purpose of using NSCoder, you'll
>> avoid this whole path if you stuff all four doubles into a single
>> NSData. Don't forget to use the byte-swapping functions to ensure that
>> they all have a consistent representation across architectures.
>
> Well, what can I say, you and Quincey Morris are absolutely right. This is
> the way to go.
>
> The same data set takes just 4 seconds to store with a file size of 17.2MB.
>
> Thanks for all the help guys! For the record I'm posting the code below.

I'm glad it all worked out for you.

Just to address one last point, there should be no problems with
floating point formats. As a practical matter, both PPC and x86 use
the same IEEE754 floating point format, so the only problem is
endianness. Any realistic future architecture is also likely to use
this standard format. In a theoretical sense you should be protected
regardless, because the swap functions you're using are explicitly
made for floating point, so if there were any format differences then
they would be expected to take care of them for you.

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: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Markus Spoettl

On Jun 18, 2008, at 2:41 PM, Michael Ash wrote:

Although it partially defeats the purpose of using NSCoder, you'll
avoid this whole path if you stuff all four doubles into a single
NSData. Don't forget to use the byte-swapping functions to ensure that
they all have a consistent representation across architectures.



Well, what can I say, you and Quincey Morris are absolutely right.  
This is the way to go.


The same data set takes just 4 seconds to store with a file size of  
17.2MB.


Thanks for all the help guys! For the record I'm posting the code below.

Regards
Markus

- (void)encodeDouble:(double)value forKey:(NSString *)key withCoder: 
(NSCoder *)encoder

{
NSSwappedDouble sd = NSSwapHostDoubleToLittle(value);
[encoder encodeBytes:(const uint8_t *)&sd  
length:sizeof(NSSwappedDouble) forKey:key];

}

- (double)decodeDoubleForKey:(NSString *)key withCoder:(NSCoder  
*)decoder

{
double result = 0.0;
NSUInteger retsize;
NSSwappedDouble *sd = (NSSwappedDouble *)[decoder  
decodeBytesForKey:key returnedLength:&retsize];

if (retsize == sizeof(NSSwappedDouble)) {
result = NSSwapLittleDoubleToHost(*sd);
}
return result;
}

--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: [NSOutlineView/NSTableView] Returning nil enables auto-edition?

2008-06-18 Thread Stephane Sudre


On Jun 13, 2008, at 11:23 AM, Corbin Dunn wrote:


You probably mean, editing (not edition).


Certainly.



[...]
- (BOOL) outlineView:(NSOutlineView *) inOutlineView  
shouldEditTableColumn:(NSTableColumn *) inTableColumn item:(id)inItem


First off -- 10.4 *requires* a double click to begin an editing  
session. Are you sure you aren't manually starting the editing by  
calling - (void)editColumn:(NSInteger)column row:(NSInteger)row  
withEvent:(NSEvent *)theEvent select:(BOOL)select;


In fact, you can break on that method and see when it is invoked,  
and look at the bt to figure out why.


No, I checked the source.


Is it a bug or just an unsupported scenario?


I don't think it should happen the way you described, see the notes  
above. Really, you should return non-nil from the method. I have a  
feeling something else is going on.


This is the solution I used to "fix" the issue.


___

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

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

2008-06-18 Thread Markus Spoettl

On Jun 18, 2008, at 5:04 PM, Adam R. Maxwell wrote:
It's not recommended, but have you tried using old-style archiving  
as another approach?  It used to be considerably faster than keyed  
archiving under some circumstances.



I have thought about trying this until I read it's deprecated since  
10.2. Also they don't play well with changes to the data structure,  
both very good reasons to stay away.


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Drawing in CALayers

2008-06-18 Thread Gordon Apple
Addendum:  I did implement my own transform to flip the drawing.  As far
as I can tell, the "initialFlippedState" parameter in NSGraphicsContext
*)graphicsContextWithGraphicsPort:(void *)graphicsPort
flipped:(BOOL)initialFlippedState  has no impact whatsoever.  Bug report
time?

Another thing that does not seem to work is CALayer's
setNeedsDisplayInRect:.  SetNeedsDisplay does work and updates the visible
layer while you draw or modify a shape.  Apparently, setNeedsDisplayInRect
is intended to accumulate calls until something flushes it to the screen.  I
tried using "display" even though the ref. Doc. says don't call it, and the
new Hillegasse book does it anyway, but it didn't help.


>   At the present time, I'm not doing animation.  I just want a layer stack
> I can draw into, with one layer for previous drawings and one normal user
> drawing activities.  Later, I want to add more layers for user annotation
> and (possibly animated) attention directors.  So far, I haven't even been
> able to get the drawing right-side-up, no matter what I tell the context.
> The underlying view uses flipped coordinates, mainly because some objects
> use text and NSLayoutManager just doesn't work with un-flipped views.  I
> also haven't been able to get visual feedback when drawing a shape.  I'm
> sure I'll eventually figure it out, but it's not as easy as I thought it
> would be.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting double-clicks on NSTextField

2008-06-18 Thread Andy Lee

On Jun 18, 2008, at 8:25 PM, Steve Nicholson wrote:
I have an NSTextField on my window that is neither editable nor  
selectable. Is there a way for my window controller to be notified  
when the user double-clicks on the field?


I don't know if there's a better way, but this works:

NSTextField doesn't have a doubleAction, but NSMatrix does.  So  
instead of an NSTextField, use an NSMatrix with just one cell.  You  
can do this in IB by selecting the NSTextField and selecting Layout >>  
Embed Objects In >> Matrix from the menu.  In your window controller's  
awakeFromNib, do this:


[_textFieldMatrix setTarget:self];
[_textFieldMatrix  
setDoubleAction:@selector(doTextFieldDoubleClick:)];


--Andy

___

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

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

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

This email sent to [EMAIL PROTECTED]


Services menu invoke from the command line?

2008-06-18 Thread Glen Low

Hi All

Is there any command-line tool that will invoke a Services menu  
command with standard input as the data to be transformed?





Cheers, Glen Low


---
pixelglow software | simply brilliant stuff
www.pixelglow.com
aim: pixglen

___

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

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

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

This email sent to [EMAIL PROTECTED]


Getting double-clicks on NSTextField

2008-06-18 Thread Steve Nicholson
I have an NSTextField on my window that is neither editable nor  
selectable. Is there a way for my window controller to be notified  
when the user double-clicks on the field?


-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: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Adam R. Maxwell


On Jun 18, 2008, at 7:31 PM, Markus Spoettl wrote:


On Jun 18, 2008, at 2:50 PM, Quincey Morris wrote:
I suppose you could byte-move each group of 4 doubles in one NSData  
and give that to the archiver instead. Or do it further upstream  
and make a bigger array of numbers in a NSData. (But you'll have to  
deal with endianness and -- egads! -- floating point representation  
issues across architectures yourself.)



I've now completed testing the third approach saving each ANode into  
it's own NSData and writing a number of those into the file archive:


It's not recommended, but have you tried using old-style archiving as  
another approach?  It used to be considerably faster than keyed  
archiving under some circumstances.


--
Adam
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Quincey Morris


On Jun 18, 2008, at 16:31, Markus Spoettl wrote:

I'm not exactly sure about the speed, blocking the UI for 15 seconds  
isn't the best idea and the real data will be even bigger. So, a  
cure for NSKeyedArchiver's optimization would be great.


The fastest, easiest approach would be to put your doubles as raw  
bytes into NSData objects, as Michael Ash suggested.


Endianness should be easy to deal with, since you have the various  
NSSwap... functions to assist you.


Perhaps floating point representation would not be an issue. It's  
years since I needed to know, but maybe all current Macs (Intel and  
PPC) use the same floating point representation for the 'double' type?  
The documentation, or a knowledgeable lurker, should be able to answer  
that for you. Or, manually decompose each double into a (56 bit?)  
integer mantissa and a (8 bit?) integer exponent.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Binding the current table view selection to property in my controller

2008-06-18 Thread Rick Mann
I have a window controller that provides a list of ports displayed in  
a table view. The master-detail view I set up works fine, and I can  
adjust attributes of individual ports as you would expect.


However, I want my window controller to have a "current port" property  
that reflects the current selection in the table view. This seems like  
an obvious thing to be able to do, but I don't see how to do it.


Could someone please explain? Thanks!

--
Rick

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Markus Spoettl

On Jun 18, 2008, at 2:50 PM, Quincey Morris wrote:
I suppose you could byte-move each group of 4 doubles in one NSData  
and give that to the archiver instead. Or do it further upstream and  
make a bigger array of numbers in a NSData. (But you'll have to deal  
with endianness and -- egads! -- floating point representation  
issues across architectures yourself.)



I've now completed testing the third approach saving each ANode into  
it's own NSData and writing a number of those into the file archive:


Optimization  Write TimeFile Size
- ----
None4:48 min   17.2 MB
4-double NSData 0:10 min   38.3 MB
Upstream NSData 0:15 min   12.1 MB

Surprisingly the file size is 1/3 smaller with the latest approach,  
the save time is still too long but much better than the original  
(almost 5 minutes).


I'm not exactly sure about the speed, blocking the UI for 15 seconds  
isn't the best idea and the real data will be even bigger. So, a cure  
for NSKeyedArchiver's optimization would be great.


Anyway, this is certainly interesting to learn all this, thanks for  
your help!


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Working if Cocoa Core Data

2008-06-18 Thread Thiago Rossi
An idea… If the transaction object knows the previous one, the get balance
method would return the current transaction amount +++plus the previous
transaction (if it is not nil). It would be more than an array, but a list…
But in core data it is not that simple, I guess.
On Wed, Jun 18, 2008 at 7:52 PM, Thiago Rossi <[EMAIL PROTECTED]>
wrote:

> It was not that clear on the tutorial. =)
> I was studying Objective C and I had started to implement the classes of my
> project by hand when I saw that tutorial about Core Data. That was when I
> moved my "DTO" to Core Data. I think I have to make them by hand.
>
> And about the amount/balance and so on… I think I was misunderstood. What I
> wanted is not a sum of all of my transactions. But, when I saw all of my
> transactions of an specific account, it shows the "evolution"øæ of my
> account…
>
> Quincey understood me rightly. I don(R)'t know what OT means, but I got his
> point and agree with him. :)
>
> Thanks all for the support.
>
> I know it is just a beginner doubt and that I was supposed to have gone
> deeper on the subjects, but just starting… My first Mac came just a few
> months ago!
>
> Hamish, thanks for the link! Very helpful.
>
>
> On Wed, Jun 18, 2008 at 3:47 PM, I. Savant <[EMAIL PROTECTED]>
> wrote:
>
>> > Can anyone please help me?
>>
>>   No. At least not at present. There have been many discussions
>> (several very long ones recently) about the fact that - as stated in
>> the documentation - Core Data is most emphatically NOT a beginner
>> technology. Any effort spent trying to help you run before you can
>> crawl will be massive and fruitless.
>>
>>  Core Data, Bindings, etc. need to be approached only *after* you've
>> become comfortably familiar with Cocoa, its frameworks, and its design
>> patterns.
>>
>> --
>> I.S.
>>
>
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Working if Cocoa Core Data

2008-06-18 Thread Thiago Rossi
It was not that clear on the tutorial. =)
I was studying Objective C and I had started to implement the classes of my
project by hand when I saw that tutorial about Core Data. That was when I
moved my "DTO" to Core Data. I think I have to make them by hand.

And about the amount/balance and so on… I think I was misunderstood. What I
wanted is not a sum of all of my transactions. But, when I saw all of my
transactions of an specific account, it shows the "evolution"øæ of my
account…

Quincey understood me rightly. I don(R)'t know what OT means, but I got his
point and agree with him. :)

Thanks all for the support.

I know it is just a beginner doubt and that I was supposed to have gone
deeper on the subjects, but just starting… My first Mac came just a few
months ago!

Hamish, thanks for the link! Very helpful.

On Wed, Jun 18, 2008 at 3:47 PM, I. Savant <[EMAIL PROTECTED]>
wrote:

> > Can anyone please help me?
>
>   No. At least not at present. There have been many discussions
> (several very long ones recently) about the fact that - as stated in
> the documentation - Core Data is most emphatically NOT a beginner
> technology. Any effort spent trying to help you run before you can
> crawl will be massive and fruitless.
>
>  Core Data, Bindings, etc. need to be approached only *after* you've
> become comfortably familiar with Cocoa, its frameworks, and its design
> patterns.
>
> --
> I.S.
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSOpenPanel setDirectory to a package

2008-06-18 Thread Ken Thomases

On Jun 18, 2008, at 5:18 PM, Dale Jensen wrote:

I have an "application picker" bit in my preferences, which allows  
the user to select an app to do something.  90% of the time, I  
presume, this will be a package, not a single file.  My code is thus:


[oPanel setTreatsFilePackagesAsDirectories: NO];
NSString *filePath = @"/Applications/Preview.app";  // just for  
example, it doesn't really default this way

[oPanel setDirectory:filePath];

I think those are the only relevant bits.  When then open panel  
comes up, the application is selected, and you're looking at the  
root level of the package (ie: "Contents").  That's not what I  
want, and not what I think the above code should result in.  I  
think that it should show the applications folder, with Preview  
selected (but not "open" to the Contents folder.)


I disagree.  There's a difference between restricting what the user  
can do and a program restricting what it can do to itself.   
setTreatsFilePackagesAsDirectories:NO is about the program  
restricting the user, not itself.  If the program then proceeds to  
tell the NSOpenPanel to start in a particular directory, it should do  
so, even if that would not be something the user would be allowed to do.


To accomplish what you want, you should specify the filename to the  
begin... or runModal... method that you invoke.


Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Markus Spoettl

On Jun 18, 2008, at 2:50 PM, Quincey Morris wrote:
I suppose you could byte-move each group of 4 doubles in one NSData  
and give that to the archiver instead. Or do it further upstream and  
make a bigger array of numbers in a NSData. (But you'll have to deal  
with endianness and -- egads! -- floating point representation  
issues across architectures yourself.)


Perhaps you could avoid the endianness and representation issues by  
archiving each group of 4 doubles (with a different archive object)  
into a NSData and give that to your main archiver. This sounds like  
it would be slow, but probably not as slow as what you already tried.


I just tried this. It is slower than saving XML (around 10 seconds),  
which is orders of magnitudes faster than without this "optimization".


One problem is that each 4 double value object gets blown up to 307  
bytes when in its NSData container. That makes the overall file  
increase from 18MB to 38MB. That's a bit of a problem and compressing  
the data won't make things faster, so that's not an option.


I'll try the further upstream approach, it should lower the memory  
impact but I will pay for that with much slower performance - I'll  
report back how that turns out.


Probably the real answer is that NSKeyedArchiver isn't designed to  
handle such large numbers of objects efficiently.



It's more like "lots of numbers" rather than "lots of objects". It  
doesn't matter whether the doubles are located in separate objects or  
not. Iit would be nice to see a warning in the documentation if such a  
design limitation really exists - it may be a bug.


Anyway thanks for your input!

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

NSOpenPanel setDirectory to a package

2008-06-18 Thread Dale Jensen
I have an "application picker" bit in my preferences, which allows the  
user to select an app to do something.  90% of the time, I presume,  
this will be a package, not a single file.  My code is thus:


[oPanel setTreatsFilePackagesAsDirectories: NO];
NSString *filePath = @"/Applications/Preview.app";  // just for  
example, it doesn't really default this way

[oPanel setDirectory:filePath];

I think those are the only relevant bits.  When then open panel comes  
up, the application is selected, and you're looking at the root level  
of the package (ie: "Contents").  That's not what I want, and not what  
I think the above code should result in.  I think that it should show  
the applications folder, with Preview selected (but not "open" to the  
Contents folder.)


If you follow a similar process in Safari to change the default RSS  
reader in Preferences > RSS, it performs as expected, so there must be  
a way to get it working, but it doesn't seem obvious.


Thanks for any pointers!


dale



___

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

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

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

This email sent to [EMAIL PROTECTED]


NSPathControl, Bindings and Shared User Defaults

2008-06-18 Thread Jeremy Matthews

Anyone out there binding multiple NSPathControls in IB?

I can do it programatically, but when I attempt to use multiple  
NSPathControls the only item that ends up in the users' plist is the  
most recent one modified...


I'm using a "newer" version of Xcode Tools, but the same thing happens  
under the 3.0.1 distro.


Thanks,
jeremy
___

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

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

2008-06-18 Thread Quincey Morris


On Jun 18, 2008, at 14:17, Markus Spoettl wrote:

Exactly and the test data isn't particularly big. Any ideas how to  
tell the archiver not to do this with my doubles (that doesn't  
involve conversion to strings and back)?


I suppose you could byte-move each group of 4 doubles in one NSData  
and give that to the archiver instead. Or do it further upstream and  
make a bigger array of numbers in a NSData. (But you'll have to deal  
with endianness and -- egads! -- floating point representation issues  
across architectures yourself.)


Perhaps you could avoid the endianness and representation issues by  
archiving each group of 4 doubles (with a different archive object)  
into a NSData and give that to your main archiver. This sounds like it  
would be slow, but probably not as slow as what you already tried.


Probably the real answer is that NSKeyedArchiver isn't designed to  
handle such large numbers of objects efficiently.



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: [Q] UTF-8, stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding, weirdness

2008-06-18 Thread Michael Ash
On Wed, Jun 18, 2008 at 5:07 PM, JongAm Park
<[EMAIL PROTECTED]> wrote:
> Thank you for the additional information.
>
> Interestingly I found a similar method in NSFileManager,
> fileSystemRepresentationWithPath.
> So, is there any document on which file system uses which representation?

"Filesystem representation" is a property of the OS, not of an
individual filesystem. It is not the representation of one filesystem,
but rather the representation used by the filesystem as a whole, as
opposed to pieces of the system unrelated to files.

The NSString and NSFileManager methods produce identical results as
far as I know, so use whichever one you like better.

> Also, is there any reason why a program, like the FCP, prefers the
> decomposed string over precomposed string?
> Will there be a problem, if a program expect decomposed string and its
> client program sends precomposed one to the server?
> (Well.. it depends on implementation of the programs.. )

A properly written program will accept any equivalent form of a string
as being the same as any other, unless it specifically says that it
requires a particular form. That said, many programs are buggy. The
Mac OS X kernel was a great example of this. Up to, I think, 10.2, the
kernel didn't properly convert all unicode sequences to the preferred
filesystem form, leading to buggy behavior if you gave it sequences it
didn't like. On more recent versions you can use any valid UTF-8 and
the kernel will convert it to the internal format that it requires.

In conclusion, you can probably send any form, but if you want to be
really careful, figure out what form the remote program "prefers" and
convert to that form before sending.

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: disappearing NSSpellingStateAttributeName

2008-06-18 Thread Martin Wierschin
Does anyone know what causes the  
_clearTemporaryAttributesForCharacterRange method to get called...  
and have theories on why it's being called in my app and why the  
NSSpellingStateAttributeName that it is clearing isn't being replaced?


I believe that method should only be called when the character  
contents of the text storage have changed, not the attributes. I  
would guess that your syntax coloring (or other attribute  
modifications) are making their changes within a bracketed edit (eg:  
while a beginEditing call hasn't been closed by a corresponding  
endEditing). Basically the edited range/flags are all unioned  
together so it would all appear as one giant text change to the  
layout manager. Imagine the call sequence:


NSTextStorage* ts = whatever;
[ts beginEditing];
[ts replaceCharactersInRange:NSMakeRange(0,0) withString:@"x"];
	[ts addAttribute:NSWhateverAttributeName value:whatever  
range:NSMakeRange(0, [ts length])];

[ts endEditing];

When the layout manager is notified from processEditing the  
editedMask/editedRange will specify both characters and attributes  
have changed across the whole storage. Thus the layout manager would  
clear away temporary attributes for the entire storage.


~Martin

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Michael Ash
On Wed, Jun 18, 2008 at 5:17 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> On Jun 18, 2008, at 1:59 PM, Quincey Morris wrote:
>>
>> Yes, but look at where the time is *really* being spent. At a guess,
>> finishEncoding is comparing every number object against every other number
>> object to see if it can archive just one object of each distinct numeric
>> value. With the number of objects you said you're using, this O(n**2)
>> optimization -- if that's what it's doing -- is hideously expensive.
>
>
> Exactly and the test data isn't particularly big. Any ideas how to tell the
> archiver not to do this with my doubles (that doesn't involve conversion to
> strings and back)?

Although it partially defeats the purpose of using NSCoder, you'll
avoid this whole path if you stuff all four doubles into a single
NSData. Don't forget to use the byte-swapping functions to ensure that
they all have a consistent representation across architectures.

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: [Q] UTF-8 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding weirdness

2008-06-18 Thread JongAm Park


I even didn't think about the normalization. Wow.. it is quite 
complicated.
I tried the 4 methods, 
-precomposedStringWith[Canonical/Compatibility]Mapping and 
-decomposedStringWith[Canonical/Compatibility]Mapping.


The result was that [NSString UTF8String] returns "precomposed" version


That's not quite accurate.  Any given string will be in precomposed or 
decomposed form (or it might not be normalized to either form, and 
have a mix).  Whatever form that string is in, -UTF8String will 
maintain it.  So, -UTF8String doesn't necessarily return "precomposed" 
form, it just so happens that the string you got was already in 
precomposed form.



You are right. It depends on an original string. The NSString is quite 
smart...



, while the one used in the FCP was "decomposed".


The low-level file-system APIs on Mac OS X use what Apple calls 
"file-system representation", which is mostly decomposed (NFD) with 
some specific exceptions.  So, any time you obtain a file name from 
the file-system -- by enumerating a directory or from an NSOpenPanel, 
for example -- it's likely to be mostly decomposed.  This is true even 
if the name originally used to create the file was passed in 
precomposed form.


If you want the string in a specific normalization form for some 
reason, you need to transform it using the above methods.  Don't rely 
on "file-system representation" being in any particular form.  You can 
compare strings without regard for normalization form using one of the 
-compare:... methods and _not_ specifying NSLiteralSearch.  Note that 
isEqual: and isEqualToString: _do_ specify NSLiteralSearch (or the 
equivalent) and so can report NO for two strings which display 
identically.


Cheers,
Ken

I tested with the compare: method. It could return "Same" when a 
decomposed string is compared with a composed string.
So, when Unicode is to be handled, it would be safer if the compare: 
function is used instead of isEqual.


( NSString even provides comparison with localized strings. I'm 
impressed!!! )


Thank you for the good information. Although I have used the NSString, I 
didn't know what those methods really meant. But now, I opened my eyes!!!

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Working if Cocoa Core Data

2008-06-18 Thread Quincey Morris


On Jun 18, 2008, at 13:04, Ben Trumbull wrote:

*Amount* is an calculated field and it depends on the previous  
transactions.
I don't know how to do it! It is not a value I can save on  
database, for

example, because it changes all the time (I guess I have to mark the
transient field at Core Data).


As someone else mentioned, you probably want to move "amount" over  
to Account as "balance".  You can make it transient.


Given that the OP seemed to want to display cumulative balances with  
each displayed transaction (like a Quicken register does), a single  
account balance property doesn't really help.


And the right approach (whatever it is) is a little bit subtle, I  
think. If there are multiple transactions with the same sort key (the  
same date, in the OP's example), or the transactions might be listed  
in various orders, you'd have to accumulate the balance based on the  
actual displayed order, so it's unlikely that it could be kept in the  
data model (e.g. as a Core Data property) unless you added transient  
sets of report items separately from the set of transactions. In a  
way, the balance is a transient property of the "V" rather than the "M".


This is a bit OT, I guess, but it's interesting to notice that Cocoa  
doesn't seem to have any standard coding patterns that would deal with  
this simple-seeming case.



___

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

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

2008-06-18 Thread Markus Spoettl

On Jun 18, 2008, at 1:59 PM, Quincey Morris wrote:
Yes, but look at where the time is *really* being spent. At a guess,  
finishEncoding is comparing every number object against every other  
number object to see if it can archive just one object of each  
distinct numeric value. With the number of objects you said you're  
using, this O(n**2) optimization -- if that's what it's doing -- is  
hideously expensive.



Exactly and the test data isn't particularly big. Any ideas how to  
tell the archiver not to do this with my doubles (that doesn't involve  
conversion to strings and back)?


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: [Q] UTF-8, stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding, weirdness

2008-06-18 Thread JongAm Park

Thank you for the additional information.

Interestingly I found a similar method in NSFileManager, 
fileSystemRepresentationWithPath.
So, is there any document on which file system uses which representation?

Also, is there any reason why a program, like the FCP, prefers the decomposed 
string over precomposed string?
Will there be a problem, if a program expect decomposed string and its client 
program sends precomposed one to the server?
(Well.. it depends on implementation of the programs.. )

Sure looks like it, based on the data.  EC 9E 90 is U+C790, "�"; E1  
84 8C E1 85 A1 is U+110C "ᄌ", U+1161 "ᅡ", which is the decomposed  
version of the same thing.  -[NSString fileSystemRepresentation] may

also be of use here, given that this is really a file path -- the
normalization form used for file names is dictated by the file system.

--Chris Nebel
AppleScript Engineering


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: [Q] UTF-8 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding weirdness

2008-06-18 Thread Ken Thomases

On Jun 18, 2008, at 3:47 PM, JongAm Park wrote:


Thank you very much for the information.


You're welcome.


I even didn't think about the normalization. Wow.. it is quite  
complicated.
I tried the 4 methods, -precomposedStringWith[Canonical/ 
Compatibility]Mapping and -decomposedStringWith[Canonical/ 
Compatibility]Mapping.


The result was that [NSString UTF8String] returns "precomposed"  
version


That's not quite accurate.  Any given string will be in precomposed  
or decomposed form (or it might not be normalized to either form, and  
have a mix).  Whatever form that string is in, -UTF8String will  
maintain it.  So, -UTF8String doesn't necessarily return  
"precomposed" form, it just so happens that the string you got was  
already in precomposed form.




, while the one used in the FCP was "decomposed".


The low-level file-system APIs on Mac OS X use what Apple calls "file- 
system representation", which is mostly decomposed (NFD) with some  
specific exceptions.  So, any time you obtain a file name from the  
file-system -- by enumerating a directory or from an NSOpenPanel, for  
example -- it's likely to be mostly decomposed.  This is true even if  
the name originally used to create the file was passed in precomposed  
form.


If you want the string in a specific normalization form for some  
reason, you need to transform it using the above methods.  Don't rely  
on "file-system representation" being in any particular form.  You  
can compare strings without regard for normalization form using one  
of the -compare:... methods and _not_ specifying NSLiteralSearch.   
Note that isEqual: and isEqualToString: _do_ specify NSLiteralSearch  
(or the equivalent) and so can report NO for two strings which  
display identically.


Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Quincey Morris


On Jun 18, 2008, at 13:06, Markus Spoettl wrote:

I did profile it but it's not my code that is slow. It's the call to  
[archiver finishEncoding] that's taking so long (see the Shark trace  
below.


Regards
Markus

	3.5%	57.0%	CoreFoundation	
__CFSetFindBuckets2	
	2.6%	52.0%	CoreFoundation	 
__plistNumberEqual	
	4.0%	27.9%	CoreFoundation	  
CFEqual	
	1.1%	23.7%	CoreFoundation	   
__CFNumberEqual	
	10.3%	22.6%	CoreFoundation	
CFNumberCompare	
	6.9%	11.9%	CoreFoundation	 
__CFNumberGetValue	
	3.8%	3.8%	commpage  
[libSystem.B.dylib]	 __memcpy	

...
	4.9%	20.5%	CoreFoundation	  
CFNumberIsFloatType	
	15.6%	15.6%	CoreFoundation	   
CFNumberGetType	


Yes, but look at where the time is *really* being spent. At a guess,  
finishEncoding is comparing every number object against every other  
number object to see if it can archive just one object of each  
distinct numeric value. With the number of objects you said you're  
using, this O(n**2) optimization -- if that's what it's doing -- is  
hideously expensive.



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Rethinking my approach; rather overwhelmed.

2008-06-18 Thread Shawn Erickson
On Tue, Jun 17, 2008 at 9:28 PM, Josh de Lioncourt
<[EMAIL PROTECTED]> wrote:
> Hi Louis and Andy,
>
> I'm certainly looking at this suggestion, but another developer suggested
> that I may be better served by hooking into the keyboard input functionality
> of OpenGL.  Assuming that have focus on an NSWindow doesn't interfere with
> such an implementation, I'd be able to accomplish the input through a
> non-platform specific API, potentially making my code even more portable
> between Windows and OS X.
>
> Is there any reason why I shouldn't consider OpenGL for input?

Personally avoid GLUT. It isn't well designed for any serious
application development.

Use a simple Cocoa application shell to host your OpenGL engine or as
a secondary choice consider SDL (sorry not following this thread 100%
so I really don't have a clear picture of the application you are
trying to develop). Anyway you may get better assistance on the
Mac-Games-Dev list.

-Shawn
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting all subclasses

2008-06-18 Thread Christopher Nebel
That depends on what you mean by "automatically".  If you read the  
documentation, you'll see this bit:


"The load message is sent to classes and categories that are both  
dynamically loaded and statically linked, but only if the newly loaded  
class or category implements a method that can respond."


So, the method will be called "automatically" upon load, but only if  
each subclass implements its own +load implementation, which probably  
is more trouble than you want.  Also, there's no guarantee about the  
order +load calls are issued, so a subclass's +load might get called  
before its superclass's, and +load is considered bad performance juju,  
since it makes the system do work regardless of whether or not the  
application uses the class.  +initialize doesn't have those problems,  
but it does have a different one -- notice the second sentence,  
quoting here from the +initialize documentation:


"The runtime sends initialize to each class in a program exactly one  
time just before the class, or any class that inherits from it, is  
sent its first message from within the program. (Thus the method may  
never be invoked if the class is not used.)"


That makes it unsuitable (or at least kind of risky) for the find-all- 
the-subclasses task originally described.  objc_getClassList really is  
the right approach, though I'll note that caching the result doesn't  
work if new classes get loaded dynamically.



--Chris N.

On Jun 18, 2008, at 10:24 AM, Jean-Daniel Dupas wrote:

IIRC, +initialize call the super implementation if the child class  
does not override it, but not the +load method that is called  
exactly once per class and per categorie.

So +load will not be called automatically.


Le 18 juin 08 à 18:57, Mike Abdullah a écrit :

Another option would be to write a +load method in your abstract  
superclass that will be automatically called for any subclasses and  
register them with the superclass.


Mike.

On 18 Jun 2008, at 16:45, Laurent Cerveau wrote:


Fantastic!
Thanks to you and Omar.

laurent

On Jun 18, 2008, at 9:28 AM, Graham Cox wrote:

If you need a list of subclasses of a class, there isn't a built- 
in function - you have to test them one at a time. However I had  
the exact same need recently and wrote a little helper class to  
do it. One thing I ran into in my situation is that I really  
needed to prevent +initialize from ever getting called, because  
some low-level classes in the Cocoa framework wrote certain  
messages to the log when they were invoked (because they are  
obsolete and shouldn't be used) but testing for the class itself  
was enough to trigger this.


So, my code uses a lower-level function. Here it is:




@interface DKRuntimeHelper : NSObject

+ (NSArray*)allClasses;
+ (NSArray*)allClassesOfKind:(Class) aClass;


@end



@implementation DKRuntimeHelper


+ (NSArray*)allClasses
{
return [self allClassesOfKind:[NSObject class]];
}


+ (NSArray*)allClassesOfKind:(Class) aClass
{
	// returns a list of all Class objects that are of kind   
or a subclass of it currently registered in the runtime. This  
caches the
	// result so that the relatively expensive run-through is only  
performed the first time


static NSMutableDictionary* cache = nil;

if ( cache == nil )
cache = [[NSMutableDictionary alloc] init];

// is the list already cached?

	NSArray* cachedList = [cache  
objectForKey:NSStringFromClass( aClass )];


if ( cachedList != nil )
return cachedList;

// if here, list wasn't in the cache, so build it the hard way

NSMutableArray* list = [NSMutableArray array];

Class*  buffer = NULL;
Class   cl;

int i, numClasses = objc_getClassList( NULL, 0 );

if( numClasses > 0 )
{
buffer = malloc( sizeof(Class) * numClasses );

NSAssert( buffer != nil, @"couldn't allocate the buffer");

(void)  objc_getClassList( buffer, numClasses );

		// go through the list and carefully check whether the class  
can respond to isSubclassOfClass: - if so, add it to the list.


for( i = 0; i < numClasses; ++i )
{
cl = buffer[i];

if( classIsSubclassOfClass( cl, aClass ))
[list addObject:cl];
}

free( buffer );
}

// save in cache for next time

[cache setObject:list forKey:NSStringFromClass( aClass )];

return list;
}

@end



BOOLclassIsNSObject( const Class aClass )
{
	// returns YES if  is an NSObject derivative, otherwise  
NO. It does this without invoking

Re: [Q] UTF-8 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding weirdness

2008-06-18 Thread JongAm Park

Thank you very much for the information.

I even didn't think about the normalization. Wow.. it is quite complicated.
I tried the 4 methods, 
-precomposedStringWith*[Canonical/Compatibility]*Mapping and 
-decomposedStringWith*[Canonical/Compatibility]*Mapping.


The result was that [NSString UTF8String] returns "precomposed" version, 
while the one used in the FCP was "decomposed".


Thank you again.

Ken Thomases wrote:

On Jun 18, 2008, at 1:49 PM, JongAm Park wrote:

Can anyone tell me why the two different data source are displayed as 
same "자연", while what it contains are different?


I haven't looked into the specific character sequences in-depth, but I 
suspect the difference is in Normalization Forms.  Specifically, form 
C vs. D.


http://unicode.org/reports/tr15/

The idea is that the same character can be obtained from a single code 
point or by several combining code points.


In Cocoa, see -precomposedStringWithCanonicalMapping and 
-decomposedStringWithCanonicalMapping.


Cheers,
Ken


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Working if Cocoa Core Data

2008-06-18 Thread Hamish Allan
On Wed, Jun 18, 2008 at 7:33 PM, Thiago Rossi <[EMAIL PROTECTED]> wrote:

> *Amount* is an calculated field and it depends on the previous transactions.
> I don't know how to do it! It is not a value I can save on database, for
> example, because it changes all the time (I guess I have to mark the
> transient field at Core Data).

You may also wish to look at this recend thread:

http://www.cocoabuilder.com/archive/message/cocoa/2008/4/21/204765

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Q] UTF-8 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding weirdness

2008-06-18 Thread Christopher Nebel

On Jun 18, 2008, at 12:24 PM, Ken Thomases wrote:


On Jun 18, 2008, at 1:49 PM, JongAm Park wrote:

Can anyone tell me why the two different data source are displayed  
as same "자연", while what it contains are different?


I haven't looked into the specific character sequences in-depth, but  
I suspect the difference is in Normalization Forms.  Specifically,  
form C vs. D.


http://unicode.org/reports/tr15/

The idea is that the same character can be obtained from a single  
code point or by several combining code points.


In Cocoa, see -precomposedStringWithCanonicalMapping and - 
decomposedStringWithCanonicalMapping.


Sure looks like it, based on the data.  EC 9E 90 is U+C790, "자"; E1  
84 8C E1 85 A1 is U+110C "ᄌ", U+1161 "ᅡ", which is the decomposed  
version of the same thing.  -[NSString fileSystemRepresentation] may  
also be of use here, given that this is really a file path -- the  
normalization form used for file names is dictated by the file system.



--Chris Nebel
AppleScript Engineering

___

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

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

2008-06-18 Thread Aron Nopanen


On 19/06/2008, at 7:21 AM, Nathan wrote:

On Wed, Jun 18, 2008 at 4:41 AM, Michael Kaye <[EMAIL PROTECTED]>  
wrote:
wow, I'm another one just starting the same challenge...how many of  
us

newbies are there working through Hillegaas at the moment?


/me raises hand.

I'm currently stuck on challenge 1 in chapter 8 (pg 135):  Make the
application sort people based on the number of characters in their
names using only Interface Builder.

I can do it by cheating (not using Interface Builder), but for the
life of me I can't figure it out using only IB.


The secret is to stick 'length' on the end of the sortKey, and use  
'compare:' as the selector.  I.e., 'length' can be treated as a read- 
only property of the string, of type NSUInteger.

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: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Markus Spoettl

On Jun 18, 2008, at 12:35 PM, Michael Ash wrote:

I saw no mention in your message; have you profiled your app yet? Even
though the time is not being spent in your code, a profile can give
you an idea of what's taking up all this time, and may give you hints
as to how to make it go faster. First response to any speed problem
should always be to run Shark on it.



I did profile it but it's not my code that is slow. It's the call to  
[archiver finishEncoding] that's taking so long (see the Shark trace  
below.


Regards
Markus

	0.0%	98.2%	Foundation	-[NSKeyedArchiver  
finishEncoding]	
	0.0%	98.2%	CoreFoundation	  
__CFBinaryPlistWriteToStream	

0.0%98.2%   CoreFoundation
_flattenPlist 
0.0%98.2%   CoreFoundation 
_flattenPlist
	0.0%	98.2%	CoreFoundation	 
_flattenPlist	
	0.0%	98.1%	CoreFoundation	  
_flattenPlist	
	0.0%	81.9%	CoreFoundation	   
CFSetAddValue	
	3.5%	57.0%	CoreFoundation	
__CFSetFindBuckets2	
	2.6%	52.0%	CoreFoundation	 
__plistNumberEqual	

4.0%27.9%   CoreFoundation   
CFEqual
	1.1%	23.7%	CoreFoundation	   
__CFNumberEqual	
	10.3%	22.6%	CoreFoundation	
CFNumberCompare	
	6.9%	11.9%	CoreFoundation	 
__CFNumberGetValue	
	3.8%	3.8%	commpage  
[libSystem.B.dylib]	 __memcpy	
	0.8%	0.8%	CoreFoundation	  
dyld_stub_memmove	
	0.4%	0.4%	libSystem.B.dylib	  
memmove	
	0.4%	0.4%	commpage  
[libSystem.B.dylib]	__memcpy	
	0.0%	0.0%	CoreFoundation	
__CFNumberGetValue	
	0.2%	0.2%	CoreFoundation	   
CFNumberCompare	
	4.9%	20.5%	CoreFoundation	  
CFNumberIsFloatType	
	15.6%	15.6%	CoreFoundation	   
CFNumberGetType	
	0.6%	0.6%	CoreFoundation	  
CFNumberGetType	
	0.4%	0.4%	CoreFoundation	  
__CFNumberEqual	
	1.2%	1.2%	CoreFoundation	 
CFNumberIsFloatType	

0.2%0.2%CoreFoundation  
CFEqual 
	0.0%	0.0%	CoreFoundation	 
__CFNumberHash	
	0.0%	0.0%	CoreFoundation	 
__CFStringHash	

0.0%0.0%CoreFoundation  
_CFHash 
0.0%0.0%CoreFoundation  
CFHash  
	0.0%	24.7%	CoreFoundation	
__CFSetGrow	
	1.5%	24.6%	CoreFoundation	 
__CFSetFindBuckets2	
	0.1%	0.1%	CoreFoundation	 
__plistNumberEqual	

0.0%0.0%CoreFoundation  
_CFHash 
	0.0%	0.0%	CoreFoundation	 
__CFNumberHash	
	0.3%	0.3%	CoreFoundation	
__plistNumberEqual	
	0.0%	0.0%	CoreFoundation	
__CFNumberHash	
	0.0%	16.0%	CoreFoundation	   
CFSetGetValue	
	1.2%	15.9%	CoreFoundation	
__CFSetFindBuckets1b	
	1.1%	14.1%	CoreFoundation	 
__plistNumberEqual	
	2.0%	7.4%	CoreFoundation	  
CFNumberIsFloatType	

0.8%5.4%CoreFoundation   
CFEqual
	0.2%	0.2%	CoreFoundation	  
CFNumberGetType	
	0.1%	0.1%	CoreFoundation	  
__CFNumberEqual	
	0.4%	0.4%	CoreFoundation	 
CFNumberIsFloatType	

0.0%0.0%CoreFoundation  
CFEqual 
	0.0%	0.0%	CoreFoundation	 
__CFStringHash	
	0.0%	0.0%	CoreFoundation	 
__CFNumberHash	

0.0%0.0%CoreFoundation  
CFHash  
0.0%0.0%CoreFoundation  
_CFHash 
	0.1%	0.1%	CoreFoundation	
__plistNumberEqual	
	0.0%	0.0%	CoreFoundation	
__CFNumberHash	
	0.0%	0.1%	CoreFoundation	   
CFArrayAppendValue	
	0.0%	0.1%	CoreFoundation	  

re: Working if Cocoa Core Data

2008-06-18 Thread Ben Trumbull

*- I'm a Java programmer who wants to migrate to ObjC/Cocoa.*


Welcome.

Unlike some of the others, I don't think Core Data requires an 
advanced degree in Cocoa.  However, in my experience, trying to learn 
both Cocoa Bindings and Core Data simultaneously overwhelms many 
people new to Cocoa.


Both technologies are designed to eliminate a lot of tedious adaptor 
code.  But if you don't have any idea what that code was supposed to 
have done, it can be quite difficult to debug.


My recommendation would be one of the following:

(1) Focus on learning the UI and Cocoa Bindings.  This is spending a 
lot of time in Interface Builder, and learning about application 
delegates and the AppKit widgets.  Pick the 'Cocoa Application' 
template.


(2) Focus on learning Foundation & Core Data.  Build a command line 
tool that does the Core Data processing you're trying to learn.  Pick 
the 'Foundation Toool' and add  to your headers 
and the CoreData.framework from /System/Library/Frameworks/ to your 
project in the 'External Frameworks' bucket.


When you're confident, go back and learn the other part.  There's a 
lot of overlap like KVC, KVO, delegates, accessor methods, 
properties, so it's not as bad as it sounds.



*Amount* is an calculated field and it depends on the previous transactions.
I don't know how to do it! It is not a value I can save on database, for
example, because it changes all the time (I guess I have to mark the
transient field at Core Data).


As someone else mentioned, you probably want to move "amount" over to 
Account as "balance".  You can make it transient.


This is probably best handled with custom accessor methods.  Create 
custom subclasses of NSManagedObject for Account and Transaction and 
set them in your model for the corresponding Entities.


You can get a head start on the proper structure and form of Core 
Data accessor methods, by selecting the properties in the model 
editor, and going to the Design->Data Model->Copy ObjC-2.0 
Implementations to Clipboard and pasting them into source and 
deleting all the ones you don't need.


On the Account's NSManagedObject subclass, override -value to check 
if balance is nil.  If it is, iterate over all the transactions, and 
sum them.  Create an NSNumber with the balance and set it.  Then 
return it.


Also, override the to-many accessors for the relationship from 
Account to Transaction.  The Design->Data Model menu will create all 
of them for you.  You can learn more about them in the Foundation 
reference for NSKeyValueCoding's -mutableSetValueForKey: method and 
the 'Key-Value Coding Programming Guide'.  Have them also set balance 
to nil.


On the Transaction's NSManagedObject subclass, override -setValue: to 
tell its Account to nil out balance.


Probably missed something, but you get the idea.  It's also possible, 
but more complicated to make 'balance' persistent, and for many of 
these operations to 'fix up' balance by a delta instead of forcing an 
entire recomputation.

--

-Ben
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Michael Ash
On Wed, Jun 18, 2008 at 2:13 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> Hello List,
>
>  I'm having a problem with a performance problem in NSKeyedArchiver which I
> can't find a cause for.

I saw no mention in your message; have you profiled your app yet? Even
though the time is not being spent in your code, a profile can give
you an idea of what's taking up all this time, and may give you hints
as to how to make it go faster. First response to any speed problem
should always be to run Shark on it.

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: Trying to get hang of PDO

2008-06-18 Thread Waldo Lee Sharvey
I'm getting SIGBUS errors when my  [connection rootProxy] is called.

On Wed, Jun 18, 2008 at 3:00 PM, I. Savant <[EMAIL PROTECTED]>
wrote:

> On Wed, Jun 18, 2008 at 2:54 PM, Waldo Lee Sharvey
> <[EMAIL PROTECTED]> wrote:
> > Whoops, I had a typo on ClientController's nameserver's portname (it was
> > supposed to be "CommServerPort" and not "ChatterPort")
> > Fixed this, but now I'm getting crashes when the debugger hits [[connect
> > rootProxy] retain].
>
>   "Getting crashes?"
>
>  See:
>  http://www.catb.org/~esr/faqs/smart-questions.html
>
> --
> I.S.
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Q] UTF-8 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding weirdness

2008-06-18 Thread Ken Thomases

On Jun 18, 2008, at 1:49 PM, JongAm Park wrote:

Can anyone tell me why the two different data source are displayed  
as same "자연", while what it contains are different?


I haven't looked into the specific character sequences in-depth, but  
I suspect the difference is in Normalization Forms.  Specifically,  
form C vs. D.


http://unicode.org/reports/tr15/

The idea is that the same character can be obtained from a single  
code point or by several combining code points.


In Cocoa, see -precomposedStringWithCanonicalMapping and - 
decomposedStringWithCanonicalMapping.


Cheers,
Ken___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: unexpected nil outlet

2008-06-18 Thread Nathan
On Wed, Jun 18, 2008 at 4:41 AM, Michael Kaye <[EMAIL PROTECTED]> wrote:
> wow, I'm another one just starting the same challenge...how many of us
> newbies are there working through Hillegaas at the moment?

/me raises hand.

I'm currently stuck on challenge 1 in chapter 8 (pg 135):  Make the
application sort people based on the number of characters in their
names using only Interface Builder.

I can do it by cheating (not using Interface Builder), but for the
life of me I can't figure it out using only IB.

~ Nathan
___

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

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

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

This email sent to [EMAIL PROTECTED]


[ANN] NYC CocoaHeads meeting Thu 6/19

2008-06-18 Thread Andy Lee

WHAT:  Cathy Shive will talk about creating IB plugins.
   Afterwards, food and beer as usual.

WHEN:  Thursday, June 19, 6:00PM (special date this month due to WWDC)

WHERE: The basement at Tekserve, at 119 West 23rd between 6th and 7th,
   http://www.tekserve.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: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Markus Spoettl

On Jun 18, 2008, at 11:25 AM, Kyle Sluder wrote:

On Wed, Jun 18, 2008 at 2:13 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
2) I also noticed that when I use the NSPropertyListXMLFormat_v1_0  
instead
of binary, the process speeds up considerably, taking just below 10  
seconds.
The problem with this is that the output file is huge (100 MB)  
which is too
big for my purposes. Also, decoding the XML data is much slower  
than with

binary data.


Maybe serialize it to an XML plist data object, and then gzip that on
a background thread?  Won't help much with the decompression, I'm
afraid.  Or, you could grap an XML plist blob and then, on a
background thread, reinstate that and write it out again as binary.
This will consume a LOT of memory.  I have this vision that you need
to take a snapshot of the state of your object hierarchy at point X,
so my suggestions might not be that helpful.  It all has to do with
what tradeoffs you're willing to make.


If there is no other solution to it, I may consider this. But I have a  
feeling there's something wrong with the doubles I encode which causes  
the whole mess. Anyway, thanks for the suggestion.



Also, what OS and SDK are you using?



Sorry I forgot. I'm on 10.5.3 using Xcode 3.0 and targeting 10.5+.

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: unexpected nil outlet

2008-06-18 Thread David Reynolds


On 18 Jun 2008, at 13:31, David Reynolds wrote:


Sure, I can email it to you I get home from work if you like?


For anyone following, here is my version of the code:

Controller.h:

#import 

@interface Controller : NSObject {
}
@end

No instance variables and no methods- is this bad?

Controller.m:

#import "Controller.h"

@implementation Controller
- (NSSize)windowWillResize:(NSWindow *)sender
toSize:(NSSize)frameSize
{
NSSize mySize;
mySize.width = frameSize.width;
mySize.height = (frameSize.width / 2);

NSLog(@"mySize is %f wide and %f tall", mySize.width, mySize.height);
return mySize;
}
@end

I set the initial height and width of the window in Interface Builder  
and also set the windows delegate to be my controller instance and I  
think that was it.


As I said earlier, I'd be very interested to know if my method is the  
best or the "right" way to do it and if not, which method is the best.


Thanks for your help

--
David Reynolds
[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: Trying to get hang of PDO

2008-06-18 Thread I. Savant
On Wed, Jun 18, 2008 at 2:54 PM, Waldo Lee Sharvey
<[EMAIL PROTECTED]> wrote:
> Whoops, I had a typo on ClientController's nameserver's portname (it was
> supposed to be "CommServerPort" and not "ChatterPort")
> Fixed this, but now I'm getting crashes when the debugger hits [[connect
> rootProxy] retain].

  "Getting crashes?"

  See:
  http://www.catb.org/~esr/faqs/smart-questions.html

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Trying to get hang of PDO

2008-06-18 Thread Waldo Lee Sharvey
Whoops, I had a typo on ClientController's nameserver's portname (it was
supposed to be "CommServerPort" and not "ChatterPort")
Fixed this, but now I'm getting crashes when the debugger hits [[connect
rootProxy] retain].

On Wed, Jun 18, 2008 at 2:40 PM, Waldo Lee Sharvey <
[EMAIL PROTECTED]> wrote:

>
> For the last several days I've been trying to use Distributed Objects in my
> application to no avail. I've scanned and scoured for multiple pieces of
> documentation over just about everywhere, I've tried one variation of code
> after another, initially trying to use NSSocketPort with domain sockets and
> then dropping down to NSMessagePorts w/ name server (to rule out any socket
> programming issues) and still nothing works.
>
> The below is a mini-sized, minimalistic version of what I've been trying to
> write. It's largely based off the example I found in the Advanced Mac
> Programming book. My (simplified for the time being) goal is to create a
> foundation-tool based daemon that vends a communication object that will let
> a client Cocoa application connect and register as a client via distributed
> objects.
>
> The server seems to run okay, but the client tries to get the vended
> NSMessagePort sendPort, sendPort shows up as nil in the debugger. What am I
> doing wrong/misunderstanding?
>
> # Protocol ##
>
> #import 
>
> @protocol ClientMessages
>
> - (oneway void)printHelloWorld:(NSString *)barcode;
>
> @end
>
> @protocol ServerMessages
>
> - (BOOL)subscribeClient:(in byref id)newclient;
>
> @end
>
> # Daemon Code 
>
> #import 
> #import "CommManager.h"
>
>
> int main (int argc, const char * argv[])
> {
> NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>  NSRunLoop *runloop = [NSRunLoop currentRunLoop];
>  CommManager *commManager = [[CommManager alloc] init];
>  NSMessagePort *receivePort = [[NSMessagePort alloc] init];
>  NSMessagePortNameServer *mpns = [NSMessagePortNameServer sharedInstance];
>  [mpns registerPort:receivePort name:@"CommServerPort"];
>  NSConnection *connection = [NSConnection
> connectionWithReceivePort:receivePort sendPort:nil];
>
> [connection setRootObject: commManager];
>  [runloop run];
>  [pool drain];
> return 0;
> }
>
> ### CommManager.h #
>
> #import 
> #import "CommProtocol.h"
>
> @interface CommManager : NSObject 
> {
> NSMutableArray *clients;
> }
>
> @end
>
> ## CommManager.m ##
>
> #import "CommManager.h"
> #import "CommProtocol.h"
>
> @implementation CommManager
>
> - (BOOL)subscribeClient:(in byref id)newclient
> {
>  [clients addObject: newclient];
>  return YES;
> }
>
> - (void)dealloc
> {
> [clients release];
>  [super dealloc];
> }
>
> @end
>
>
> ### ClientController.h #
>
> #import 
> #import "CommProtocol.h"
>
> @interface ClientController : NSObject 
> {
> id proxy;
> }
>
> @end
>
> ### ClientController.m #
>
>
> #import "ClientController.h"
>
>
> @implementation ClientController
>
> - (void)awakeFromNib
> {
> NSMessagePortNameServer *nameServer = [NSMessagePortNameServer
> sharedInstance];
>  // sendPort shows up as nil in the debugger
> NSMessagePort *sendPort = [nameServer portForName:@"ChatterPort"];
>  NSConnection *connection = [NSConnection connectionWithReceivePort:nil
> sendPort: sendPort];
>  proxy = [[connection rootProxy] retain];
>  [proxy setProtocolForProxy:@protocol(ServerMessages)];
>  BOOL successful = [proxy subscribeClient: self];
>  if(successful)
> {
>  NSLog(@"connected");
> }
> else
>  {
> NSLog(@"not connected");
> }
> }
>
>
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


[Q] UTF-8 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding weirdness

2008-06-18 Thread JongAm Park

Hello, all.

I found a very interesting and strange behaviour of the 
NSString:stringByAddingPercentEscapedUsingEncoding.


I got a UTF-8 string from a Final Cut Pro project file, which is 
exported as an XML.

There is a video clip named "자연", which means "Nature" in Korean.
And its pathurl is 
file://localhost/Users/young/Movies/%E1%84%8C%E1%85%A1%E1%84%8B%E1%85%A7%E1%86%AB.mov

The 자연 part is %E1%84%8C%E1%85%A1%E1%84%8B%E1%85%A7%E1%86%AB.
So, it is percent escaped string.

So, I tried getting a UTF8 version of "자연" by issuing either of :

1. NSString *anUTF16String = [NSString stringWithString:@"자연"];
NSString *anUTF8String = [anUTF16String UTF8String];

or
2. NSString *anUTF8String = [NSString stringWithUTF8String:"자연"];

And they returned same data.

And, I tried making a percent escaped string by calling :
NSString *anUTF8PercentEscapedString = [anUTF8String 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];


And tried reverting back to original string by calling :
NSString *revertedUTF8String = [anUTF8PercentEscapedString 
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];


This gave me the same original data to the one tried in either 1 or 2 above.
And I checked what data it contains by calling :

3. char *revertedCStringOne = (char *)[revertedUTF8String 
cStringUsingEncoding:NSUTF8StringEncoding];


It was : EC 9E 90 EC 97 B0

As I mentioned above, the pathurl string of FCP project looks different 
from the result 3.

So, I tried converting the Korean part of the pathurl by calling :

char test[] ={ 0xE1, 0x84, 0x8C, 0xE1, 0x85, 0xA1, 0xE1, 0x84, 0x8B, 
0xE1, 0x85, 0xA7, 0xE1, 0x86, 0xAB, 0};

length = strlen( test );
for( i = 0; i < length; i++ )
{
NSLog(@"%X", test[i] );
}
printf("\n");

// 4. It prints the same "자연"
NSString *questionedString = [NSString stringWithUTF8String:test];
NSLog(@"Questioned String = %@", questionedString );

and.. when the questionedString is converted to a percent escaped string 
by calling :
NSString *questionedPercentEscapedString = [questionedString 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSLog(@"%@", questionedPercentEscapedString);

It was same to the one in the FCP project pathurl, ie. %E1%84%8C

Can anyone tell me why the two different data source are displayed as 
same "자연", while what it contains are different?
I would like to send an Apple event to the Final Cut Pro, but I'm not 
sure if it is OK to send the percent escaped one like 1 or 2, or the one 
in the FCP project. ( I don't know how to generate the one like in the 
FCP project XML file. )


I also tried a Java applet, 
http://www.profitcode.net/resources/tools/utf8_encoder_applet.html,
and its result is same to the one tried at 1 or 2 above. It is different 
from the one in the FCP project.


I will appreciate any help.

Thank you.


P.S. My whole code is here, just in case.

---

NSString *anUTF16String = [NSString stringWithString:@"자연"];
//NSString *anUTF16PercentEscapedString = [anUTF16String 
stringByAddingPercentEscapesUsingEncoding:NSUTF16StringEncoding];
char *UTF16CString = (char *)[anUTF16String 
cStringUsingEncoding:NSUTF16StringEncoding];


// 1. Making an NSString object with a UTF8 encoding
NSString *anUTF8String = [NSString stringWithUTF8String:"자연"];
NSString *anUTF8PercentEscapedString = [anUTF8String 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *revertedUTF8String = [anUTF8PercentEscapedString 
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
char *revertedCStringOne = (char *)[revertedUTF8String 
cStringUsingEncoding:NSUTF8StringEncoding];


NSLog(@"Unicode 16 : %@", anUTF16String );
//NSLog(@"Unicode 16 Percent Escaped : %@", anUTF16PercentEscapedString );

NSLog(@"Unicode 8 : %@", anUTF8String );
NSLog(@"Unicode 8 Percent Escaped : %@", anUTF8PercentEscapedString );
NSLog(@"Reverted from Unicode 8 Percent Escaped : %@", revertedUTF8String );
NSLog(@"bytes : %s", revertedCStringOne );

// 2. The data : EC 9E 90 EC 97 B0
int length = strlen( revertedCStringOne );
int i;
for( i = 0; i < length; i++ )
{
NSLog(@"%X", revertedCStringOne[i] );
}
printf("\n");

// 3. Data from a Final Cut Pro XML project file which is same to "자연"
// This looks very different from what you can see from // 2.
char test[] ={ 0xE1, 0x84, 0x8C, 0xE1, 0x85, 0xA1, 0xE1, 0x84, 0x8B, 
0xE1, 0x85, 0xA7, 0xE1, 0x86, 0xAB, 0};

length = strlen( test );
for( i = 0; i < length; i++ )
{
NSLog(@"%X", test[i] );
}
printf("\n");

// 4. It prints the same "자연"
NSString *questionedString = [NSString stringWithUTF8String:test];
NSLog(@"Questioned String = %@", questionedString );

// 5. Percent Escape representation of it is same to that of //3 not //2
NSString *questionedPercentEscapedString = [questionedString 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Re: Working if Cocoa Core Data

2008-06-18 Thread I. Savant
> Can anyone please help me?

  No. At least not at present. There have been many discussions
(several very long ones recently) about the fact that - as stated in
the documentation - Core Data is most emphatically NOT a beginner
technology. Any effort spent trying to help you run before you can
crawl will be massive and fruitless.

  Core Data, Bindings, etc. need to be approached only *after* you've
become comfortably familiar with Cocoa, its frameworks, and its design
patterns.

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Working if Cocoa Core Data

2008-06-18 Thread Hal Mueller
1. You really need to master the basics of Cocoa before you tackle  
Core Data.


2. I would move "amount" over on the "Account" entity, and rename it  
"balance".


3.  See #1.

Hal

___

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

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

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

This email sent to [EMAIL PROTECTED]


Trying to get hang of PDO

2008-06-18 Thread Waldo Lee Sharvey
For the last several days I've been trying to use Distributed Objects in my
application to no avail. I've scanned and scoured for multiple pieces of
documentation over just about everywhere, I've tried one variation of code
after another, initially trying to use NSSocketPort with domain sockets and
then dropping down to NSMessagePorts w/ name server (to rule out any socket
programming issues) and still nothing works.

The below is a mini-sized, minimalistic version of what I've been trying to
write. It's largely based off the example I found in the Advanced Mac
Programming book. My (simplified for the time being) goal is to create a
foundation-tool based daemon that vends a communication object that will let
a client Cocoa application connect and register as a client via distributed
objects.

The server seems to run okay, but the client tries to get the vended
NSMessagePort sendPort, sendPort shows up as nil in the debugger. What am I
doing wrong/misunderstanding?

# Protocol ##

#import 

@protocol ClientMessages

- (oneway void)printHelloWorld:(NSString *)barcode;

@end

@protocol ServerMessages

- (BOOL)subscribeClient:(in byref id)newclient;

@end

# Daemon Code 

#import 
#import "CommManager.h"


int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 NSRunLoop *runloop = [NSRunLoop currentRunLoop];
 CommManager *commManager = [[CommManager alloc] init];
 NSMessagePort *receivePort = [[NSMessagePort alloc] init];
 NSMessagePortNameServer *mpns = [NSMessagePortNameServer sharedInstance];
 [mpns registerPort:receivePort name:@"CommServerPort"];
 NSConnection *connection = [NSConnection
connectionWithReceivePort:receivePort sendPort:nil];

[connection setRootObject: commManager];
 [runloop run];
 [pool drain];
return 0;
}

### CommManager.h #

#import 
#import "CommProtocol.h"

@interface CommManager : NSObject 
{
NSMutableArray *clients;
}

@end

## CommManager.m ##

#import "CommManager.h"
#import "CommProtocol.h"

@implementation CommManager

- (BOOL)subscribeClient:(in byref id)newclient
{
[clients addObject: newclient];
 return YES;
}

- (void)dealloc
{
[clients release];
 [super dealloc];
}

@end


### ClientController.h #

#import 
#import "CommProtocol.h"

@interface ClientController : NSObject 
{
id proxy;
}

@end

### ClientController.m #


#import "ClientController.h"


@implementation ClientController

- (void)awakeFromNib
{
NSMessagePortNameServer *nameServer = [NSMessagePortNameServer
sharedInstance];
 // sendPort shows up as nil in the debugger
NSMessagePort *sendPort = [nameServer portForName:@"ChatterPort"];
 NSConnection *connection = [NSConnection connectionWithReceivePort:nil
sendPort: sendPort];
 proxy = [[connection rootProxy] retain];
 [proxy setProtocolForProxy:@protocol(ServerMessages)];
 BOOL successful = [proxy subscribeClient: self];
 if(successful)
{
NSLog(@"connected");
}
else
{
NSLog(@"not connected");
}
}
___

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

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

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

This email sent to [EMAIL PROTECTED]


Working if Cocoa Core Data

2008-06-18 Thread Thiago Rossi
Hello, guys!

I've been studying the Cocoa Core Data and I have a question about it. I
went through a blog tutorial I got at the Internet and I build my first
Cocoa Application. So I decided to do something by my own: a financial
controller.

To make it simple, I used Account and Transaction objects with an
one-to-many relationship. Their properties are:

*Account*
- name

*Transaction*
- date
- description
- value
- amount

*Amount* is an calculated field and it depends on the previous transactions.
I don't know how to do it! It is not a value I can save on database, for
example, because it changes all the time (I guess I have to mark the
transient field at Core Data).

The view would seem something like this:
DateValue Amount
01/01/2008+450.00+450.00
01/02/2008+100.00+550.00
01/02/2008 -50.00+500.00

If I add a transaction between the first and the second after some days, it
would show this (changing all the amount values, except from the ones
before):
DateValue Amount
01/01/2008+450.00+450.00
01/02/2008+200.00+650.00
01/02/2008+100.00+750.00
01/02/2008 -50.00+700.00

Can anyone please help me?

I'm not used to this kind of programming like I wrote an entire blog without
any code line. I guss I have to write some code now, but I don't know how,
when and if I'm not abusing on you, which one.

Thank you!

Thiago.
*- I'm a Java programmer who wants to migrate to ObjC/Cocoa.*
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Swapping splitview subviews

2008-06-18 Thread I. Savant
> Is there a way to swap these subviews? (invert the position).
> Any hint?

  Remove the subviews, then re-add them in the desired order?

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Kyle Sluder
Assuming you don't fix the issue:

On Wed, Jun 18, 2008 at 2:13 PM, Markus Spoettl
<[EMAIL PROTECTED]> wrote:
> 2) I also noticed that when I use the NSPropertyListXMLFormat_v1_0 instead
> of binary, the process speeds up considerably, taking just below 10 seconds.
> The problem with this is that the output file is huge (100 MB) which is too
> big for my purposes. Also, decoding the XML data is much slower than with
> binary data.

Maybe serialize it to an XML plist data object, and then gzip that on
a background thread?  Won't help much with the decompression, I'm
afraid.  Or, you could grap an XML plist blob and then, on a
background thread, reinstate that and write it out again as binary.
This will consume a LOT of memory.  I have this vision that you need
to take a snapshot of the state of your object hierarchy at point X,
so my suggestions might not be that helpful.  It all has to do with
what tradeoffs you're willing to make.

Also, what OS and SDK are you using?

--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: Road to 80 cores ( Was Re: Grand Central Details)

2008-06-18 Thread Kyle Sluder
On Wed, Jun 18, 2008 at 1:50 PM, Pierce T. Wetter III
<[EMAIL PROTECTED]> wrote:
>  The problem is that creating a thread, destroying a thread, and switching
> threads in and out have a LOT of overhead. The above thread is going to
> spend most of its time waiting for I/O, but the OS has no way of knowing
> that really. So the OS swaps in the thread, which looks at its mutex and
> says "I have nothing to do", and then gets swapped out.

I'm sorry but I have to take issue with this.  Are you saying that the
scheduler is not intelligent enough to keep the apps on a blocked
queue until a packet comes in for that handle, at which point the
process is awoken and sent a signal?

>  Trivia: Apache 1.x is even worse then this, it forks off a whole new
> _process() per connection so you have even more overhead. That's one of the
> reasons people tend to put caches in front of apache for performance
> (webperfcache on OSX Server, squid on others).

I'd say the fact that this model is still the default points towards
its persistence as an engineering tradeoff.

But overall I agree with you 100%.  Threads are most useful when you
have a major task (calculate pi) and a minor task (print digits as
they're computed), and do not want or cannot have the minor task
suffer for the major task.  You still want to consume your entire
timeslice with performing the single, heavy task.  Web serving, on the
other hand, is a bajillion tiny tasks, and better methods exist to
accomplish that goal.

--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: NSThread, NSAutoreleasePool and mach_trap_msg

2008-06-18 Thread Bill Bumgarner

On Jun 18, 2008, at 11:10 AM, Georg Schuster wrote:
I'm sorry that I can't post any real code, but does anybody know if  
there are some special things I should keep an eye on when  
programming the WorkerClass? I tried to read every doc about threads  
and autoreleasepools I could get my hands on (including the apple- 
docs), but I just can't find any solution to get rid of that kernel  
trap message.


In general, you don't subclass NSThread as you aren't overriding any  
of its functionality, you are simply using an instance of it.


Instead, your worker class would use...

+ (void)detachNewThreadSelector:(SEL)selector toTarget:(id)target  
withObject:(id)argument;


... to spawn a new thread.

I would fix that first and see if the problem continues.   It may not.

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]

NSKeyedArchiver finishEncoding takes forever

2008-06-18 Thread Markus Spoettl

Hello List,

  I'm having a problem with a performance problem in NSKeyedArchiver  
which I can't find a cause for. Let me first describe the data I'm  
storing:


It's a simple object hierarchy consisting of the following

Root  custom < NSCoding > compliant object
  |-- ANodes  (NSMutableArray)
   |-- A  (custom < NSCoding > compliant object
   |- NNodes  (NSMutableArray)
|- N  (custom < NSCoding > compliant object
   |- 4 double ivars

There is 1 root object with 120 A objects each containing 1000-3000 N  
objects, that makes about 200k N objects in the hierarchy.


For some reason N is causing the performance problem, but in a very  
strange way. The encodeWithCoder method looks like this:


--
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeDouble:v1 forKey:@"v1"];
[encoder encodeDouble:v2 forKey:@"v2"];
[encoder encodeDouble:v3 forKey:@"v3"];
[encoder encodeDouble:v4 forKey:@"v4"];
}
--

v1, v2, v3, v4 are all ivars of N.

It is not the encoding itself that takes so long (the whole hierarchy  
is encoded in less than one second), it's when I call [archiver  
finishEncoding] in my document's dataOfType: which looks like this:


--
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
NSMutableData *data = [[NSMutableData alloc] init];

NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]  
initForWritingWithMutableData: data];

[archiver setOutputFormat: NSPropertyListBinaryFormat_v1_0];

[archiver encodeObject: root forKey:@"root"];

[archiver finishEncoding];

[archiver release];

[data autorelease];

if ((!data) && (outError != NULL)) {
   *outError = [NSError errorWithDomain:NSOSStatusErrorDomain
   code:unimpErr userInfo:NULL];
}

return data;
}
--

With the above mentioned test data it takes more than 5 minutes on my  
MBP 2.5GHz for finishEncoding to complete.


I've experimented and found the following:

1) When I change the values of v1, v2, v3, v4 to 1.0, 2.0, 3.0 and 4.0  
everything works with acceptable speed (the process takes less than 5  
seconds). It's still saving the same hierarchy, just the numbers  
stored are different. How can that be?


2) I also noticed that when I use the NSPropertyListXMLFormat_v1_0  
instead of binary, the process speeds up considerably, taking just  
below 10 seconds. The problem with this is that the output file is  
huge (100 MB) which is too big for my purposes. Also, decoding the XML  
data is much slower than with binary data.


3) I've tried converting the doubles to strings and encode those. This  
also is a lot faster, almost as fast a with "straight" double values.


I've found nothing on Google or the list archives with respect to  
performance of NSArchiver and I'm puzzled. Also instruments isn't  
telling me much except that "flattenProperties" (if I recall  
correctly) is what most of the time is going.


What am I doing wrong? Thanks for any pointers!

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

NSThread, NSAutoreleasePool and mach_trap_msg

2008-06-18 Thread Georg Schuster

Hi,

as I'm fairly new to cocoa-programming, I've stumbled across a problem  
that I can't quite understand.
	- I've made a class (let's call it ThreadClass) that is a subclass of  
NSThread.
	- This class gets invoked from somewhere else via [theThreadClass  
start].

- That invokes ThreadClass's -(void)main
I read the documentation for NSThread and I do understand why you have  
to create an autoreleasepool (at least I hope), so I created one.


The Problem is now the following: I got another class (let's call it  
WorkerClass). And in the ThreadClass, I want to do the following:


- (void)main {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

WorkerClass *wc = [[WorkerClass alloc] init];
[wc doStuff];

[pool release];
}

When I compile this, the program runs up to this point and then  
crashes with a "mach_trap_msg". If I leave out the AutoreleasePool,  
everything works fine, but the program is leaking memory, which is  
obviously not an option.
I found out that if I comment out the [wc doStuff], everything  
compiles fine.


I'm sorry that I can't post any real code, but does anybody know if  
there are some special things I should keep an eye on when programming  
the WorkerClass? I tried to read every doc about threads and  
autoreleasepools I could get my hands on (including the apple-docs),  
but I just can't find any solution to get rid of that kernel trap  
message.


Any help would be greatly appreciated.

Best regards,

  Georg Schuster
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Race condition with awakeFromNib?

2008-06-18 Thread Kyle Sluder
On Wed, Jun 18, 2008 at 1:04 PM, David Carlisle
<[EMAIL PROTECTED]> wrote:
> I have a navigator object which maintains a stack of NSViewControllers.
>  When I create a new NSViewController and push it to the navigator, I want
> the view's back button to show the name of the previous view.  If the
> navigator tries to set the title of the button, the button is still null
> because it has not yet awoke from the nib.

By the time -awakeFromNib is called, all outlets will point to valid
objects.  It sounds like you're doing something too early.

> The navigator can pass the
> previous view to the new view so that when the new view does an
> awakeFromNib, it can get the title of the previous view and set its back
> button accordingly.

This also sounds like bad design.  Perhaps you want to abstract things
a bit further?  I don't know exactly what you're doing, but why do you
have a button that does the same thing on each of your subviews,
rather than one button outside the subviews that sends a -goBack:
action or something of that sort?

> This works, but I'm concerned that if awakeFromNib is
> being done in a separate thread then I have a race condition between
> awakeFromNib and the navigator setting the previous view.  Though it works
> now, might it break with a multicore computer?

AppKit is not thread safe, and everything* is done on the main thread.

--Kyle Sluder

* For some value of "everything".
___

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

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

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

This email sent to [EMAIL PROTECTED]


Swapping splitview subviews

2008-06-18 Thread dexter morgan
Hello,
I'm using NSSplitView with two subviews in both vertical and horizontal
mode.
In awakeFromNib of my code I use -addSubView to fill the first subview (the
other is just filled because I've created it in IB).
Is there a way to swap these subviews? (invert the position).
Any hint?
Thanks.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Race condition with awakeFromNib?

2008-06-18 Thread David Carlisle
I have a navigator object which maintains a stack of  
NSViewControllers.  When I create a new NSViewController and push it  
to the navigator, I want the view's back button to show the name of  
the previous view.  If the navigator tries to set the title of the  
button, the button is still null because it has not yet awoke from the  
nib.  The navigator can pass the previous view to the new view so that  
when the new view does an awakeFromNib, it can get the title of the  
previous view and set its back button accordingly.  This works, but  
I'm concerned that if awakeFromNib is being done in a separate thread  
then I have a race condition between awakeFromNib and the navigator  
setting the previous view.  Though it works now, might it break with a  
multicore computer?

___

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

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

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

This email sent to [EMAIL PROTECTED]


disappearing NSSpellingStateAttributeName

2008-06-18 Thread Jesse Grosjean
I have an NSTextView. Check spelling as you type is enabled. If I  
misspell a word it is correctly underlined with a red line immediately  
after I type the word followed by a whitespace. But then the underline  
is removed when I begin typing a new word.


I'm guessing this is related to some things that I'm doing with the  
text system. I'm doing lots of syntax highlighting and things like  
that. Specifically I'm changing attributes in the underlying text  
storage, and I'm manually updating the text views current selection.  
But I'm not doing anything with temporary attributes, and I'm not  
actually modifying the underlying text.


The trouble is I'm not sure what exactly I'm doing to cause the  
problem. I know that spelling state is implemented with the  
NSSpellingStateAttributeName temporary attribute in the layout manger.  
So to debug things I've subclassed NSLayoutManager and overridden all  
the mutator methods:


- (void)addTemporaryAttributes:(NSDictionary *)attrs forCharacterRange: 
(NSRange)charRange
- (void)addTemporaryAttribute:(NSString *)attrName value:(id)value  
forCharacterRange:(NSRange)charRange
- (void)setTemporaryAttributes:(NSDictionary *)attrs forCharacterRange: 
(NSRange)charRange
- (void)removeTemporaryAttribute:(NSString *)attrName  
forCharacterRange:(NSRange)charRange


But none of those methods seemed to be causing the problem. Then I  
noticed the private method:


- (void)_clearTemporaryAttributesForCharacterRange:(struct  
_NSRange)fp8 changeInLength:(int)fp16


And that's appears to be the one that's removing the  
NSSpellingStateAttributeName, but I'm not sure why. Does anyone know  
what causes the _clearTemporaryAttributesForCharacterRange method to  
get called... and have theories on why it's being called in my app and  
why the NSSpellingStateAttributeName that it is clearing isn't being  
replaced?


Here's a stack.

#0	0x0030777f in -[TPLayoutManager  
_clearTemporaryAttributesForCharacterRange:changeInLength:] at  
TPLayoutManager.m:77
#1	0x913ec1d7 in -[NSLayoutManager  
textStorage:edited:range:changeInLength:invalidatedRange:]
#2	0x913ec144 in -[NSTextStorage  
_notifyEdited:range:changeInLength:invalidatedRange:]

#3  0x914a3212 in -[NSTextStorage processEditing]
#4	0x000e6620 in -[TPEntryAliasStorage processEditing] at  
TPEntryAliasStorage.m:355

#5  0x913d2aef in -[NSTextStorage endEditing]
#6  0x914a0fad in -[NSTextView insertText:replacementRange:]
#7  0x914a04f3 in -[NSTextView insertText:]
#8	0x914a001a in - 
[NSKeyBindingManager(NSKeyBindingManager_MultiClients)  
flushTextForClient:]

#9  0x9149e56f in -[NSTSMInputContext interpretKeyEvents:]
#10 0x9149e03a in -[NSView interpretKeyEvents:]
#11 0x9149df4a in -[NSTextView keyDown:]
#12	0x0030a500 in -[TPEntryAliasesTextView keyDown:] at  
TPEntryAliasesTextView.m:161

#13 0x9140e4c5 in -[NSWindow sendEvent:]
#14 0x913da431 in -[NSApplication sendEvent:]
#15 0x91337e27 in -[NSApplication run]
#16 0x91305030 in NSApplicationMain
#17 0x253d in main at main.m:17

___

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

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

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

This email sent to [EMAIL PROTECTED]


Road to 80 cores ( Was Re: Grand Central Details)

2008-06-18 Thread Pierce T. Wetter III




  Topic/focus changed to please the moderator.

Too bad you can't avoid blocking at least occasionally with the  
event-driven APIs, meaning you still have to use threads to avoid  
it completely. And I fail to see what's so bad about having one  
thread per socket. Is it because Threads Are Hard?


In that case, it is because threads are relatively expensive.
Every thread adds a bit of memory use -- not insignificant given  
each individual thread's stack -- and scheduling overhead.   In this  
model, you'd expect that most threads will be blocked on I/O most of  
the time, but you might also likely find that performance goes to  
hell in a handbasket as soon as multiple sockets are lit up with  
inbound data.


And, yes, threads are hard, though -- in this case -- that hardness  
is a bit irrelevant in that the real challenge is how to get data  
*out* of the thread dealing with network I/O and *into* the threads  
dealing with data.


  Bill and others have nailed it, but I'll expand and talk about what  
I'd like to see in MacOSX to support middle-ground parallelism in Snow  
Leopard ala SEDA or some other mechanism. I don't really want that  
much, so who knows, maybe it will happen and Apple will provide an  
NSOperationQueueGroup class. I'll use a simplified webserver as a model.


 Let's start with some back of the envelope calculations.

  3 GHz 64-bit processor running on a 1 GHz backplane = 64 gigabits/ 
second.


  100 Megabit link to the internet at our colocation site, or .1  
gigabits.


  CPU load to keep the pipe full to the internet: .64%. Except I have  
8 cores, so make that

  .08%.

  IntrAnet? Ok, 1 gigabit/second means .8% CPU load.

  Except you never see that low of a CPU load. You never see that  
because its much, much easier to write code like the following for a  
webserver:


   socket=openSocket(PORT_80);
   listen(socket);
   connection=connect(socket);
   SpawnThread(socketThread(connection))


   socketThread(connection)
   {
  while (moreData)
  {
  request=read(connection);
  cachedFile=loadFileIntoCache(request);
  send(cachedFile, connection);
   }
   disconnect(connection);
   }


   In fact, nearly every introductory programming book in the world  
tells you to do it that way. Because the two sections are very linear,  
its much easier to think "I need to do this, then I need to do that,  
and I'll wrap it in a thread so I can be doing this and that in  
parallel".


 The problem is that creating a thread, destroying a thread, and  
switching threads in and out have a LOT of overhead. The above thread  
is going to spend most of its time waiting for I/O, but the OS has no  
way of knowing that really. So the OS swaps in the thread, which looks  
at its mutex and says "I have nothing to do", and then gets swapped out.


 If you spawn a thread per connection, pretty soon your app grinds to  
a halt and can't get anything done.


 Trivia: Apache 1.x is even worse then this, it forks off a whole new  
_process() per connection so you have even more overhead. That's one  
of the reasons people tend to put caches in front of apache for  
performance (webperfcache on OSX Server, squid on others).


 Ironically, its the concept of threads themselves that created this  
problem. If you look at pre-thread programming books they all told you  
do write code like the following:


  socketsWithData=select(opensockets)
  for (socket : socketsWithData)
  {
 serviceSocket()
  }

 That is, the select call lets you pass in a whole bunch of open  
sockets, and it then blocks until one of them has work to do. Remember  
how we only need .08% CPU to keep up with the network pipe? Well you  
can easily do that with one thread for 1000s of sockets.


  The grandson of select is CFNetwork (Or the non-blocking I/O  
classes in Java). What CFNetwork does is turn all of that into events,  
so you can easily service all the sockets. But as Michael says, "Too  
bad you can't avoid blocking at least occasionally". So what you can  
then do then do to address that is split the processing of that data,  
from the servicing of the sockets. If necessary, you can farm out the  
processing of the data to a thread, or even better, NSOperationQueue.


  So if we revist our "webserver", this means that if we factor in  
CFNetwork, that turns the network code into the following:



   // So first, all of the network bookkeeping gets handled by an  
event model in the same

   // thread.
   socket=openSocket(PORT_80);

   switch (event)
   {
case listen:
listen(socket);
 break;
case connect:
 connection=connect(socket);
 break;
case dataIncoming:
 processData(data);
 break;
case dataOutgoing:
 sendMoreData(data);
 break;
case disconnect:
 disconnect(connection)
   }

   // here, we process the incoming data, a

Re: Getting all subclasses

2008-06-18 Thread Jean-Daniel Dupas


IIRC, +initialize call the super implementation if the child class  
does not override it, but not the +load method that is called exactly  
once per class and per categorie.

So +load will not be called automatically.


Le 18 juin 08 à 18:57, Mike Abdullah a écrit :

Another option would be to write a +load method in your abstract  
superclass that will be automatically called for any subclasses and  
register them with the superclass.


Mike.

On 18 Jun 2008, at 16:45, Laurent Cerveau wrote:


Fantastic!
Thanks to you and Omar.

laurent

On Jun 18, 2008, at 9:28 AM, Graham Cox wrote:

If you need a list of subclasses of a class, there isn't a built- 
in function - you have to test them one at a time. However I had  
the exact same need recently and wrote a little helper class to do  
it. One thing I ran into in my situation is that I really needed  
to prevent +initialize from ever getting called, because some low- 
level classes in the Cocoa framework wrote certain messages to the  
log when they were invoked (because they are obsolete and  
shouldn't be used) but testing for the class itself was enough to  
trigger this.


So, my code uses a lower-level function. Here it is:




@interface DKRuntimeHelper : NSObject

+ (NSArray*)allClasses;
+ (NSArray*)allClassesOfKind:(Class) aClass;


@end



@implementation DKRuntimeHelper


+ (NSArray*)allClasses
{
return [self allClassesOfKind:[NSObject class]];
}


+ (NSArray*)allClassesOfKind:(Class) aClass
{
	// returns a list of all Class objects that are of kind   
or a subclass of it currently registered in the runtime. This  
caches the
	// result so that the relatively expensive run-through is only  
performed the first time


static NSMutableDictionary* cache = nil;

if ( cache == nil )
cache = [[NSMutableDictionary alloc] init];

// is the list already cached?

	NSArray* cachedList = [cache  
objectForKey:NSStringFromClass( aClass )];


if ( cachedList != nil )
return cachedList;

// if here, list wasn't in the cache, so build it the hard way

NSMutableArray* list = [NSMutableArray array];

Class*  buffer = NULL;
Class   cl;

int i, numClasses = objc_getClassList( NULL, 0 );

if( numClasses > 0 )
{
buffer = malloc( sizeof(Class) * numClasses );

NSAssert( buffer != nil, @"couldn't allocate the buffer");

(void)  objc_getClassList( buffer, numClasses );

		// go through the list and carefully check whether the class can  
respond to isSubclassOfClass: - if so, add it to the list.


for( i = 0; i < numClasses; ++i )
{
cl = buffer[i];

if( classIsSubclassOfClass( cl, aClass ))
[list addObject:cl];
}

free( buffer );
}

// save in cache for next time

[cache setObject:list forKey:NSStringFromClass( aClass )];

return list;
}

@end



BOOLclassIsNSObject( const Class aClass )
{
	// returns YES if  is an NSObject derivative, otherwise  
NO. It does this without invoking any methods on the class being  
tested.


return classIsSubclassOfClass( aClass, [NSObject class]);
}


BOOL	classIsSubclassOfClass( const Class aClass, const Class  
subclass )

{
Class   temp = aClass;
int match = -1;

	while(( 0 != ( match = strncmp( temp->name, subclass->name,  
strlen( subclass->name  && ( NULL != temp->super_class ))

temp = temp->super_class;

return ( match == 0 );
}




hth,


cheers, Graham




On 18 Jun 2008, at 3:19 pm, Laurent Cerveau wrote:


Hi

Is there a way to get all subclases of a class. I have a class  
that I would call abstract (although I did not find any real way  
to declare some methods as virtual) and would like to get a list  
of all "real" subclass implementations.


Thanks

laurent
___

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

Please do not post admin requests or moderator comments to the  
list.

Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.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/mai

Re: Core Data / Bindings problem: context not notified of add: ?

2008-06-18 Thread Quincey Morris


On Jun 18, 2008, at 03:31, Alain Schartz wrote:

My model consists of an abstract entity A and an entity B, with A  
being B's parent. Each entity is managed by it's own  
NSArrayController (mode set to Entity and correctly bound to the  
context), and each NSArrayController is bound to a NSTableView to  
show me what is going on.


Now When I create a B object (using it's NSArrayController's add:  
function), it shows up correctly in the according table view but  
*sometimes* - impossible to say exactly when or how often - the  
corresponding A object does NOT show up. It does so ONLY when I move  
the mouse in either one of the views. How strange is that!


You're going to have to clarify your question before anyone can give  
you an answer. Array controllers in entity mode don't manage entities,  
they are bound to content sets that contain managed objects. What  
content sets are the array controllers bound to?


If A is an abstract parent entity (i.e. the Core Data equivalent of an  
abstract superclass), there cannot be any actual A objects. If B is  
the only sub-entity of A you defined, everything must be a B object,  
so it's unclear what the A array controller is supposed to be observing.


It sounds like the content set to which the A controller is bound is  
simply not being maintained in a KVO-compliant way. That could explain  
the odd behavior you are seeing.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Getting all subclasses

2008-06-18 Thread Mike Abdullah
Another option would be to write a +load method in your abstract  
superclass that will be automatically called for any subclasses and  
register them with the superclass.


Mike.

On 18 Jun 2008, at 16:45, Laurent Cerveau wrote:


Fantastic!
Thanks to you and Omar.

laurent

On Jun 18, 2008, at 9:28 AM, Graham Cox wrote:

If you need a list of subclasses of a class, there isn't a built-in  
function - you have to test them one at a time. However I had the  
exact same need recently and wrote a little helper class to do it.  
One thing I ran into in my situation is that I really needed to  
prevent +initialize from ever getting called, because some low- 
level classes in the Cocoa framework wrote certain messages to the  
log when they were invoked (because they are obsolete and shouldn't  
be used) but testing for the class itself was enough to trigger this.


So, my code uses a lower-level function. Here it is:




@interface DKRuntimeHelper : NSObject

+ (NSArray*)allClasses;
+ (NSArray*)allClassesOfKind:(Class) aClass;


@end



@implementation DKRuntimeHelper


+ (NSArray*)allClasses
{
return [self allClassesOfKind:[NSObject class]];
}


+ (NSArray*)allClassesOfKind:(Class) aClass
{
	// returns a list of all Class objects that are of kind   
or a subclass of it currently registered in the runtime. This  
caches the
	// result so that the relatively expensive run-through is only  
performed the first time


static NSMutableDictionary* cache = nil;

if ( cache == nil )
cache = [[NSMutableDictionary alloc] init];

// is the list already cached?

	NSArray* cachedList = [cache  
objectForKey:NSStringFromClass( aClass )];


if ( cachedList != nil )
return cachedList;

// if here, list wasn't in the cache, so build it the hard way

NSMutableArray* list = [NSMutableArray array];

Class*  buffer = NULL;
Class   cl;

int i, numClasses = objc_getClassList( NULL, 0 );

if( numClasses > 0 )
{
buffer = malloc( sizeof(Class) * numClasses );

NSAssert( buffer != nil, @"couldn't allocate the buffer");

(void)  objc_getClassList( buffer, numClasses );

		// go through the list and carefully check whether the class can  
respond to isSubclassOfClass: - if so, add it to the list.


for( i = 0; i < numClasses; ++i )
{
cl = buffer[i];

if( classIsSubclassOfClass( cl, aClass ))
[list addObject:cl];
}

free( buffer );
}

// save in cache for next time

[cache setObject:list forKey:NSStringFromClass( aClass )];

return list;
}

@end



BOOLclassIsNSObject( const Class aClass )
{
	// returns YES if  is an NSObject derivative, otherwise  
NO. It does this without invoking any methods on the class being  
tested.


return classIsSubclassOfClass( aClass, [NSObject class]);
}


BOOL	classIsSubclassOfClass( const Class aClass, const Class  
subclass )

{
Class   temp = aClass;
int match = -1;

	while(( 0 != ( match = strncmp( temp->name, subclass->name,  
strlen( subclass->name  && ( NULL != temp->super_class ))

temp = temp->super_class;

return ( match == 0 );
}




hth,


cheers, Graham




On 18 Jun 2008, at 3:19 pm, Laurent Cerveau wrote:


Hi

Is there a way to get all subclases of a class. I have a class  
that I would call abstract (although I did not find any real way  
to declare some methods as virtual) and would like to get a list  
of all "real" subclass implementations.


Thanks

laurent
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.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/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]


___

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

Please do not post admin requests or moderator comments to the list.
Contact the mod

Re: does NSTextField always use UTF8 encoding

2008-06-18 Thread Alastair Houghton

On 18 Jun 2008, at 07:25, Andrew Farmer wrote:

NSStrings are encoding-independent. They represent strings, not  
sequences of bytes.


Not *entirely*.  The docs are a little sloppy on this, unfortunately,  
both for Cocoa and Core Foundation; in both cases they talk about  
"Unicode characters" and suggest that these may be 16-bits in size.   
There was a point in the past where Unicode (as opposed to ISO10646,  
which later merged with it if I've got my history right) was indeed a   
16-bit per "character" encoding, which is probably the reason the docs  
read the way they do, but it isn't really true today and so it's best  
not to think of it that way.


Perhaps more accurately, NSString is a sequence of UTF-16 code units,  
which is not the same thing at all (in fact, the word "character" is  
generally one to avoid because it's often unclear what you mean when  
you use it).


In particular, -characterAtIndex: can return either half of a  
surrogate pair (e.g. if you have a string containing a non-BMP code  
point like MUSICAL SYMBOL G CLEF U+1D11E, which is encoded D834 DD1E  
according to Character Palette, you might get 0xD834 or 0xDD1E, but  
you won't ever get 0x1D11E).  Nor is that the only trap for the  
unwary; you can also get various types of Unicode control codes as  
well as several kinds of combining characters (though the most common  
group is probably accents).


The String Programming Guide does warn about this to some extent:

"If you need to access string objects character-by-character, you must  
understand the Unicode character encoding—specifically, issues related  
to composed character sequences."


Anyway, this is often not a big deal, but in some applications it can  
be so it's worth bearing in mind.


Kind regards,

Alastair.

--
http://alastairs-place.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: Send Key Event to Focused Window

2008-06-18 Thread Bill Cheeseman
on 2008-06-18 7:25 AM, Daniel at [EMAIL PROTECTED] wrote:

> I should be able to
> click on a button (representing a key stroke) and sending the event
> (e.g. Safari) to the right application.

As joar says, look at the Quartz Event Taps API and the Accessibility API.

To try out examples of applications that do what you're trying to do,
download:

1. The free 30-day trial version of PreFab UI Browser
; and

2. The free PreFab Event Taps Testbench
.

They will give you a feel for what is involved in doing this sort of thing
across process boundaries.

--

Bill Cheeseman - [EMAIL PROTECTED]
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com

PreFab Software - www.prefabsoftware.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: Getting all subclasses

2008-06-18 Thread Laurent Cerveau

Fantastic!
Thanks to you and Omar.

laurent

On Jun 18, 2008, at 9:28 AM, Graham Cox wrote:

If you need a list of subclasses of a class, there isn't a built-in  
function - you have to test them one at a time. However I had the  
exact same need recently and wrote a little helper class to do it.  
One thing I ran into in my situation is that I really needed to  
prevent +initialize from ever getting called, because some low-level  
classes in the Cocoa framework wrote certain messages to the log  
when they were invoked (because they are obsolete and shouldn't be  
used) but testing for the class itself was enough to trigger this.


So, my code uses a lower-level function. Here it is:




@interface DKRuntimeHelper : NSObject

+ (NSArray*)allClasses;
+ (NSArray*)allClassesOfKind:(Class) aClass;


@end



@implementation DKRuntimeHelper


+ (NSArray*)allClasses
{
return [self allClassesOfKind:[NSObject class]];
}


+ (NSArray*)allClassesOfKind:(Class) aClass
{
	// returns a list of all Class objects that are of kind  or  
a subclass of it currently registered in the runtime. This caches the
	// result so that the relatively expensive run-through is only  
performed the first time


static NSMutableDictionary* cache = nil;

if ( cache == nil )
cache = [[NSMutableDictionary alloc] init];

// is the list already cached?

	NSArray* cachedList = [cache  
objectForKey:NSStringFromClass( aClass )];


if ( cachedList != nil )
return cachedList;

// if here, list wasn't in the cache, so build it the hard way

NSMutableArray* list = [NSMutableArray array];

Class*  buffer = NULL;
Class   cl;

int i, numClasses = objc_getClassList( NULL, 0 );

if( numClasses > 0 )
{
buffer = malloc( sizeof(Class) * numClasses );

NSAssert( buffer != nil, @"couldn't allocate the buffer");

(void)  objc_getClassList( buffer, numClasses );

		// go through the list and carefully check whether the class can  
respond to isSubclassOfClass: - if so, add it to the list.


for( i = 0; i < numClasses; ++i )
{
cl = buffer[i];

if( classIsSubclassOfClass( cl, aClass ))
[list addObject:cl];
}

free( buffer );
}

// save in cache for next time

[cache setObject:list forKey:NSStringFromClass( aClass )];

return list;
}

@end



BOOLclassIsNSObject( const Class aClass )
{
	// returns YES if  is an NSObject derivative, otherwise NO.  
It does this without invoking any methods on the class being tested.


return classIsSubclassOfClass( aClass, [NSObject class]);
}


BOOL	classIsSubclassOfClass( const Class aClass, const Class  
subclass )

{
Class   temp = aClass;
int match = -1;

	while(( 0 != ( match = strncmp( temp->name, subclass->name,  
strlen( subclass->name  && ( NULL != temp->super_class ))

temp = temp->super_class;

return ( match == 0 );
}




hth,


cheers, Graham




On 18 Jun 2008, at 3:19 pm, Laurent Cerveau wrote:


Hi

Is there a way to get all subclases of a class. I have a class that  
I would call abstract (although I did not find any real way to  
declare some methods as virtual) and would like to get a list of  
all "real" subclass implementations.


Thanks

laurent
___

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

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

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


Core Animation and Live Resize Problems

2008-06-18 Thread Milen Dzhumerov

Hi all,

I've hit a very nasty problem when using Core Animation and doing a  
live resize. Even though I've disabled animations, Core Animation  
messes up the layer when resized for a couple of frames. So, here's  
what I think happens:

- I resize several sublayers and reposition them
- Since the sublayers contain text and have not been redrawn yet, CA  
immediatelly "scales" the previous contents and the layers look awful
- Probable a hundred miliseconds or less after that, CA catches up and  
redraws the layers and all the layers look good again.


But the user-experience is totally ruined. I've a screen-capped the  
problem:
- Doing layout of the sublayers during live-resize: http://www.doc.ic.ac.uk/~md207/ca/PixelatedResize.mov 
 -- note how CA scales the content to the new frame which looks very  
ugly
- Doing layout only at the end of live-resize: http://www.doc.ic.ac.uk/~md207/ca/DelayedResize.mov 
 -- in this case, no ill-effects can be noticed


I've also recorded how scrolling is instantaneous and results in no  
visual artifacts (I guess this is due to the fact that the layers are  
not redrawn but only moved).

The basic algorithm for doing the layout which I use is:
- Start a new CATransaction
- Disable all actions
- Resize all layers to the required size
- Call setNeedsRedraw on the visible ones and schedule the same for  
the others a little bit later (I've tried it both ways - redrawing all  
and only visible and there is no difference to the live resize behavior)

- Commit the transaction

Any help / hints are greatly appreciated,
M
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Send Key Event to Focused Window

2008-06-18 Thread j o a r


On Jun 18, 2008, at 4:25 AM, Daniel wrote:


Basically, I've noticed that the code I'm using works (as it sends the
right event), but it is sent to the wrong "receiver". That means I'm
sending it to my current application, instead I should be able to
click on a button (representing a key stroke) and sending the event
(e.g. Safari) to the right application.



Cocoa is not a "cross-process" API, for the most part, so that would  
be expected.


In the code you posted you used a reference to "NSApp". This is a  
reference to your own application, it's not a reference to some other  
application. The OS prevents you from interacting directly with the  
internals of other applications for stability and security reasons.


You should be able to do what you want using Quartz Event Services.



Is there a way to build a focus-less application/window?



Can you explain what you mean by that?

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: disable manual resizing of NSWindow

2008-06-18 Thread Uli Kusterer


Am 18.06.2008 um 15:15 schrieb Angelo Chen:
In a NSWindow, I'd like to disable manual resizing(don't allow user  
to drag the lower right corner to resize the window), only by  
clicking 'max' and 'restore' icons, possible? the reason is, I put a  
QuickTIme's movieview in the window and the preserving aspect ratio  
is on, manual resizing will not do good.



 Huh? You're not making sense here... an NSWindow can be told to  
maintain an aspect ratio when resizing (or a grid step size). Wouldn't  
it be much better to just set that up correctly instead of removing  
the grow box?


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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: disable manual resizing of NSWindow

2008-06-18 Thread Jean-Daniel Dupas


Le 18 juin 08 à 15:15, Angelo Chen a écrit :


Hi,

Is there a way to do following:

In a NSWindow, I'd like to disable manual resizing(don't allow user  
to drag the lower right corner to resize the window), only by  
clicking 'max' and 'restore' icons, possible? the reason is, I put a  
QuickTIme's movieview in the window and the preserving aspect ratio  
is on, manual resizing will not do good.


Thanks,

Angelo



You can implements the windowWillResize:toSize: delegate method.

Alternatively, you can force the window aspect ratio using -[NSWindow  
setAspectRatio:];





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: Running a daemon

2008-06-18 Thread Ivan C Myrvold


Den 18. juni. 2008 kl. 14:22 skrev [EMAIL PROTECTED]:


Ivan C Myrvold wrote on 2008-06-18 13:07:50:


I have developed a daemon that have an Objective-C class
"ApplicationWatcher" which checks the foreground applications with
NSWorkspace.

In my main I create the ApplicationWatcher, and the class starts an
NSTimer.
This is probably a stupid question, but I want the daemon to continue
running, but at the end of main the daemon quit, even if I have an
NSTimer running.
So what should I do in main to have the daemon running?

In an ordinary Cocoa application the main contains "return
NSApplicationMain(argc, (const char **) argv);", but as this is a
daemon I can't call this.



The bit of NSApplicationMain() which you need to replicate is the run
loop. Timers get scheduled in run loops.  Have a look at the NSRunLoop
documentation (you probably want [[NSRunLoop currentRunLoop] run]).

Cheers,
Graham.


That worked perfectly. Thanks!

Ivan






--
Graham Lee
Senior Macintosh Software Engineer, Sophos

Tel: 01235 540266 (Direct)
Web: http://www.sophos.com
Sophos - Security and Control

Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon,
OX14 3YP, United Kingdom.

Company Reg No 2096520. VAT Reg No GB 348 3873 20.




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: disable manual resizing of NSWindow

2008-06-18 Thread Apparao Mulpuri
If you are creating Window in IB, then in window inspector Uncheck the
reResize checkbox.

In programmatic approach, you have to set the Window's style mask.

- Apparao.

2008/6/18 Angelo Chen <[EMAIL PROTECTED]>:
> Hi,
>
> Is there a way to do following:
>
> In a NSWindow, I'd like to disable manual resizing(don't allow user to drag 
> the lower right corner to resize the window), only by clicking 'max' and 
> 'restore' icons, possible? the reason is, I put a QuickTIme's movieview in 
> the window and the preserving aspect ratio is on, manual resizing will not do 
> good.
>
> Thanks,
>
> Angelo
>
>
>
>
>  Yahoo! Mail具備一流的網上安全保護功能,請前往 http://hk.antispam.yahoo.com/ 了解更多相關資訊!
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/apparao.forums%40gmail.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]

disable manual resizing of NSWindow

2008-06-18 Thread Angelo Chen
Hi,

Is there a way to do following:

In a NSWindow, I'd like to disable manual resizing(don't allow user to drag the 
lower right corner to resize the window), only by clicking 'max' and 'restore' 
icons, possible? the reason is, I put a QuickTIme's movieview in the window and 
the preserving aspect ratio is on, manual resizing will not do good. 

Thanks,

Angelo

 


  Yahoo! Mail具備一流的網上安全保護功能,請前往 http://hk.antispam.yahoo.com/ 了解更多相關資訊!
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: unexpected nil outlet

2008-06-18 Thread David Reynolds


On 18 Jun 2008, at 11:41 am, Michael Kaye wrote:

wow, I'm another one just starting the same challenge...how many of  
us newbies are there working through Hillegaas at the moment?


I would love to see your solution...when I complete it maybe we  
should exchange off list?



Sure, I can email it to you I get home from work if you like?

Thanks,

David

--
David Reynolds
[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: Running a daemon

2008-06-18 Thread Graham . Lee
Ivan C Myrvold wrote on 2008-06-18 13:07:50:

> I have developed a daemon that have an Objective-C class 
> "ApplicationWatcher" which checks the foreground applications with 
> NSWorkspace.
> 
> In my main I create the ApplicationWatcher, and the class starts an 
> NSTimer.
> This is probably a stupid question, but I want the daemon to continue 
> running, but at the end of main the daemon quit, even if I have an 
> NSTimer running.
> So what should I do in main to have the daemon running?
> 
> In an ordinary Cocoa application the main contains "return 
> NSApplicationMain(argc, (const char **) argv);", but as this is a 
> daemon I can't call this.
> 

The bit of NSApplicationMain() which you need to replicate is the run 
loop. Timers get scheduled in run loops.  Have a look at the NSRunLoop 
documentation (you probably want [[NSRunLoop currentRunLoop] run]).

Cheers,
Graham.



-- 
Graham Lee
Senior Macintosh Software Engineer, Sophos

Tel: 01235 540266 (Direct)
Web: http://www.sophos.com
Sophos - Security and Control

Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon,
OX14 3YP, United Kingdom.

Company Reg No 2096520. VAT Reg No GB 348 3873 20.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: does NSTextField always use UTF8 encoding

2008-06-18 Thread Ken Thomases

On Jun 18, 2008, at 1:25 AM, Andrew Farmer wrote:


On 17 Jun 08, at 23:16, Wayne Shao wrote:

In my UI, a user may type in any string into a NSTextField, e.g.
Chinese characters.

Do I assume the return value from

NSString * value = [textField stringValue]

is always encoded with UTF8?


NSStrings are encoding-independent. They represent strings, not  
sequences of bytes.


I need to convert this to a properly url encoded value as a GET  
parameter.


[value  
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] will  
return a string with proper UTF-8 percent escaping.


And if you want to get a byte sequence in a particular encoding from a  
string, you can use one of:


-[NSString cStringUsingEncoding:]
-[NSString getCString:maxLength:encoding:]
-[NSString dataUsingEncoding:allowLossyConversion:]
-[NSString UTF8String]

Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Running a daemon

2008-06-18 Thread Ivan C Myrvold
I have developed a daemon that have an Objective-C class  
"ApplicationWatcher" which checks the foreground applications with  
NSWorkspace.


In my main I create the ApplicationWatcher, and the class starts an  
NSTimer.
This is probably a stupid question, but I want the daemon to continue  
running, but at the end of main the daemon quit, even if I have an  
NSTimer running.

So what should I do in main to have the daemon running?

In an ordinary Cocoa application the main contains "return  
NSApplicationMain(argc, (const char **) argv);", but as this is a  
daemon I can't call this.


Ivan
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Send Key Event to Focused Window

2008-06-18 Thread Daniel
Thank you! I'll read through them.

Basically, I've noticed that the code I'm using works (as it sends the
right event), but it is sent to the wrong "receiver". That means I'm
sending it to my current application, instead I should be able to
click on a button (representing a key stroke) and sending the event
(e.g. Safari) to the right application.

Is there a way to build a focus-less application/window?

Thanks
Daniel

On Wed, Jun 18, 2008 at 9:48 AM, j o a r <[EMAIL PROTECTED]> wrote:
>
> On Jun 18, 2008, at 12:31 AM, Daniel wrote:
>
>> I'm developing a tool for assistive input and my question is how can I
>> send a key event (like a keyboard press event) to the current window
>> (whatever this one could be), for data input.
>
>
> Have you looked at the Quartz Event Services?
>
> 
>
> I assume that you've already familiarized yourself with the Accessibility
> APIs:
>
> 
>
>
> 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]


Displaying high PPI image at proper size

2008-06-18 Thread Loren Ryter
Hello all.

I'm trying to make sure any image included in an RSS feed is displayed at
the proper size.   I've found some images, such as netflix, store 300 dpi
images, which when displayed (in a Growl notification) appear at about 24%
of their "actual" size.

The example I'm working with is this:

http://cdn-0.nflximg.com/us/boxshots/small/70057002.jpg

The image displays correctly in Safari, in Preview, and in Path Finder. Only
in Growl does it seem to have problems (where it appears at about 6x9
pixels) -- but the fact that it opens at 24% in Graphic Converter and shows
300 ppi  (with 64x90 pixels) indicates that its not entirely a Growl problem
-- the other apps are adjusting.

Since I'm actually working in AppleScript Studio and am just passing
parameters on to some custom C class to then pass to Growl, I tried Image
Events first with just plain scaling but it looked horrible (as if it tried
to scale the tiny image without the high res content).

I've scoured google and tried a number of solutions trying to set the image
size to the size of its bitmap representation, such as this, without luck
(still looks tiny):

NSImage *myImage = [NSImage alloc];
myImage = [myImage initWithContentsOfFile:aPath];
NSBitmapImageRep *rep = [[myImage representations] objectAtIndex:0];
int renderedWidth = [rep pixelsWide];
int renderedHeight = [rep pixelsHigh];
//[rep setSize:NSMakeSize(renderedWidth, renderedHeight)];
[myImage setSize:NSMakeSize(renderedWidth, renderedHeight)];
//[myImage addRepresentation:rep];
//[myImage removeRepresentation:[[myImage representations]
objectAtIndex:0]];

(I've tried with and without the commented-out lines.)

Ultimately I have to pass the TIFF representation to Growl, which I suspect
further complicates this:

iconData:[myImage TIFFRepresentation]

I need a general solution where I can pass any image file path to this
method and get the "right" image data to pass to Growl.

I'm a cocoa newbie (going on week 2 here ;-) so image processing is pretty
far over my head already but I'm catching on!

I've posted about this at the Growl forums but have not found a resolution
yet (though PH has been helpful) and would very much like to move on!

http://forums.cocoaforge.com/viewtopic.php?f=6&t=16005&p=106701


___

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

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

2008-06-18 Thread Michael Kaye
wow, I'm another one just starting the same challenge...how many of us  
newbies are there working through Hillegaas at the moment?


I would love to see your solution...when I complete it maybe we should  
exchange off list?


Regards, Michael.

On 18 Jun 2008, at 09:25, David Reynolds wrote:



On 18 Jun 2008, at 1:47 am, William Squires wrote:

I'm trying to code a solution to the challenge "Make a Delegate" in  
chapter 6 of the new Hillegaas book. Here is my AppController.h



Interestingly, I was doing this same challenge last night, and I  
think I did it a slightly different way, but I don't have the code  
on me at the moment. If no one minds, it would be an interesting  
exercise for me to post my code and for more experienced cocoa  
programmers to discuss which is the more 'correct' way of doing it.


I'll post my version of the code this evening, if no one minds?

--
David Reynolds
[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/michaelkaye%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]


Core Data / Bindings problem: context not notified of add: ?

2008-06-18 Thread Alain Schartz
Hello list.

I need help with a problem I suspect being a Core Data / Bindings hickup :

My model consists of an abstract entity A and an entity B, with A being B's 
parent. Each entity is managed by it's own NSArrayController (mode set to 
Entity and correctly bound to the context), and each NSArrayController is bound 
to a NSTableView to show me what is going on.

Now When I create a B object (using it's NSArrayController's add: function), it 
shows up correctly in the according table view but *sometimes* - impossible to 
say exactly when or how often - the corresponding A object does NOT show up. It 
does so ONLY when I move the mouse in either one of the views. How strange is 
that!

I created an observer for the managedObjectContext to see what is going on, and 
this one too is NOT being fired after the add: UNLESS the mouse enters one of 
the aforementioned views.

I tried to processPendingChanges in all kinds of places in my code, to no 
avail. I tried to programatically change the selection of the array controllers 
after each add:, to no avail.

Google doesn't seem to be my friend on this one, any ideas what I am missing ?

Thanks !
Alain
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: [MODERATOR] Re: Two basic questions regarding UITableViewController and ObjC-2.0

2008-06-18 Thread Stefan Wolfrum
thanks & sorry, didn't know.

2008/6/18 Scott Anguish <[EMAIL PROTECTED]>:

> As explained multiple times today, including in the list guidelines that
> were posted on June 15 with the tag "MUST READ" and are sent to every new
> subscriber...
>
>
> Discussing NDA Projects (Snow Leopard and iPhone OS) and Private API
> 
>
> This list is not an appropriate forum for the discussion of issues that are
> covered by non-disclosure. This includes Snow Leopard and iPhone OS 2.0.
> Doing so will violate your NDA and the message will be forwarded to WWDR.
>
> The discussion of Private API is also not appropriate for this list. Using
> private API is strongly discouraged as it can (and often does) change in
> future software revisions. If you feel some private API should be made
> public contact WWDR directly or file a bug using bugreporter.apple.com.
> Please do not advocate for those changes here, it isn't effective.
>
>
>
> On Jun 18, 2008, at 5:27 AM, Stefan Wolfrum wrote:
>
>  Hi all,
>>
>> I hope this is the correct mailing list for iPhone OS questions, too? If
>> not, please redirect me to a more appropriate forum/list.
>>
>
> There is no place to discuss this publicly.
>
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Binding the enabled property of a NSMatrix instance to wether or not a multiple selection on a array controller is made.

2008-06-18 Thread Eloy Duran

Hi list,

I have a NSArrayController and a form (collection of controls) that  
displays attributes for a individual object in the array controller.
One attribute is bound to a NSMatrix (radio buttons) with the  
"Selected Index" binding. This works great.


But now I want to disable the NSMatrix when multiple objects in the  
array controller are selected.
I have this working with NSTextField, by setting "Allows Editing  
Multiple Values Selection" to false and "Conditionally Sets Enabled"  
to true.
I did the same for the NSMatrix under it's "Selected Index" binding,  
but it doesn't work


I have tried checking/unchecking all different sorts of combinations,  
but nothing really helps.

Any suggestions/ideas? Existing code/examples would be great too.

Thanks in advance.

Cheers,
Eloy.
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSURLRequest conditional GET

2008-06-18 Thread Marc Monguio
Some weird things seem to happen with NSURLRequest when used with  
NSURLRequestUseProtocolCachePolicy :


1)
The documentation I've found about "Conditional GET" in the web says I  
should be sending "If-Modified-Since" and "If-None-Match" headers with  
the contents of "Last-Modified" and ETag" headers from the last  
server's answer. However it doesn't look like a NSURLRequest with a  
NSURLRequestUseProtocolCachePolicy is adding the "If-None-Match"  
header. Fortunately it adds the "Last-Modified" header automatically  
so I've tweaked my server-side to be able to work just with this  
header for caching.


Is this a bug in NSURLRequestUseProtocolCachePolicy ?

2)
When debugging the status in the "connection:didReceiveResponse:"  
delegate method the statusCode is always 200. I knew for sure than in  
fact it was being cached so I ran "tcpdump" and I saw that except the  
first call the rest were always Status  Code 304 Not Modified. Why I  
can't see what I really get from the server in my code?


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

{
  NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
  int statusCode = [httpResponse statusCode];
  NSLog(@"StatusCode: %d", statusCode);
// ...

regards,
Marc
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Two basic questions regarding UITableViewController and ObjC-2.0

2008-06-18 Thread Scott Anguish
As explained multiple times today, including in the list guidelines  
that were posted on June 15 with the tag "MUST READ" and are sent to  
every new subscriber...



Discussing NDA Projects (Snow Leopard and iPhone OS) and Private API


This list is not an appropriate forum for the discussion of issues  
that are covered by non-disclosure. This includes Snow Leopard and  
iPhone OS 2.0. Doing so will violate your NDA and the message will be  
forwarded to WWDR.


The discussion of Private API is also not appropriate for this list.  
Using private API is strongly discouraged as it can (and often does)  
change in future software revisions. If you feel some private API  
should be made public contact WWDR directly or file a bug using  
bugreporter.apple.com. Please do not advocate for those changes here,  
it isn't effective.




On Jun 18, 2008, at 5:27 AM, Stefan Wolfrum wrote:


Hi all,

I hope this is the correct mailing list for iPhone OS questions,  
too? If not, please redirect me to a more appropriate forum/list.


There is no place to discuss this publicly.

___

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

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

2008-06-18 Thread Scott Anguish

And again
On Jun 17, 2008, at 8:47 PM, Pierce T. Wetter III wrote:



On Jun 17, 2008, at 5:31 PM, David Wilson wrote:


WWDC is still under NDA, I'm pretty sure no one's allowed to say
anything here beyond whatever mentions have been made to the press.


Well, Apple people are, once they obtain the appropriate  
permissions. Asking on the dev lists is often the best way to nudge  
them a bit, or sometimes someone says "Hint: check here and here on  
ADC".


Though sometimes I wish Apple had an NDA-required list. Even if I  
had to send a notarized form somewhere, the whole NDA thing gets  
annoying sometimes.


I read the press release, and it said "Grand Central is cool, it  
slices your bread for you".


But how exactly does it do that?



Discussing NDA Projects (Snow Leopard and iPhone OS) and Private API


This list is not an appropriate forum for the discussion of issues  
that are covered by non-disclosure. This includes Snow Leopard and  
iPhone OS 2.0. Doing so will violate your NDA and the message will be  
forwarded to WWDR.


The discussion of Private API is also not appropriate for this list.  
Using private API is strongly discouraged as it can (and often does)  
change in future software revisions. If you feel some private API  
should be made public contact WWDR directly or file a bug using  
bugreporter.apple.com. Please do not advocate for those changes here,  
it isn't effective.



___

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

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

2008-06-18 Thread Scott Anguish


On Jun 17, 2008, at 8:17 PM, Pierce T. Wetter III wrote:



 I had a release the week before, plus we didn't have enough tickets  
since WWDC was sold out, so I didn't go. Are there any details on  
Grand Central?



Discussing NDA Projects (Snow Leopard and iPhone OS) and Private API


This list is not an appropriate forum for the discussion of issues  
that are covered by non-disclosure. This includes Snow Leopard and  
iPhone OS 2.0. Doing so will violate your NDA and the message will be  
forwarded to WWDR.


The discussion of Private API is also not appropriate for this list.  
Using private API is strongly discouraged as it can (and often does)  
change in future software revisions. If you feel some private API  
should be made public contact WWDR directly or file a bug using  
bugreporter.apple.com. Please do not advocate for those changes here,  
it isn't effective.



___

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

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

2008-06-18 Thread Scott Anguish


On Jun 17, 2008, at 4:50 PM, Erik Buck wrote:

I am a little bit confused by Scott's statement that "if you use  
layers-hosting views, then you should not rely on view drawing at  
all ... conversely, if you use layer-backed views then you should  
not directly access the views."




and you should be. I hosed the final word.

is should have said if you use layer-backed views then you should not  
directly access the LAYERS.



layer-backed views provides you a facility for providing caching our  
existing view content. views are used for all the interaction
layer-hosting views provides you a means of displaying a layer tree  
that you manage. layers are used for all the interaction.






___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Where to store document window specific setup data

2008-06-18 Thread Bill Cheeseman
on 2008-06-17 9:36 PM, Markus Spoettl at [EMAIL PROTECTED]
wrote:

> Also, if that data is it stored on a per document basis, is it stored
> as a part of the document data or in the user defaults data. Storing
> in the user default database (or someplace else) would remember all
> documents opened by a user but not influence the look and feel if its
> opened by someone or somewhere else.

If the configuration of the views is a matter of individual user preference
and not necessarily tied to the current content of the document, it is
customary to use NSUserDefaults and, for bindings, NSUserDefaultsController.
Cocoa even uses the user defaults database for you for things like window
size and position, if you call -[NSWindow setFrameAutosaveName:], perhaps in
your -awakeFromNib implementation. For other configuration settings, just
code it yourself. For example, I have a window that shows streaming content,
and at the bottom of the window there is a slider that regulates how much
content is allowed to show in the window at any one time (discarding the
excess on the fly). Whenever the slider is adjusted, the current setting of
the slider is stored directly in the user defaults database, and it is
retrieved from there when needed, using a combination of bindings and code.
The setting is remembered between runs of the program, and different users
of the machine can maintain different settings.

But if the configuration of the views reflects the current content of the
document, such as the setting of a text field, checkbox or slider that
displays document content, then you would subclass NSWindowController or use
bindings in conjunction with the document's data to make sure the settings
in the view match the current content of the document.

There may be gray areas. I can imagine situations where the size and
position of the window, for example, might depend upon current document
content, and in that kind of situation you would want to make sure the
document content controls the window size and position so they will appear
correctly when the same document is opened by another user, perhaps on
another computer. You might then, optionally, also update the settings in
the user defaults database, if it would be useful or convenient to allow
other features of your application to retrieve a window's current size and
position from the user defaults database instead of from the document
itself. This might be convenient, for example, if you are locking an
ancillary window or palette to the main document window's current position
on screen.

See Apple's document "User Defaults Programming topics for Cocoa."

--

Bill Cheeseman - [EMAIL PROTECTED]
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com

PreFab Software - www.prefabsoftware.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]


Two basic questions regarding UITableViewController and ObjC-2.0

2008-06-18 Thread Stefan Wolfrum

Hi all,

I hope this is the correct mailing list for iPhone OS questions, too?  
If not, please redirect me to a more appropriate forum/list.


I'm currently learning some basic Cocoa touch stuff and my first app  
is to be a very simple table view with a detail view for each row.
I'm studying the code samples "SimpleDrillDown", "TheElements" and  
"SimpleTableView" (from the TableViewSuite) and came across a few  
questions:


(1) In the demo projects like "SimpleDrillDown", "TheElements",  
"SimpleTableView" (from the TableViewSuite) the array that holds the  
strings/titles of the table view's rows is implemented as a member in  
the AppDelegate class -- not in the subclassed TableViewController  
class. Why? The "View Controller Programming Guide", Version from  
2008-06-09, says (on page 43) that the data source for the table view  
IS the UITableViewController class and in the code snippets I see a  
member "anArrayOfStrings" of the view controller class. So, where  
should I put my data source for the table view rows' titles?


(2) Have a look at the SimpleDrillDown example code. The file  
SimpleDrillDownAppDelegate.h defines a member "NSMutableArray *list"  
in the @interface section.
After this section there's a @property directive that declares the  
member "list" as readonly:

@property (nonatomic, copy, readonly) NSArray *list;
Now take a look at the implementation file  
SimpleDrillDownAppDelegate.m. Unusual, there's another @interface  
section and now the "list" member is declared as readwrite:

@property (nonatomic, copy, readwrite) NSArray *list;
What's the reason behind this? And why is the member a NSMutableArray  
while in the @property statement it's a NSArray?


Also, I understood that the @synthesize directive actually creates the  
accessor methods (setter & getter) for members. Right? There is a  
corresponding line for the "list" member in the .m file:

@synthesize list;
But, additionally, there's another implementation of the setter method  
for the "list" member later in this file (which is, btw, not declared  
in the .h file):

- (void)setList:(NSArray *)newList {
if (list != newList) {
[list release];
list = [newList mutableCopy];
}
}
Why this?

Thanks a lot for your help in advance!! :-)

Stefan.

___

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

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

2008-06-18 Thread Jonathan Dann

Thanks Douglas,

Nice to know I'm not going mad!

Jon

On 16 Jun 2008, at 17:51, douglas a. welton wrote:


Jonathan,

I don't think you missed anything.  I do believe that documentation  
is somewhat misleading for this class.


I was in the same situation as you, so I simply decided to get a  
CGImageRef (with the associated CGImageProperties) from my  
CGImageSourceRef object and use the -(void)setImage:imageProperties:  
method to set my image.


regards,

douglas

PS:  This issue has been discussed on the Quartz list, but at this  
moment Apple Lists archives are doing something funky and I can't  
find the reference for you.


On Jun 16, 2008, at 7:05 AM, Jonathan Dann wrote:


Hi Guys,

I was just looking at passing a CGImageSourceRef to an IKImageView,  
the documentation says you can, but there's not method that accepts  
it as a parameter.  Is this just a feature that isn't present in  
the release?  Are there release notes that this would be in as  
Image Kit isn't in the App Kit release note.


Thanks,

Jon






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: capture modifier key events

2008-06-18 Thread Mattias Arrelid
Hi Apparao,

On Wed, Jun 18, 2008 at 7:55 AM, Apparao Mulpuri
<[EMAIL PROTECTED]> wrote:
> I have a NSTextField, in which i have to update with new string
> value when ever user presses Cmd, Control or Option keys. I have tried
> with keyDown and controlDidChange methods. These are working with
> combination of other keys includes nemuric, character and functional
> keys.
>
> Is there any provision, to capture only modifier keys (with out
> pressing on other keys) events in Cocoa.

If you have a subclass of NSTextField (or any class that inherits from
NSResponder) you could override the flagsChanged: method. It will be
called as soon as the user holds down any of the control keys. Read
more about it in the documentation set on NSResponder.

Good luck
Mattias
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Rethinking my approach; rather overwhelmed.

2008-06-18 Thread Louis Gerbarg
I have not used glut for any OS X based projects, but my impression is
that if you intend to use no OS facilities in the window you are
interacting with then glutKeyboardFunc() and friends should work just
fine. If you want to use a WebView or anything that expects NSEvents
in that window you are probably going to find it much more
complicated. Instead of just consuming the incoming NSEvents you want
and passing on the rest you will need to synthesize NSEvents for
anything you want to pass on.

In general mixing and matching event models is a lot more pain than it
is usually worth. If you are going to write a pure OpenGL based
application then glut will probably serve you well, if you intend to
use any Cocoa facilities (such as WebKit) you are going to have to
work with the native event system at some point along the way, and I
suspect converting glut style events into something the rest of the
stack can use is a lot more (platform specific) code than just
extracting what you want from the NSEvents in the first place.

Louis

On Tue, Jun 17, 2008 at 9:28 PM, Josh de Lioncourt
<[EMAIL PROTECTED]> wrote:
> Hi Louis and Andy,
>
> I'm certainly looking at this suggestion, but another developer suggested
> that I may be better served by hooking into the keyboard input functionality
> of OpenGL.  Assuming that have focus on an NSWindow doesn't interfere with
> such an implementation, I'd be able to accomplish the input through a
> non-platform specific API, potentially making my code even more portable
> between Windows and OS X.
>
> Is there any reason why I shouldn't consider OpenGL for input?
>
>
> Josh de Lioncourt
> Mac-cessibility: http://www.Lioncourt.com
> Twitter: http://twitter.com/Lioncourt
>
>
> "The rich declare themselves poor,
> "And most of us are not sure,
> "If we have too much,
> "But we'll take our chances,
> "'cause God stopped keeping score."
> Praying for Time--George Michael
>
>
>
>
> On Jun 17, 2008, at 5:03 PM, Andreas Monitzer wrote:
>
>> On Jun 18, 2008, at 01:22, Louis Gerbarg wrote:
>>
>>> It sounds like what you want to do is here is subclass NSApplication,
>>> with a replacement implementation of sendEvent that decodes the
>>> incoming events, marshals the NSEvent's parameters, then sends them to
>>> your C++ code for processing. If your C++ code uses them you swallow
>>> the event, if not you pass it onto the superclasses implementation and
>>> the app code will handle them just like any other Cocoa application.
>>
>> Note that this is just what I did for the X-server:
>>
>>
>> http://www.google.com/codesearch?hl=en&q=monitzer+show:Nu3rlWhknBM:x28_xYSo3mE:b82DNfVvtyQ&sa=N&cd=1&ct=rc&cs_p=http://gentoo.osuosl.org/distfiles/X430src-3.tgz&cs_f=xc/programs/Xserver/hw/darwin/quartz/XApplication.m
>>
>> This can serve as an example on how to implement something like this. Just
>> don't forget to declare this subclass to be the principal class of the
>> application bundle.
>>
>> andy
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/lgerbarg%40gmail.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: unexpected nil outlet

2008-06-18 Thread David Reynolds


On 18 Jun 2008, at 1:47 am, William Squires wrote:

I'm trying to code a solution to the challenge "Make a Delegate" in  
chapter 6 of the new Hillegaas book. Here is my AppController.h



Interestingly, I was doing this same challenge last night, and I  
think I did it a slightly different way, but I don't have the code on  
me at the moment. If no one minds, it would be an interesting  
exercise for me to post my code and for more experienced cocoa  
programmers to discuss which is the more 'correct' way of doing it.


I'll post my version of the code this evening, if no one minds?

--
David Reynolds
[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]


  1   2   >