Re: Properties and memory management

2008-08-06 Thread Marcel Weiher


On Aug 5, 2008, at 15:28 , Uli Kusterer wrote:


On 05.08.2008, at 22:24, Marcel Weiher wrote:

On Aug 5, 2008, at 2:57 , Uli Kusterer wrote:

Lucky then, that I adopted GNUstep-style ASSIGN() and DESTROY()  
macros for these purposes, and since most of my code still needs  
to be 10.4-compatible, I've mostly been using those:


So why not go one step further and let macros generate the accessor  
for you (of course using the ASSIGN() macro inside those generated  
accessors)?


Well, I'm using ASSIGN in the mutators. Did you have an even more  
cunning plan that would work?


I am not sure it is cunning, but it's been working for over a decade:   
have macros to generate the accessors for you.



-   snip   --
#define setAccessor( type, var,setVar ) \
-(void)setVar:(type)newVar { \
ASSIGN_ID(var,newVar)\
} \

#define readAccessor( type, var )\
-(type)var  {   return  
var; }


#define objectAccessor( objectType, var, setVar ) \
readAccessor( objectType, var )\
setAccessor( objectType, var,setVar )

#define idAccessor( var, setVar ) objectAccessor( id, var, setVar )
-   snip   --

So to create the accessors for "myVar", just write

idAccessor( myVar, setMyVar )


Cheers,

Marcel



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: "backporting" nibs question / Rhapsody license anyone?

2008-08-06 Thread Ralf Edmund Stranzenbach

Hi,

because i'm currently facing a comparable situation - i'd like to  
migrate old NeXT style mails and mailboxes and also some old NeXTstep  
based applications for my personal use - i'm really interested in any  
possible solutions.


I still have access to some of the early Rhapsody CDs, but i lack Mac  
OS releases prior to 10.4.9 (switched lately to Mac). Is there any  
document describing which releases can be obtained from Apple and wich  
of them are really required for such a migration?


Is there any chance to install those releases on a Parallels or VMware  
virtual machine ?


Regards,

Ralf Edmund Stranzenbach
[EMAIL PROTECTED]



Am 05.08.2008 um 05:40 schrieb Bill Bumgarner:


On Aug 4, 2008, at 3:41 PM, Lars Sonchocky-Helldorf wrote:

Am 04.08.2008 um 23:55 schrieb Bill Bumgarner:

On Aug 4, 2008, at 2:46 PM, Lars Sonchocky-Helldorf wrote:
- So does anyone on this list know of a way to "backport" nibs to  
an earlier version (besides recreating all the nibs from scratch)?


Your problem statement doesn't make sense.  The NIBs don't need to  
be backported.


Well, I indeed want to backport it. I forgot to mention that the  
code I got depends on SoundKit - and this is the reason I want at  
first take a step back in time - to predecessor OPENSTEP 4.2, which  
I got from a colleague and then port it slowly over to MusicKit (http://musickit.sourceforge.net/ 
) which has some similarities to SoundKit and later eventually to  
something more modern. My aim is also to keep that application  
compatible to GNUstep so maybe I don't ditch the MusicKit  
dependency to soon.


Bahh.. sorry -- I misread the original post and, as Jon indicated,  
backporting the NIBs from a later version to an earlier version will  
be exceedingly difficult.


b.bum

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/macbook%40reswi.de

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: Rotate NSString... I give up :(

2008-08-06 Thread Jean-Daniel Dupas

Shouldn't be this instead (check the translations' signs) ?

[tr translateXBy:dx yBy:dy]; // center or rect will be the center of  
rotation

[tr rotateByDegrees:90]; // rotate it
[tr translateXBy:-dx yBy:-dy]; // move it back


Le 6 août 08 à 08:46, Vitaly Ovchinnikov a écrit :


Hello,

I need to draw NSString rotated to 90 degrees. Now I have the code:

NSRect rcWhereToDraw = NSMakeRect(); // <- rect is already
"rotated" here
[str drawInRect:rcWhereToDraw withAttributes:attributes]; // string
will be drawn non-rotated

as far as I know, I need something like this:

[[NSGraphicsContext currentContext] saveGraphicsState];
NSRect rcWhereToDraw = NSMakeRect();

float dx = NSMidX(rcWhereToDraw), dy = NSMidY(rcWhereToDraw);

NSAffineTransform *tr = [NSAffineTransform transform];
[tr translateXBy:-dx yBy:-dy]; // center or rect will be the center  
of rotation

[tr rotateByDegrees:90]; // rotate it
[tr translateXBy:dx yBy:dy]; // move it back
[tr concat];

[str drawInRect:rcWhereToDraw withAttributes:attributes];
[[NSGraphicsContext currentContext] restoreGraphicsState];

This doesn't work, where am I wrong?
Thank you.
___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: "backporting" nibs question / Rhapsody license anyone?

2008-08-06 Thread Bill Bumgarner

On Aug 6, 2008, at 12:19 AM, Ralf Edmund Stranzenbach wrote:
because i'm currently facing a comparable situation - i'd like to  
migrate old NeXT style mails and mailboxes and also some old  
NeXTstep based applications for my personal use - i'm really  
interested in any possible solutions.


You'll also likely want to use the TOPS scripts to migrate from  
NeXTSTEP 3.3 and prior APIs to the modern APIS.  In particular, it  
isn't hard to create a TOPS script to migrate between Display  
PostScript and NSBezier*.   That was the bulk of the migration  
required beyond the default set of NX* -> NS* migration (pre- 
Foundation to post-Foundation).  Though, there are a number of  
functional APIs that could also be migrated.


I still have access to some of the early Rhapsody CDs, but i lack  
Mac OS releases prior to 10.4.9 (switched lately to Mac). Is there  
any document describing which releases can be obtained from Apple  
and wich of them are really required for such a migration?


Small Dog and various other resellers typically have older versions of  
Mac OS X (and Macintosh hardware) available at reasonable prices.  I  
would check with said source.


Is there any chance to install those releases on a Parallels or  
VMware virtual machine ?


Mac OS X, itself, has never supported a VM style installation, as far  
as I know.  Thus, you might be out of luck on that front.


b.bum



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Using performSelector: on super

2008-08-06 Thread Wade Tregaskis
The try/catch setup is well optimized and introduces very little  
overhead. So in the nominal case, where there is no exception,  
there's almost no overhead at all. Even if an exception was  
thrown, NSException is fairly lightweight.


This is not particularly accurate.


There, I'll beg to differ.

Exception handlers are cheap ("zero-cost") to set up in C++ and in  
the

64-bit Objective-C runtime.  They are unfortunately kind of expensive
to set up in 32-bit Objective-C.  They are based on setjmp/longjmp.


setjmp/longjmp is very fast. Or at least it used to. I understand  
that setjmp has slowed down over the years as more and more state  
information needs to be saved to make it work. During my career I've  
implemented setjmp/longjmp a few times and it used to take only  
about a dozen machine instructions to squirrel away the current  
stack pointers into a local structure, return, and perform a  
conditional test. Probably faster than objc_msgSend.


I haven't measured it in ages, but I suspect that it's still  
reasonably fast. I have several performance intensive applications  
that I profile regularly, and my code uses exceptions and try/catch  
blocks a lot. I've never seen setjmp or longjmp show up in Shark as  
a hot spot. So from casual observation, I'd say that try/catch  
blocks don't slow things down too much.


Let me say straight up that I hate exceptions, and code that uses  
them.  So, I am biased, though I've tried not to be with my  
experimentation.


A quick and dirty test program - one which simply throws exceptions as  
fast as possible in a fixed-iteration-count loop, measured using the  
'time' utility - shows me that the whole exception shebang is about  
three or four times more expensive in 64-bit than 32, and that it's at  
least three orders of magnitude slower than returning an int.  (all on  
Intel)  I use that as a somewhat relevant counter-example given the  
traditional argument between error codes and exceptions as prevailing  
models, and given that the original case was using  
instancesRespondToSelector:, which while notably more complex  
ultimately boils down to returning a scalar, rather than creating an  
entire object as with exceptions.  [[ admittedly I'm not considering  
additional messaging overhead ]]


And I quickly discovered the gotcha that since NSExceptions are  
autoreleased, if you happen to be triggering lots of them in a loop  
without explicit pool flushes, you'll unnecessarily enlarge your  
memory footprint.


I'm not presenting numbers since these tests are so primitive, and I  
don't want to go into unnecessary details; the point is well enough  
made.  If anyone wants to do a full analysis with appropriate controls  
and timing and some Shark profiles, be my guest, by all means.


The prevailing wisdom has always been that exceptions are for  
exceptional cases.  Maybe they would more appropriately titled as  
unexpecteds.  Intentionally using them as the foundation for  
determining whether some class supports some optional or unofficial  
interface, or anything of that nature, is a gross abuse of them.  And  
while, granted, you can happily throw thousands, perhaps tens of  
thousands of exceptions a second without a meaningful performance  
impact for most programs, it seems simply a bad and unnecessary habit  
to get into.


The comment that actually riled me enough to jump in on this thread  
was the ever-popular "premature optimisation" card being played.  This  
card is almost always misplayed in discussions like this.  Premature  
optimisation is making a design or implementation choice, on the basis  
of performance, without sufficient facts.  It does not apply  
universally as a wildcard whenever you wish to override someone else's  
approach - arbitrary or not - with your own.  In this case, it is well  
demonstrated and well documented that exceptions are expensive.   
Relying on them for normal control flow is a bad idea, and against  
common wisdom.


It does not need to be proven that it will definitely impact the final  
performance; there is a choice in this case between two functional  
equivalents for which once is clearly more appropriate and less likely  
to become an actual performance issue.  This is not premature  
optimisation, it is simply mindful design.


Wade
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: handling idle events

2008-08-06 Thread Negm-Awad Amin

Hi,


maybe you can use a thread and set the thread priority low. I never  
tried it, just an idea.
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSThread_Class/Reference/Reference.html#/ 
/apple_ref/occ/clm/NSThread/setThreadPriority:


I think, that this a better design, because the main thread can  
interrupt the "idle thread", if the idle thread takes a long time and  
would block the app otherwise.


Amin





Am Mi,06.08.2008 um 04:16 schrieb Jim Crafton:


Is there a way to handle idle time in an NSApplication? In Win32 or
Carbon, since you manually write the actual while loop that processes
the events, this is pretty easy to do. Is there anything like this in
Cocoa? I've got some objects whose state (possibly) needs to be
updated, and I was planning on handling this in the "idle" handler.

My other idea, if this is not possible, would be to simply have a
timer that fires off every 0.5 seconds or so.

Thanks

Jim C
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[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: "backporting" nibs question / Rhapsody license anyone?

2008-08-06 Thread Jean-Daniel Dupas


Le 6 août 08 à 09:50, Bill Bumgarner a écrit :


On Aug 6, 2008, at 12:19 AM, Ralf Edmund Stranzenbach wrote:
because i'm currently facing a comparable situation - i'd like to  
migrate old NeXT style mails and mailboxes and also some old  
NeXTstep based applications for my personal use - i'm really  
interested in any possible solutions.


You'll also likely want to use the TOPS scripts to migrate from  
NeXTSTEP 3.3 and prior APIs to the modern APIS.  In particular, it  
isn't hard to create a TOPS script to migrate between Display  
PostScript and NSBezier*.   That was the bulk of the migration  
required beyond the default set of NX* -> NS* migration (pre- 
Foundation to post-Foundation).  Though, there are a number of  
functional APIs that could also be migrated.


I still have access to some of the early Rhapsody CDs, but i lack  
Mac OS releases prior to 10.4.9 (switched lately to Mac). Is there  
any document describing which releases can be obtained from Apple  
and wich of them are really required for such a migration?


Small Dog and various other resellers typically have older versions  
of Mac OS X (and Macintosh hardware) available at reasonable  
prices.  I would check with said source.


Is there any chance to install those releases on a Parallels or  
VMware virtual machine ?


Mac OS X, itself, has never supported a VM style installation, as  
far as I know.  Thus, you might be out of luck on that front.


b.bum


Especially if you considere that all Mac OS X versions prior to 10.4.x  
are PPC only.



___

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

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

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

This email sent to [EMAIL PROTECTED]


autorelease CGImageRef?

2008-08-06 Thread Peter N Lewis

Given a CGImageRef, how can I autorelease it?

Perhaps this is obvious, or perhaps its impossible, but googling 
hasn't found me the answer yet except for a tantalizing comment in 
the docs for NSBitmapImageRep:


- (CGImageRef)CGImage (added in 10.5)
"Returns an autoreleased CGImage object (an opaque type) from the 
receiver's current bitmap data."


For CFStringRef, I know I can cast it to an NSString* and then 
autorelease it, but is there an equivalent for CGImageRef?


Thanks,
   Peter.

--
  Keyboard Maestro 3 Now Available!
Now With Status Menu triggers!

Keyboard Maestro  Macros for your Mac
   
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Rotate NSString... I give up :(

2008-08-06 Thread Vitaly Ovchinnikov
Will test this too, but I don't think it will work.
In my case I moved rectangle from it's real position to zero, then
rotate around zero and then moved back.
In your case I will move it far from zero and then rotate...
But I will give it a try.

On Wed, Aug 6, 2008 at 11:20 AM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:
> Shouldn't be this instead (check the translations' signs) ?
>
> [tr translateXBy:dx yBy:dy]; // center or rect will be the center of
> rotation
> [tr rotateByDegrees:90]; // rotate it
> [tr translateXBy:-dx yBy:-dy]; // move it back
>
>
> Le 6 août 08 à 08:46, Vitaly Ovchinnikov a écrit :
>
>> Hello,
>>
>> I need to draw NSString rotated to 90 degrees. Now I have the code:
>>
>> NSRect rcWhereToDraw = NSMakeRect(); // <- rect is already
>> "rotated" here
>> [str drawInRect:rcWhereToDraw withAttributes:attributes]; // string
>> will be drawn non-rotated
>>
>> as far as I know, I need something like this:
>>
>> [[NSGraphicsContext currentContext] saveGraphicsState];
>> NSRect rcWhereToDraw = NSMakeRect();
>>
>> float dx = NSMidX(rcWhereToDraw), dy = NSMidY(rcWhereToDraw);
>>
>> NSAffineTransform *tr = [NSAffineTransform transform];
>> [tr translateXBy:-dx yBy:-dy]; // center or rect will be the center of
>> rotation
>> [tr rotateByDegrees:90]; // rotate it
>> [tr translateXBy:dx yBy:dy]; // move it back
>> [tr concat];
>>
>> [str drawInRect:rcWhereToDraw withAttributes:attributes];
>> [[NSGraphicsContext currentContext] restoreGraphicsState];
>>
>> This doesn't work, where am I wrong?
>> Thank you.
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org
>>
>> This email sent to [EMAIL PROTECTED]
>>
>
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Using performSelector: on super

2008-08-06 Thread Negm-Awad Amin


Am Di,05.08.2008 um 22:20 schrieb Andy Lee:


On Aug 5, 2008, at 3:39 PM, I. Savant wrote:

I'm going to make a bold statement: You should only ever call [super
someMethod] from within an overridden someMethod implementation. I
believe this is true in all cases (because I can't at the moment
imagine a case where you'd do otherwise). Third party opinions are
welcome.


The one case that comes to mind is when a designated initializer  
calls its superclass's different designated initializer.


--Andy

Jepp, because of some reasons:

- You should override the DI of the base class, if you define  
additional ivars in the subclass.

- You should call the base' class DI in the subclass' DI.
- You should call the subclass' DI in the subclass' non-DI.

If super would be dispatched dynamically, this would lead to an  
infinite loop. Example:


Superclass NSObject, DI: -init
Baseclass: Instrument, DI: -initWithName:
   -init is overriden to call the DI -initWithName
Subclass: Piano, DI (still) -initWithName:
   -initWithName is overriden for some additional ivars (i.e. keyCount)

Code:
Piano* piano = [[[Piano alloc] init] autorelease];
will call -init (Instrument)

-init (Instrument) uses dynamic dispatched self and calls - 
initWithName: (Piano) (That's correct to give Piano the chance to init  
its ivars.)
-initWithName: (Piano) will call supers -initWithName: (Instrument).  
This would be done correct, even  it is dispacthed dynamivally. The  
instance has the class Piano (look at the alloc) so even the "run- 
times super" is Instrument. Everything nice.
-initWithName: (Instrument) send the -init-Message to its super. There  
is a Problem:
** Dispacthing statically (as it is done), the compiler performs a  
hard-wired call to NSObjects -init. That's correct and the intended  
behaviour.
** Dispatching this dynamically the run-time-system would send this  
message to the superclass of the instance. We have a Piano-instance  
(look at the alloc). The superclass of Piano is Instrument. So,  
dynamically dispatched, -init (INstrument) and *not* -init (NSObject)  
would be called. That''s the point we started: inifinite loop-


You can imagine such situations outside initialization. Buit it is a  
typical init-problem.


Amin





___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[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]


Distributed Objects, NSFileHandle and file transfer

2008-08-06 Thread Gert Andreas

Hi,
i'm currently working on a client-server-system for transferring  
filesets to a server and downloading them.


But i'm still not sure about how to realize the communication and  
especially how to transfer large files.
I'm using dictionaries for transferring the information of the files.  
But how to transfer the data of each file or the whole set.


Using NSData and sending a file at once doesn't work as you need to  
allocate too much memory for large files.
So i made an attempt using distributed objects and vending the  
NSFileHandle from to file on the client side to the server.


- (void)sendFileHandle:(in byref NSFileHandle *)fileHandle;

and the read the file till the end using:
dataToWrite = [fileHandle readDataOfLength:10];

That works indeed great but i'm wondering if it's a good idea using  
DOs for transferring files?
Would it be better to use something like AsyncSockets or Input/ 
Outputstreams?


I'm looking for a solution that uses less memory and provides an easy  
managemend for the chunks of the files.

Any feedback is highly appreciated.

Thanks,
Gert
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: CGGStackRestore: gstack underflow

2008-08-06 Thread Ryan Brown

A shot in the dark...

Are you manually activating the run loop using NSDefaultRunLoopMode? I  
recently encountered the same problem (using Core Animation as well),  
and eventually tracked it down to the way I was waiting for messages  
from a CFMessagePort to arrive. Specifying a custom run loop mode  
caused the problem to go away, and I'm still mystified as to why.


If that isn't it, I'd check that you are using Core Animation  
properly. Is the NSView a layer-hosting or layer-backed view? Does it  
have any NSView subviews or CALayer sublayers? Read this if you  
haven't already:


http://developer.apple.com/documentation/GraphicsImaging/Conceptual/Animation_Overview/ChooseAnimTech/chapter_5_section_3.html#/ 
/apple_ref/doc/uid/TP40004952-CH5-SW4


Best,
Ryan

On Aug 5, 2008, at 10:08 PM, Gordon Apple wrote:


It does not appear to come from anything in my drawing code.  It only
happens when I use layers.   The view in a scroller.  Moving the  
scroll bars
or resizing the window results in a flood of such console messages.  
The

drawLayer:inContext: appears to be balanced:

   NSGraphicsContext *nsGraphicsContext;
   nsGraphicsContext = [NSGraphicsContext
graphicsContextWithGraphicsPort:ctx flipped:YES ];
   [NSGraphicsContext saveGraphicsState];
   [NSGraphicsContext setCurrentContext:nsGraphicsContext];
   ... (My drawing)
   [NSGraphicsContext restoreGraphicsState];

This was straight out of the Core Animation Cookbook.


On 8/5/08 5:09 PM, "Kyle Sluder" <[EMAIL PROTECTED]>  
wrote:



On Tue, Aug 5, 2008 at 5:44 PM, Gordon Apple <[EMAIL PROTECTED]> wrote:

What should I be looking for to find the problem?


I'm not a CoreGraphics expert, but my first instinct is too many  
calls

to -[NSGraphicsContext restoreGraphicsState].

--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/ryan%40wabdo.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: autorelease CGImageRef?

2008-08-06 Thread Mike Abdullah

Since CGImage is derived from CFType you can just do:

[(id)aCGImageRef autorelease]

The reason being that CFType knows how to handle a -release message,  
and autorelease is just a way of deferring that message.


On 6 Aug 2008, at 09:29, Peter N Lewis wrote:


Given a CGImageRef, how can I autorelease it?

Perhaps this is obvious, or perhaps its impossible, but googling  
hasn't found me the answer yet except for a tantalizing comment in  
the docs for NSBitmapImageRep:


- (CGImageRef)CGImage (added in 10.5)
"Returns an autoreleased CGImage object (an opaque type) from the  
receiver's current bitmap data."


For CFStringRef, I know I can cast it to an NSString* and then  
autorelease it, but is there an equivalent for CGImageRef?


Thanks,
  Peter.

--
 Keyboard Maestro 3 Now Available!
   Now With Status Menu triggers!

Keyboard Maestro  Macros for your Mac
   
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to enable/disable buttons immediately after focus transfer

2008-08-06 Thread Negm-Awad Amin

Did you try a subclass of NSWindow and overriding -setFirstResponder:?

Amin
Am Di,05.08.2008 um 15:36 schrieb an0:


I know how to do this for NSValidatedUserInterfaceItem by implementing
`- (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem

)anItem'; however, NSSegmentedControl and NSButton do not conform to

NSValidatedUserInterfaceItem protocol, then how can I switch the
enable status of  these controls as an IMMEDIATE response to the focus
transfer?
Thanks in advance.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[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: Distributed Objects, NSFileHandle and file transfer

2008-08-06 Thread Ken Thomases

On Aug 6, 2008, at 4:07 AM, Gert Andreas wrote:

Using NSData and sending a file at once doesn't work as you need to  
allocate too much memory for large files.
So i made an attempt using distributed objects and vending the  
NSFileHandle from to file on the client side to the server.


- (void)sendFileHandle:(in byref NSFileHandle *)fileHandle;

and the read the file till the end using:
dataToWrite = [fileHandle readDataOfLength:10];

That works indeed great but i'm wondering if it's a good idea using  
DOs for transferring files?


You haven't transferred the file (or even the file handle) to the  
server.  What you've done is create a proxy in the server for the file  
handle object in the client.  Then, the readDataOfLength: message is  
sent to the proxy which forwards it to the client and then a proxy of  
the resulting data object is returned to the server.  This is perhaps  
the worst of all worlds because then all operations on the data object  
proxy will cause further D.O. communication. If readDataOfLength: were  
declared in a protocol to return its result bycopy, then at least  
you'd transfer an actual copy of the data object to the server, where  
it could be used locally without further D.O. overhead, but that  
wouldn't be any better than just sending the data in the first place.


NSFileHandle doesn't adopt the NSCoding protocol and so can't be sent  
by-copy to the server.



If the client and server are on the same computer, you have a couple  
of approaches:


If you really want the server to obtain an open file from the client,  
you may have to use Unix-domain sockets.  See "man unix".  There's no  
Cocoa front-end to this, as far as I know.  Unix domain sockets allow  
you to transfer a file descriptor from one process to another on the  
same computer.  You can use NSFileHandle to obtain the file descriptor  
in the client, and you can create an NSFileHandle from the file  
descriptor once its been transmitted to the server.


(Hmm.  Come to think of it, you may be able to use NSSocketPort and  
NSPortMessage to transmit a file descriptor between processes over a  
Unix-domain socket.)


Another approach would be to transfer the file path to the server, but  
then the file needs to be accessible by the server, which may have  
different access privileges than the client.



If the client and server are on different computers, then you can't  
really avoid the need to transmit the data in the file.  In that case,  
you might want to use NSStream or, if that's not flexible enough, a  
TCP socket you open yourself wrapped in an NSFileHandle.


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]


typedef, bindings, and Objective-C

2008-08-06 Thread patrick machielse
While maintaining some older Obj-C++ code I ran into the following  
issue: typedef'ed pointer/object types break bindings in Objective-C.  
To illustrate, the model code is similar to this:


Model.mm

#import 

typedef NSString MyString;

@interface Model : NSObject {
MyString *text;
}
@end

@implementation Model
- (MyString *)text { return @"testing"; }
@end


In IB the value binding of an NSTextField is connected to the Model's  
'text' property. This works as expected when the code is compiled as  
Objective-C++. Changing to Objective-C still compiles perfectly, but  
when the application starts an exception is thrown inside -[Model  
valueForUndefinedKey:]. This puzzled me, and it took me a while to  
realize that the typedef seemed to be causing this behavior.


Notes:

-) I'm running Mac OS X 10.5.4
-) typedefed ints, floats, etc. work, obviously.
-) -[Model respondsToSelector:@selector(text)] always returns YES,  
even when -[Model valueForKey:@"text"] fails.


Should I have expected this?

patrick
--
Patrick Machielse
Hieper Software

http://www.hieper.nl
[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: KBML Generator/Parser

2008-08-06 Thread Apparao Mulpuri
Sorry, mentioned incorrect url for KBML. Working url for KBML is:
http://koala.ilog.fr/kbml/.

Any pointers on this would greatly help.

Thanks,
- Apparao.




On Wed, Aug 6, 2008 at 11:16 AM, Apparao Mulpuri
<[EMAIL PROTECTED]> wrote:
> Hi Guys,
>
> In my Cocoa application, i am planning to use KBML
> (http://www.inria.fr/koala/kbml/). KBML is pure java application, so i
> need to port it into Cocoa.
>
> I am looking for open source KBML generators/parsers to cut my
> development time. Is anybody aware of such applications?
>
> Thanks In Advance,
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: typedef, bindings, and Objective-C

2008-08-06 Thread Ken Thomases

On Aug 6, 2008, at 5:47 AM, patrick machielse wrote:


typedef NSString MyString;

[...]

In IB the value binding of an NSTextField is connected to the  
Model's 'text' property. This works as expected when the code is  
compiled as Objective-C++. Changing to Objective-C still compiles  
perfectly, but when the application starts an exception is thrown  
inside -[Model valueForUndefinedKey:]. This puzzled me, and it took  
me a while to realize that the typedef seemed to be causing this  
behavior.


[...]
Should I have expected this?


This is obscure enough that I wouldn't have any particular expectation  
one way or another, I guess.


Out of curiosity, what do @encode(MyString*) and @encode(MyString)  
provide in Objective-C vs. Objective-C++?


I know that Key-Value Coding investigates return and parameter types  
of the accessors to figure out whether it needs to wrap non-objects in  
NSValue or NSNumber.  See: .  Also see the notes under "Support for Arbitrary Types in KVC and  
KVO" in the Leopard Foundation release notes .


I suspect KVC uses @encode() or its equivalent to make these  
inquiries.  The compiler may produce different encodings for your  
typedef depending on the language in use.


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: Message Framework and Garbage Collection

2008-08-06 Thread Ruotger Skupin

Hi,

just to let you know:

I'm trying to use the Message Framework with Garbage Collection  
enabled and it crashes deep down in the framework.

I filed a bug: 6128812



You can [...] use Pantomime,
Pantomime is not GC-ready. I haven't tried to switch on CG and see  
what happens though.



Ruotger

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: autorelease CGImageRef?

2008-08-06 Thread Jean-Daniel Dupas
Be carefull when you mix CFType memory management, and obj-c memory  
management.
It works well when you do not use GC, but may become problematic if  
you do not take special care with GC code.


If I'm not wrong, it should be something like this:

[NSMakeCollectable(aCGImageRef) autorelease];


Le 6 août 08 à 12:16, Mike Abdullah a écrit :


Since CGImage is derived from CFType you can just do:

[(id)aCGImageRef autorelease]

The reason being that CFType knows how to handle a -release message,  
and autorelease is just a way of deferring that message.


On 6 Aug 2008, at 09:29, Peter N Lewis wrote:


Given a CGImageRef, how can I autorelease it?

Perhaps this is obvious, or perhaps its impossible, but googling  
hasn't found me the answer yet except for a tantalizing comment in  
the docs for NSBitmapImageRep:


- (CGImageRef)CGImage (added in 10.5)
"Returns an autoreleased CGImage object (an opaque type) from the  
receiver's current bitmap data."


For CFStringRef, I know I can cast it to an NSString* and then  
autorelease it, but is there an equivalent for CGImageRef?


Thanks,
 Peter.

--
Keyboard Maestro 3 Now Available!
  Now With Status Menu triggers!

Keyboard Maestro  Macros for your  
Mac
   download.stairways.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/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: autorelease CGImageRef?

2008-08-06 Thread Negm-Awad Amin


Am Mi,06.08.2008 um 14:26 schrieb Jean-Daniel Dupas:

Be carefull when you mix CFType memory management, and obj-c memory  
management.
It works well when you do not use GC, but may become problematic if  
you do not take special care with GC code.

IIRC, there are some rules:
1 GC respects reference counting. That means, that GC will not  
deallocate any instance with an RC greater than 0.
2 RC methods of objective-C (-retain, -release) are "dead". That means  
that no change of the RC is applied.
3 (1+2) Using GC and -retain, -release leads to the situation, that  
the RC is never greater than 0. So GC behaves as intended: GC respects  
the RC, but there is no RC to respect. (Even it works: You should not  
mix up GC and RC methods.)
4 RC functions of CF are still working. That means, that they do  
change the RC.
5 (1+4) Using CF-RC leads to the situation, that (by CF) referenced  
instances are not collected by the GC.


5 is a feature, because you can hold instances in memory without  
having a reference to it.


Amin




If I'm not wrong, it should be something like this:

[NSMakeCollectable(aCGImageRef) autorelease];


Le 6 août 08 à 12:16, Mike Abdullah a écrit :


Since CGImage is derived from CFType you can just do:

[(id)aCGImageRef autorelease]

The reason being that CFType knows how to handle a -release  
message, and autorelease is just a way of deferring that message.


On 6 Aug 2008, at 09:29, Peter N Lewis wrote:


Given a CGImageRef, how can I autorelease it?

Perhaps this is obvious, or perhaps its impossible, but googling  
hasn't found me the answer yet except for a tantalizing comment in  
the docs for NSBitmapImageRep:


- (CGImageRef)CGImage (added in 10.5)
"Returns an autoreleased CGImage object (an opaque type) from the  
receiver's current bitmap data."


For CFStringRef, I know I can cast it to an NSString* and then  
autorelease it, but is there an equivalent for CGImageRef?


Thanks,
Peter.

--
   Keyboard Maestro 3 Now Available!
 Now With Status Menu triggers!

Keyboard Maestro  Macros for your  
Mac
   

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[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: How to debug a corrupted stack

2008-08-06 Thread Gerriet M. Denkmann


On 6 Aug 2008, at 11:14, Ken Thomases wrote:


On Aug 5, 2008, at 9:51 PM, Gerriet M. Denkmann wrote:

I have a document based app which works perfectly with -O0 or -O1  
but crashes with -O2 or higher.


When the crash occurs the debugger comes up and says: "Previous  
frame identical to this frame (corrupt stack?)"


When I try to step through the function (which is kind of  
difficult, as the optimization has shuffled the lines a lot) at  
some time the top frame of the stack gets duplicated.



Any help would be most welcome. I am completely run out of ideas  
and spent already hours with this bug.


You don't say what kind of crash it is?  EXC_BAD_ACCESS?


I didn't say because no one told me. Especially not gdb. But I ran  
the program outside of Xcode and got a crash report with:


Exception:  EXC_BAD_ACCESS (0x0001)
Codes:  KERN_PROTECTION_FAILURE (0x0002) at 0x

The crash has nothing to do with aliases (they just created diffent  
paths through the code).
The program crashes when both -O2 (or better) and Generate Position- 
Dependend Code are set.


here r20 = 0x90ec (good)
0x2b04  <+0464>  lwz r4,0(r21)
0x2b08  <+0468>  mr  r5,r29
0x2b0c  <+0472>  mr  r3,r24
0x2b10  <+0476>  bla 0xfffeff00  = [ a  
addChild: b ]

now r20 = 0 (bad)
...
0x2b4c  <+0536>  lwz r4,0(r20)< crash here, because r20 = 0
0x2b50  <+0540>  mr  r3,r29
0x2b54  <+0544>  bla 0xfffeff00  = [ b  
release ]


If someone wants to check whether it really is a compiler bug (and  
not just some stupidity on my side) I can send the whole project.

10.4.11 - not tested on 10.5

This was difficult to debug, because -O2 keeps most variables in  
registers, so whenever I did

"po a" I got the answer: "No symbol "a" in current context."
And the two identical stack-frames are maybe a gdb bug (the crash  
report had a normal stack trace).



Anyway - I switched off the Generate Position-Dependend Code (Faster  
function calls for applications)  and all is fine again (after a day  
lost fighting with the compiler).



Kind regards,

Gerriet.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Dumb Q

2008-08-06 Thread William Squires
  What's the proper way to make a C/ObjC program (Foundation tool)  
be used with the pipe operator? I want to make a simple filter that  
takes the output of "ls -la" and reformats it to appear more like the  
MS-DOS directory listing. So, I would do something like "ls -la |  
mydosfilter" and get a directory listing with the filename first, the  
# bytes second, then the timestamp (leaving out everything from the  
UNIX permissions bits to the group, and rearranging the rest.)
  Also, what's the proper place to put the resulting executable so  
all users can use it in Terminal.App without having to do "ls -la |  
" every time. Can I put this in the deployment  
target once the linker is done? Do I need "sudo" to copy there? I  
know just enough tcsh stuff to be dangerous... :)
  Finally, what's the number just after the UNIX permissions bits?  
the PID?


___

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

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

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

This email sent to [EMAIL PROTECTED]


remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Wayne Shao
Hi

Please see the question in the comments of the following code.

NSMutableDictionary* aDictionary = (initialized with some objects)

for (id theKey in aDictionary) {
  id anObject = [[aDictionary objectForKey:theKey] retain];

 [aDictionary removeObjectForKey:theKey];
 // Question: will this removal break or corrupt the loop of enumerating the
elements?

 [anObject someMessage];
}

in java, Iterators allow the caller to remove elements from the underlying
collection during the iteration. is there similar semantics in objective-c?

-- 
Wayne Shao
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Dumb Q

2008-08-06 Thread Thomas Davie


On 6 Aug 2008, at 15:57, William Squires wrote:

 What's the proper way to make a C/ObjC program (Foundation tool) be  
used with the pipe operator? I want to make a simple filter that  
takes the output of "ls -la" and reformats it to appear more like  
the MS-DOS directory listing. So, I would do something like "ls -la  
| mydosfilter" and get a directory listing with the filename first,  
the # bytes second, then the timestamp (leaving out everything from  
the UNIX permissions bits to the group, and rearranging the rest.)


Just read input from standard in, and write output to stardard out.

 Also, what's the proper place to put the resulting executable so  
all users can use it in Terminal.App without having to do "ls -la |  
" every time. Can I put this in the deployment  
target once the linker is done? Do I need "sudo" to copy there? I  
know just enough tcsh stuff to be dangerous... :)


Anywhere on your $PATH variable.  Usually /usr/local/bin or /usr/bin

 Finally, what's the number just after the UNIX permissions bits?  
the PID?


From man ls...
 If the -l option is given, the following information is  
displayed for
 each file: file mode, number of links, owner name, group name,  
number of
 bytes in the file, abbreviated month, day-of-month file was last  
modi-
 fied, hour file last modified, minute file last modified, and  
the path-
 name.  In addition, for each directory whose contents are  
displayed, the
 total number of 512-byte blocks used by the files in the  
directory is
 displayed on a line by itself, immediately before the  
information for the

 files in the directory.  If the file or directory has extended
 attributes, the permissions field printed by the -l option is  
followed by
 a '@' character.  Otherwise, if the file or directory has  
extended secu-
 rity information, the permissions field printed by the -l option  
is fol-

 lowed by a '+' character.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Dumb Q

2008-08-06 Thread Negm-Awad Amin


Am Mi,06.08.2008 um 15:57 schrieb William Squires:

 What's the proper way to make a C/ObjC program (Foundation tool) be  
used with the pipe operator? I want to make a simple filter that  
takes the output of "ls -la" and reformats it to appear more like  
the MS-DOS directory listing. So, I would do something like "ls -la  
| mydosfilter" and get a directory listing with the filename first,  
the # bytes second, then the timestamp (leaving out everything from  
the UNIX permissions bits to the group, and rearranging the rest.)
On UNIX the pipe-in is the stdin., the pipe-out the stdout. So you can  
just read from stdin to get the data piped and write it to stdout.  
(TAKE CARE ABOUT THE SIZE OF CHAR-ARRAYS! *g*)


I think, that this is c-standard …

 Also, what's the proper place to put the resulting executable so  
all users can use it in Terminal.App without having to do "ls -la |  
" every time. Can I put this in the deployment  
target once the linker is done? Do I need "sudo" to copy there? I  
know just enough tcsh stuff to be dangerous... :)
 Finally, what's the number just after the UNIX permissions bits?  
the PID?

A file does not have a PID!?!

man ls:
 The Long Format
 If the -l option is given, the following information is  
displayed for each file: file mode, number of
 links, owner name, group name, number of bytes in the file,  
abbreviated month, day-of-month file was
 last modified, hour file last modified, minute file last  
modified, and the pathname.  In addition, for
 each directory whose contents are displayed, the total number of  
512-byte blocks used by the files in
 the directory is displayed on a line by itself immediately  
before the information for the files in the
 directory.  If the file or directory has extended security  
information, the permissions field printed

 by the -l option is followed by a '+' character.

Amin




___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[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: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Negm-Awad Amin


Am Mi,06.08.2008 um 16:27 schrieb Wayne Shao:


Hi

Please see the question in the comments of the following code.

NSMutableDictionary* aDictionary = (initialized with some objects)

for (id theKey in aDictionary) {
 id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
}

in java, Iterators allow the caller to remove elements from the  
underlying
collection during the iteration. is there similar semantics in  
objective-c?
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_8_section_1.html#/ 
/apple_ref/doc/uid/TP30001163-CH18-SW1


Enumeration is “safe”—the enumerator has a mutation guard so that if  
you attempt to modify the collection during enumeration, an exception  
is raised.


Amin

BTW: This looks like a memory leak …



--
Wayne Shao
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[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: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Wayne Shao
On Wed, Aug 6, 2008 at 7:41 AM, Negm-Awad Amin <[EMAIL PROTECTED]>wrote:

>
> Am Mi,06.08.2008 um 16:27 schrieb Wayne Shao:
>
> Hi
>
> Please see the question in the comments of the following code.
>
> NSMutableDictionary* aDictionary = (initialized with some objects)
>
> for (id theKey in aDictionary) {
>  id anObject = [[aDictionary objectForKey:theKey] retain];
>
> [aDictionary removeObjectForKey:theKey];
> // Question: will this removal break or corrupt the loop of enumerating the
> elements?
>
> [anObject someMessage];
> }
>
> in java, Iterators allow the caller to remove elements from the underlying
> collection during the iteration. is there similar semantics in objective-c?
>
>
> http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_8_section_1.html#/
> /apple_ref/doc/uid/TP30001163-CH18-SW1
>
> Enumeration is "safe"—the enumerator has a mutation guard so that *if you
> a**ttempt to modify the collection during enumeration, an exception is
> raised*.
>

Oh. thanks for the info.   Is there an alternative method to remove during a
loop? (besides the option to   remove elements outside of the loop).





>
> Amin
>
> BTW: This looks like a memory leak …
>

fixed?

for (id theKey in aDictionary) {
 id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of enumerating the
elements?

[anObject someMessage];
[anObject release];
}



>
>
> --
> Wayne Shao
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de
>
> This email sent to [EMAIL PROTECTED]
>
>
> Amin Negm-Awad
> [EMAIL PROTECTED]
>
>
>
>
>


-- 
Wayne Shao
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: autorelease CGImageRef?

2008-08-06 Thread Shawn Erickson
On Wed, Aug 6, 2008 at 6:08 AM, Negm-Awad Amin <[EMAIL PROTECTED]> wrote:
>
> Am Mi,06.08.2008 um 14:26 schrieb Jean-Daniel Dupas:
>
>> Be carefull when you mix CFType memory management, and obj-c memory
>> management.
>> It works well when you do not use GC, but may become problematic if you do
>> not take special care with GC code.
>
> IIRC, there are some rules:

Likely best to point folks at the documentation...



-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: How to debug a corrupted stack

2008-08-06 Thread Shawn Erickson
On Tue, Aug 5, 2008 at 7:51 PM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:
> I have a document based app which works perfectly with -O0 or -O1 but
> crashes with -O2 or higher.
>
> When the crash occurs the debugger comes up and says: "Previous frame
> identical to this frame (corrupt stack?)"
>
> When I try to step through the function (which is kind of difficult, as the
> optimization has shuffled the lines a lot) at some time the top frame of the
> stack gets duplicated.
>
> The faulty method starts with:
>NSString *path = @"/Users/gerriet/Desktop/some alias";  //  error
> with -O2
>
> If it starts with:
>NSString *path = @"/Users/gerriet/Desktop/some file";   //  ok
> with -O2
> then everything works perfectly.
>
> When I comment out the place where the error seems to occur, it will just
> occur at some earlier place.

You are moving things around in memory by chaning the length of your
string above and commenting out things. Additionally changing
optimizer settings shuffles things around.

I have a feeling you are hitting an issue cause by an uninitialized
value or something similar in your code that is being hidden in some
situations by the code emitted.

Also are you sure you are getting any runtime exceptions logged?

-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: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Negm-Awad Amin


Am Mi,06.08.2008 um 16:48 schrieb Wayne Shao:




On Wed, Aug 6, 2008 at 7:41 AM, Negm-Awad Amin [EMAIL PROTECTED]> wrote:


Am Mi,06.08.2008 um 16:27 schrieb Wayne Shao:


Hi

Please see the question in the comments of the following code.

NSMutableDictionary* aDictionary = (initialized with some objects)

for (id theKey in aDictionary) {
 id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
}

in java, Iterators allow the caller to remove elements from the  
underlying
collection during the iteration. is there similar semantics in  
objective-c?
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_8_section_1.html#/ 
/apple_ref/doc/uid/TP30001163-CH18-SW1


Enumeration is "safe"—the enumerator has a mutation guard so that if  
you attempt to modify the collection during enumeration, an  
exception is raised.


Oh. thanks for the info.   Is there an alternative method to remove  
during a loop? (besides the option to   remove elements outside of  
the loop).
Copy the collection in front of the loop and iterate through that  
copy. In your special case you can iterate through a keys-array:

NSArray* keys = [aDcitionary allKeys];
for( key in keys ) {
…

Amin







Amin

BTW: This looks like a memory leak …

fixed?

for (id theKey in aDictionary) {
 id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
[anObject release];
}





--
Wayne Shao
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[EMAIL PROTECTED]







--
Wayne Shao



Amin Negm-Awad
[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: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Negm-Awad Amin


Am Mi,06.08.2008 um 16:48 schrieb Wayne Shao:




On Wed, Aug 6, 2008 at 7:41 AM, Negm-Awad Amin [EMAIL PROTECTED]> wrote:


Am Mi,06.08.2008 um 16:27 schrieb Wayne Shao:


Hi

Please see the question in the comments of the following code.

NSMutableDictionary* aDictionary = (initialized with some objects)

for (id theKey in aDictionary) {
 id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
}

in java, Iterators allow the caller to remove elements from the  
underlying
collection during the iteration. is there similar semantics in  
objective-c?
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_8_section_1.html#/ 
/apple_ref/doc/uid/TP30001163-CH18-SW1


Enumeration is "safe"—the enumerator has a mutation guard so that if  
you attempt to modify the collection during enumeration, an  
exception is raised.


Oh. thanks for the info.   Is there an alternative method to remove  
during a loop? (besides the option to   remove elements outside of  
the loop).






Amin

BTW: This looks like a memory leak …

fixed?

for (id theKey in aDictionary) {
 id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
[anObject release];
}


Oops, I diid not see that, sorry.

Yup, that works. I prefer:
 [id anObject = [[aDictionary objectForKey:theKey] retain]  
autorelease];


That allows breaks inside the loop. (And you do not forget the - 
release, as you did.)


Amin








--
Wayne Shao
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[EMAIL PROTECTED]







--
Wayne Shao



Amin Negm-Awad
[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: Protocol for Table View Trouble

2008-08-06 Thread Corbin Dunn

In addition to what the others said:

On Aug 5, 2008, at 10:43 PM, Eric Lee wrote:

I've been having trouble implementing some protocols for table view.  
I just copied and pasted from my other code into this .m file,  
changed the variables so that it matched the variables in the .h  
file, but it has 6 errors, and I can't find out why!


Here's the .m file:

#import "drawerTableView.h"

@implementation drawerTableView


You should follow the Cocoa convention in naming your classes (ie:  
CamelCap them), and this will help avoid problems where you are mixing  
up class names with variable names.


corbin
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Protocol for Table View Trouble

2008-08-06 Thread Shawn Erickson
On Tue, Aug 5, 2008 at 10:43 PM, Eric Lee <[EMAIL PROTECTED]> wrote:
> I've been having trouble implementing some protocols for table view. I just
> copied and pasted from my other code into this .m file, changed the
> variables so that it matched the variables in the .h file, but it has 6
> errors, and I can't find out why!
>
> Here's the .m file:
>
> #import "drawerTableView.h"
>
> @implementation drawerTableView

I encourage you to review the following...

http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html

-Shawn
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: KBML Generator/Parser

2008-08-06 Thread Jason Stephenson

Apparao Mulpuri wrote:

Sorry, mentioned incorrect url for KBML. Working url for KBML is:
http://koala.ilog.fr/kbml/.


I was just about to point that out to you. I found the above also by 
googling kbml.




Any pointers on this would greatly help.


My question is, what are you trying to do with kbml? If your intention 
is to serialize Cocoa objects, you should read this first:


http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/Tasks/serializing.html

The Cocoa way to serialize objects often involves implementing a 
category that returns the object's fields as a plist (NSDictionary). You 
can then serialize this to xml using code very similar to the first 
example on the page linked above.


Retrieving the objects is a simple matter of reading the serialized xml 
into a plist, and then calling your category method to instantiate your 
object from a plist/NSDictionary. Naturally, you will have to implement 
the code to convert your object to and from a NSDictionary 
representation, but it is generally not difficult.


If your intention is to serialize Cocoa objects so that they would be 
compatible with Java objects serialized with kbml, then I'm afraid 
you're on your own. You'd need a Cocoa class hierarchy that is identical 
to the Java objects you are attempting to emulate, and that is more 
trouble than I think it would be worth.


Hope that helps,
Jason



Thanks,
- Apparao.




On Wed, Aug 6, 2008 at 11:16 AM, Apparao Mulpuri
<[EMAIL PROTECTED]> wrote:

Hi Guys,

In my Cocoa application, i am planning to use KBML
(http://www.inria.fr/koala/kbml/). KBML is pure java application, so i
need to port it into Cocoa.

I am looking for open source KBML generators/parsers to cut my
development time. Is anybody aware of such applications?

Thanks In Advance,


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jason%40sigio.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: "backporting" nibs question / Rhapsody license anyone?

2008-08-06 Thread Bill Bumgarner

On Aug 6, 2008, at 1:02 AM, Jean-Daniel Dupas wrote:
Especially if you considere that all Mac OS X versions prior to  
10.4.x are PPC only.


Only back to Mac OS X 10.0.  Prior versions ran on an assortment of  
different platforms, including i386, m68k, PA RISC, and Sparc (in the  
shipping versions, anyway -- there were others).


b.bum



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: CGGStackRestore: gstack underflow

2008-08-06 Thread Gordon Apple
I don't know anything about NSDefaultRunLoopMode and have simply been trying
to replace my layered list of draw lists with layers in what may or may not
be a scrolling view.  I'm not doing anything with animation yet.  To say
this has been problematic would be an understatement.

Also, in spite of much reading and many comments and responses, I have to
say that I still don't have a clue what the difference is between a layer
backed view and a layer hosted view.  I assume the former is intended to be
used in the same manner as a normal view and is usually implemented by
checking the box in IB for the view, and maybe has no sublayers.  Obviously,
I need sublayers.  My current approach is to add a base layer to the view's
layer and then build my stack of sublayers in the base view.  When using
live video, I add a QTCaptureLayer subLayer to the view's layer, but that is
not involved in the current issue. (That has its own problems, on which I
have already filed two bug reports.)

There are many things they just don't tell you in the documentation, such as
the fact that your content view's layer in a scroller will be a
CATiledLayer.  I have been replacing that with my own CALayer, which could
be the source of some of the problems.  (That was my attempt to go from
layer-backed to layer-hosted.)

I did once have a couple of QTCaptureViews as subviews, but not anymore.  I
found out that that just didn't display properly because the capture view
apparently gets overdrawn by my layer stack.  That's when I went to using a
QTCaptureLayer with z=1000 to get it out front.  But that layer gets added
from my A/V controller, which hasn't happened when I'm getting all those
stack-underflow console messages.


On 8/6/08 4:41 AM, "Ryan Brown" <[EMAIL PROTECTED]> wrote:

> A shot in the dark...
> 
> Are you manually activating the run loop using NSDefaultRunLoopMode? I
> recently encountered the same problem (using Core Animation as well),
> and eventually tracked it down to the way I was waiting for messages
> from a CFMessagePort to arrive. Specifying a custom run loop mode
> caused the problem to go away, and I'm still mystified as to why.
> 
> If that isn't it, I'd check that you are using Core Animation
> properly. Is the NSView a layer-hosting or layer-backed view? Does it
> have any NSView subviews or CALayer sublayers? Read this if you
> haven't already:
> 
> http://developer.apple.com/documentation/GraphicsImaging/Conceptual/Animation_
> Overview/ChooseAnimTech/chapter_5_section_3.html#/
> /apple_ref/doc/uid/TP40004952-CH5-SW4
> 
> Best,
> Ryan



___

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

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

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

This email sent to [EMAIL PROTECTED]


[NEWB] Filling a rect with an Image

2008-08-06 Thread Brad Gibbs
I'm trying to create a view with a background image, but getting error  
after error...


- (void)drawRect:(NSRect)rect {
NSRect bounds = [self bounds];
NSImage *background = [[NSImage alloc] init];
[background setImage:@"ScrollBackground"];
[[NSColor colorWithPatternImage:background] set];
[NSBezierPath fillRect:bounds];
}


 I've added a .png named ScrollBackground to my Resources folder.   
The code compiles but I get a warning: "NSImage may not respond to '- 
setImage'.


How can I make this right?

Thanks.

Brad
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [NEWB] Filling a rect with an Image

2008-08-06 Thread Kyle Sluder
On Wed, Aug 6, 2008 at 11:50 AM, Brad Gibbs <[EMAIL PROTECTED]> wrote:
>  I've added a .png named ScrollBackground to my Resources folder.  The code
> compiles but I get a warning: "NSImage may not respond to '-setImage'.

That would be because, indeed, NSImage does not respond to -setImage.
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSImage_Class/Reference/Reference.html

> How can I make this right?

Use the +[NSImage imageNamed:] convenience constructor.  You're best
off doing this once and stuffing it in an ivar; just remember to
retain it.

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [NEWB] Filling a rect with an Image

2008-08-06 Thread Brad Gibbs
Thanks.  I was looking at NSImageView (which does have a setImage:  
method).




On Aug 6, 2008, at 8:58 AM, Kyle Sluder wrote:


On Wed, Aug 6, 2008 at 11:50 AM, Brad Gibbs <[EMAIL PROTECTED]> wrote:
I've added a .png named ScrollBackground to my Resources folder.   
The code
compiles but I get a warning: "NSImage may not respond to '- 
setImage'.


That would be because, indeed, NSImage does not respond to -setImage.
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSImage_Class/Reference/Reference.html


How can I make this right?


Use the +[NSImage imageNamed:] convenience constructor.  You're best
off doing this once and stuffing it in an ivar; just remember to
retain it.

--Kyle Sluder


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Roland King


for (id theKey in aDictionary) {
id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
[anObject release];
}


Oops, I diid not see that, sorry.

Yup, that works. I prefer:
[id anObject = [[aDictionary objectForKey:theKey] retain]  
autorelease];


That allows breaks inside the loop. (And you do not forget the - 
release, as you did.)


Amin


or send it a message before you remove it from the dictionary.

for( id theKey in aDictionary ){

id anObject = [[ aDictionary objectForKey:theKey ];

[ anObject someMessage ];

[ aDictionary removeObjectForKey:theKey ];
}

of course as the original response pointed out, you can't really do  
this anyway as the modification will cause an exception so you don't  
really have the problem, you can't really remove the object where  
you're removing it.


One question I had, the mutable guard which raises the exception,  
that's only there because of the use of fast-enumeration, am I right?  
Had you used an NSEnumerator I believe  it's still not safe to remove  
objects, but I don't think you get the exception, you just need to  
know you mustn't do it. 
___


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

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

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

This email sent to [EMAIL PROTECTED]


Re: Using performSelector: on super

2008-08-06 Thread Jonathan deWerd
The solution I would use would be to implement a category on super's  
class, or rename the method (probably the best option from a design  
standpoint). For instance, suppose we have (stretching the objc syntax  
a bit)


@implementation FooClass
- (void)sayHi {
NSLog(@"Hi");
}
@end

@implementation BarClass : FooClass
- (void)sayHi {
NSLog(@"Hi there! I am BarClass.");
}
@end

And we have
BarClass* bar = [[BarClass alloc] init];

Then [bar sayHi]; will log "Hi there! I am BarClass". If we want to  
call its super's method, then we can implement a category like so  
(assuming you don't have the code to FooClass's implementation: if you  
do, just change it):


@implementation FooClass (MethodAliasing)
- (void)sayOriginalHi {
static IMP originalHi = nil;
	if (!originalHi) originalHi = [FooClass  
instanceMethodForSelector:@selector(sayHi:)];
	originalHi(self, @selector(sayHi:) /*, additional, args, would, get,  
forwarded, here*/);

}
@end

Then you can call (or you can have NSRunLoop call) sayOriginalHi: .  
This little hack should be compatible with most living variants of  
ObjC that you are likely to encounter (it only uses Apple's official  
API after all).



This being said, I will reiterate my suggestion that you look at your  
design again. The fact that you are calling super's methods outside of  
one of your own (or you are having the run loop do it for you)  
indicates that perhaps that method of super should have remained  
exposed, and instead of overriding it your subclass should provide an  
entirely new method.

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: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Andrew Merenbach

On Aug 6, 2008, at 9:30 AM, Roland King wrote:



for (id theKey in aDictionary) {
id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
[anObject release];
}


Oops, I diid not see that, sorry.

Yup, that works. I prefer:
[id anObject = [[aDictionary objectForKey:theKey] retain]  
autorelease];


That allows breaks inside the loop. (And you do not forget the - 
release, as you did.)


Amin


or send it a message before you remove it from the dictionary.

for( id theKey in aDictionary ){

id anObject = [[ aDictionary objectForKey:theKey ];

[ anObject someMessage ];

[ aDictionary removeObjectForKey:theKey ];
}

of course as the original response pointed out, you can't really do  
this anyway as the modification will cause an exception so you don't  
really have the problem, you can't really remove the object where  
you're removing it.


One question I had, the mutable guard which raises the exception,  
that's only there because of the use of fast-enumeration, am I  
right? Had you used an NSEnumerator I believe  it's still not safe  
to remove objects, but I don't think you get the exception, you just  
need to know you mustn't do  
it.___





May I suggest the following?

-

NSMutableArray *keysToRemove = [NSMutableArray array];
for (id theKey in aDictionary) {
[keysToRemove addObject:theKey];
}
[aDictionary removeObjectsForKeys:keysToRemove];

You can even use -[NSDictionary objectsForKeys:notFoundMarker:] to  
send a single message to the dictionary's objects using - 
makeObjectsPerformSelector:


Cheers,
Andrew


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Negm-Awad Amin


Am Mi,06.08.2008 um 18:30 schrieb Roland King:



for (id theKey in aDictionary) {
id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
[anObject release];
}


Oops, I diid not see that, sorry.

Yup, that works. I prefer:
[id anObject = [[aDictionary objectForKey:theKey] retain]  
autorelease];


That allows breaks inside the loop. (And you do not forget the - 
release, as you did.)


Amin


or send it a message before you remove it from the dictionary.

for( id theKey in aDictionary ){

id anObject = [[ aDictionary objectForKey:theKey ];

[ anObject someMessage ];

[ aDictionary removeObjectForKey:theKey ];
}

of course as the original response pointed out, you can't really do  
this anyway as the modification will cause an exception so you don't  
really have the problem, you can't really remove the object where  
you're removing it.


One question I had, the mutable guard which raises the exception,  
that's only there because of the use of fast-enumeration, am I  
right? Had you used an NSEnumerator I believe  it's still not safe  
to remove objects, but I don't think you get the exception, you just  
need to know you mustn't do it.

Yes, this is simply an undefined behaviour – worse …

Amin Negm-Awad
[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: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Jonathan deWerd

On Aug 6, 2008, at 10:49 AM, Andrew Merenbach wrote:


On Aug 6, 2008, at 9:30 AM, Roland King wrote:



for (id theKey in aDictionary) {
id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
[anObject release];
}


Oops, I diid not see that, sorry.

Yup, that works. I prefer:
[id anObject = [[aDictionary objectForKey:theKey] retain]  
autorelease];


That allows breaks inside the loop. (And you do not forget the - 
release, as you did.)


Amin


or send it a message before you remove it from the dictionary.

for( id theKey in aDictionary ){

id anObject = [[ aDictionary objectForKey:theKey ];

[ anObject someMessage ];

[ aDictionary removeObjectForKey:theKey ];
}

of course as the original response pointed out, you can't really do  
this anyway as the modification will cause an exception so you  
don't really have the problem, you can't really remove the object  
where you're removing it.


One question I had, the mutable guard which raises the exception,  
that's only there because of the use of fast-enumeration, am I  
right? Had you used an NSEnumerator I believe  it's still not safe  
to remove objects, but I don't think you get the exception, you  
just need to know you mustn't do  
it.___





May I suggest the following?

-

NSMutableArray *keysToRemove = [NSMutableArray array];
for (id theKey in aDictionary) {
[keysToRemove addObject:theKey];
}
[aDictionary removeObjectsForKeys:keysToRemove];

You can even use -[NSDictionary objectsForKeys:notFoundMarker:] to  
send a single message to the dictionary's objects using - 
makeObjectsPerformSelector:


Cheers,
Andrew


You could also use performSelector:withObject:afterDelay: assuming  
that you'll reenter the run loop before you need the objects removed.





___

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

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

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


This email sent to [EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Negm-Awad Amin


Am Mi,06.08.2008 um 18:49 schrieb Andrew Merenbach:


On Aug 6, 2008, at 9:30 AM, Roland King wrote:



for (id theKey in aDictionary) {
id anObject = [[aDictionary objectForKey:theKey] retain];

[aDictionary removeObjectForKey:theKey];
// Question: will this removal break or corrupt the loop of  
enumerating the

elements?

[anObject someMessage];
[anObject release];
}


Oops, I diid not see that, sorry.

Yup, that works. I prefer:
[id anObject = [[aDictionary objectForKey:theKey] retain]  
autorelease];


That allows breaks inside the loop. (And you do not forget the - 
release, as you did.)


Amin


or send it a message before you remove it from the dictionary.

for( id theKey in aDictionary ){

id anObject = [[ aDictionary objectForKey:theKey ];

[ anObject someMessage ];

[ aDictionary removeObjectForKey:theKey ];
}

of course as the original response pointed out, you can't really do  
this anyway as the modification will cause an exception so you  
don't really have the problem, you can't really remove the object  
where you're removing it.


One question I had, the mutable guard which raises the exception,  
that's only there because of the use of fast-enumeration, am I  
right? Had you used an NSEnumerator I believe  it's still not safe  
to remove objects, but I don't think you get the exception, you  
just need to know you mustn't do  
it.___





May I suggest the following?

-

NSMutableArray *keysToRemove = [NSMutableArray array];
for (id theKey in aDictionary) {
[keysToRemove addObject:theKey];
}
[aDictionary removeObjectsForKeys:keysToRemove];

You can even use -[NSDictionary objectsForKeys:notFoundMarker:] to  
send a single message to the dictionary's objects using - 
makeObjectsPerformSelector:


Cheers,
Andrew
Hey, I didn't know that. Seems to be the best solution, because the  
multi-remove message may optimize the operation.


Amin Negm-Awad
[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: How to debug a corrupted stack

2008-08-06 Thread Sean McBride
On 8/6/08 9:51 AM, Gerriet M. Denkmann said:

>So it is kind of difficult to see where and why the stack gets
>corrupted.

Have you tried 'stack canaries'?




On 8/6/08 7:59 PM, Gerriet M. Denkmann said:

>If someone wants to check whether it really is a compiler bug (and
>not just some stupidity on my side) I can send the whole project.
>10.4.11 - not tested on 10.5

Xcode 3.1 comes with 3 compilers: gcc 4.0, gcc 4.2, llvm-gcc 4.2... you
could try all 3 if you suspect a compiler bug.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Rotate NSString... I give up :(

2008-08-06 Thread Steve Christensen
No, Jean-Daniel's method looks right. The first -translateXBy:yBy:  
moves (0, 0) to the center of your text rectangle. -rotateByDegrees:  
rotates the coordinate system by 90 degrees around that center point,  
then the second call to -translateXBy:yBy: restores the coordinate  
system's (0, 0) point to what it was so that when you draw the text  
in rcWhereToDraw, it will be correctly rotated.



On Aug 6, 2008, at 1:46 AM, Vitaly Ovchinnikov wrote:


Will test this too, but I don't think it will work.
In my case I moved rectangle from it's real position to zero, then
rotate around zero and then moved back.
In your case I will move it far from zero and then rotate...
But I will give it a try.

On Wed, Aug 6, 2008 at 11:20 AM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:

Shouldn't be this instead (check the translations' signs) ?

[tr translateXBy:dx yBy:dy]; // center or rect will be the center of
rotation
[tr rotateByDegrees:90]; // rotate it
[tr translateXBy:-dx yBy:-dy]; // move it back


Le 6 août 08 à 08:46, Vitaly Ovchinnikov a écrit :


Hello,

I need to draw NSString rotated to 90 degrees. Now I have the code:

NSRect rcWhereToDraw = NSMakeRect(); // <- rect is already
"rotated" here
[str drawInRect:rcWhereToDraw withAttributes:attributes]; // string
will be drawn non-rotated

as far as I know, I need something like this:

[[NSGraphicsContext currentContext] saveGraphicsState];
NSRect rcWhereToDraw = NSMakeRect();

float dx = NSMidX(rcWhereToDraw), dy = NSMidY(rcWhereToDraw);

NSAffineTransform *tr = [NSAffineTransform transform];
[tr translateXBy:-dx yBy:-dy]; // center or rect will be the  
center of

rotation
[tr rotateByDegrees:90]; // rotate it
[tr translateXBy:dx yBy:dy]; // move it back
[tr concat];

[str drawInRect:rcWhereToDraw withAttributes:attributes];
[[NSGraphicsContext currentContext] restoreGraphicsState];

This doesn't work, where am I wrong?
Thank you.


___

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

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

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

This email sent to [EMAIL PROTECTED]


How do you create a new PDF file and write text to it?

2008-08-06 Thread Paul Archibald

Comrades -

It looks like PDFKit is aimed at simply reading and navigating within  
an existing PDF file, but what I need to do is create a new PDF and  
write some simple text to it. I know that the Preview app does that  
for a lot of apps, but I would like to bypass that, too. I simply  
want my app to create a PDF file, open it for writing, write some  
simple text to it, and save it to disk.


Any advice?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How do you create a new PDF file and write text to it?

2008-08-06 Thread Charles Steinman
--- On Wed, 8/6/08, Paul Archibald <[EMAIL PROTECTED]> wrote:

> It looks like PDFKit is aimed at simply reading and
> navigating within  
> an existing PDF file, but what I need to do is create a new
> PDF and  
> write some simple text to it. I know that the Preview app
> does that  
> for a lot of apps, but I would like to bypass that, too. I
> simply  
> want my app to create a PDF file, open it for writing,
> write some  
> simple text to it, and save it to disk.

Easiest way: Create a view that draws what you want, send it 
-dataWithPDFInsideRect: and write that data to a file.

Cheers,
Chuck


  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How do you create a new PDF file and write text to it? LOOKS LIKE ITS SOLVED

2008-08-06 Thread Paul Archibald

Dude!

That does look simple. I figured it would be.

Thanks,
Paul


On Aug 6, 2008, at 11:42 AM, Charles Steinman wrote:


--- On Wed, 8/6/08, Paul Archibald <[EMAIL PROTECTED]> wrote:


It looks like PDFKit is aimed at simply reading and
navigating within
an existing PDF file, but what I need to do is create a new
PDF and
write some simple text to it. I know that the Preview app
does that
for a lot of apps, but I would like to bypass that, too. I
simply
want my app to create a PDF file, open it for writing,
write some
simple text to it, and save it to disk.


Easiest way: Create a view that draws what you want, send it - 
dataWithPDFInsideRect: and write that data to a file.


Cheers,
Chuck






___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How do you create a new PDF file and write text to it?

2008-08-06 Thread John Calhoun

On Aug 6, 2008, at 11:37 AM, Paul Archibald wrote:
It looks like PDFKit is aimed at simply reading and navigating  
within an existing PDF file, but what I need to do is create a new  
PDF and write some simple text to it.


Sorry, I had to jump in and refute that — PDF Kit does allow PDF  
content creation, but it may not be so obvious looking at the API.


Subclassing PDFPage is a way to do this.  Subclass and implement - 
[boundsForBox:] and -[drawWithBox:] and you're there.  You report back  
the size of the PDF page in -[boundsForBox:] (in points where 72 == 1  
inch) and you draw your text in the -[drawWithBox:] method.


You create an empty PDFDocument (alloc, init) and add your subclassed  
PDFPage to the document.



On Aug 6, 2008, at 11:42 AM, Charles Steinman wrote:
Easiest way: Create a view that draws what you want, send it - 
dataWithPDFInsideRect: and write that data to a file.


Charles is correct.  And it is easiest.  The PDF Kit method I outlined  
above gives you slightly more control over the resulting PDF (you can  
for example add metadata, multiple pages, differing crop/media boxes,  
etc.).


John Calhoun—___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Rotate NSString... I give up :( [SOLVED]

2008-08-06 Thread Vitaly Ovchinnikov
Yes, he right. I've just tested it and it works fine.
I though that -translateXBy:yBy: will move my object, but it moved
pivot point... This is hard, especially with revesed OY axis ;)
Thanks to you and Jean-Daniel.

On Wed, Aug 6, 2008 at 10:19 PM, Steve Christensen <[EMAIL PROTECTED]> wrote:
> No, Jean-Daniel's method looks right. The first -translateXBy:yBy: moves (0,
> 0) to the center of your text rectangle. -rotateByDegrees: rotates the
> coordinate system by 90 degrees around that center point, then the second
> call to -translateXBy:yBy: restores the coordinate system's (0, 0) point to
> what it was so that when you draw the text in rcWhereToDraw, it will be
> correctly rotated.
>
>
> On Aug 6, 2008, at 1:46 AM, Vitaly Ovchinnikov wrote:
>
>> Will test this too, but I don't think it will work.
>> In my case I moved rectangle from it's real position to zero, then
>> rotate around zero and then moved back.
>> In your case I will move it far from zero and then rotate...
>> But I will give it a try.
>>
>> On Wed, Aug 6, 2008 at 11:20 AM, Jean-Daniel Dupas
>> <[EMAIL PROTECTED]> wrote:
>>>
>>> Shouldn't be this instead (check the translations' signs) ?
>>>
>>> [tr translateXBy:dx yBy:dy]; // center or rect will be the center of
>>> rotation
>>> [tr rotateByDegrees:90]; // rotate it
>>> [tr translateXBy:-dx yBy:-dy]; // move it back
>>>
>>>
>>> Le 6 août 08 à 08:46, Vitaly Ovchinnikov a écrit :
>>>
 Hello,

 I need to draw NSString rotated to 90 degrees. Now I have the code:

 NSRect rcWhereToDraw = NSMakeRect(); // <- rect is already
 "rotated" here
 [str drawInRect:rcWhereToDraw withAttributes:attributes]; // string
 will be drawn non-rotated

 as far as I know, I need something like this:

 [[NSGraphicsContext currentContext] saveGraphicsState];
 NSRect rcWhereToDraw = NSMakeRect();

 float dx = NSMidX(rcWhereToDraw), dy = NSMidY(rcWhereToDraw);

 NSAffineTransform *tr = [NSAffineTransform transform];
 [tr translateXBy:-dx yBy:-dy]; // center or rect will be the center of
 rotation
 [tr rotateByDegrees:90]; // rotate it
 [tr translateXBy:dx yBy:dy]; // move it back
 [tr concat];

 [str drawInRect:rcWhereToDraw withAttributes:attributes];
 [[NSGraphicsContext currentContext] restoreGraphicsState];

 This doesn't work, where am I wrong?
 Thank you.
>
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: CGImageSourceCreateFromURL failed with error -11

2008-08-06 Thread James Trankelson
Hi Nicolas, David,

I'm having the exact same problem. Loading collections of small images
(jpeg in my case).

The only slight difference for me is that if I run my application
under XCode (Debug build), I don't get any errors. All of the images
load fine. However, when I run the (Debug) binary, I'm able to load
around ~180 small jpegs, then just a whole bunch of the following
error for each image I try to load past that ~180 image limit.

CGImageSourceCreateWithURL failed with error code -11.

I'd like to get this figured out if anyone has any insight. I'd also
like to know if there are any *expected* differences between running
the same (Debug) binary through XCode versus as a standalone... I
wouldn't think so, but that's not what I'm seeing. In other parts of
my app, the standalone will simply crash without explanation, whereas
the XCode version will perform the expected behavior without
complaint.

-j

On Tue, Aug 5, 2008 at 2:32 AM, Nicolas Zinovieff <[EMAIL PROTECTED]> wrote:
> David,
>
> the images are GIFs, roughly 40KB each, 200x100 (or 100x200).
> Nothing fancy.
>
> On 05 Aug 2008, at 01:05, David Duncan wrote:
>
>> What types of images are you trying to load?
>
> --
> Zino
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/trankelson%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: Rotate NSString... I give up :( [SOLVED]

2008-08-06 Thread Kyle Sluder
On Wed, Aug 6, 2008 at 4:37 PM, Vitaly Ovchinnikov
<[EMAIL PROTECTED]> wrote:
> Yes, he right. I've just tested it and it works fine.
> I though that -translateXBy:yBy: will move my object, but it moved
> pivot point... This is hard, especially with revesed OY axis ;)

Well, it all happens in one transformation matrix.  If I recall matrix
math correctly (probably not), rotation is a linear transformation,
but translation isn't, so in order to get rotation to work right the
pivot point must be the origin.  Since you want to rotate the object
around its center, you need to translate it twice.  This is all
chained together in one transformation matrix, so when the
multiplication's done the net result is one matrix that does all three
operations.

Anyone, please feel free to correct me, I would very much appreciate
any clarification.  :D

--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: Rotate NSString... I give up :( [SOLVED]

2008-08-06 Thread Vitaly Ovchinnikov
Yes, you right, but I expected what I need to move text to the zero
point, rotate it and move it back. But NSAffineTransform works quite
the contrary and requires to move the zero point to the text and then
back. That was a big surprise for me.

On Thu, Aug 7, 2008 at 12:55 AM, Kyle Sluder
<[EMAIL PROTECTED]> wrote:
> On Wed, Aug 6, 2008 at 4:37 PM, Vitaly Ovchinnikov
> <[EMAIL PROTECTED]> wrote:
>> Yes, he right. I've just tested it and it works fine.
>> I though that -translateXBy:yBy: will move my object, but it moved
>> pivot point... This is hard, especially with revesed OY axis ;)
>
> Well, it all happens in one transformation matrix.  If I recall matrix
> math correctly (probably not), rotation is a linear transformation,
> but translation isn't, so in order to get rotation to work right the
> pivot point must be the origin.  Since you want to rotate the object
> around its center, you need to translate it twice.  This is all
> chained together in one transformation matrix, so when the
> multiplication's done the net result is one matrix that does all three
> operations.
>
> Anyone, please feel free to correct me, I would very much appreciate
> any clarification.  :D
>
> --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: CGImageSourceCreateFromURL failed with error -11

2008-08-06 Thread David Duncan
Couldn't tell either of you why your having issues without seeing  
code, and probably not even then, but this is probably worth a bug  
report.


On Aug 6, 2008, at 1:52 PM, James Trankelson wrote:


I'm having the exact same problem. Loading collections of small images
(jpeg in my case).

On Tue, Aug 5, 2008 at 2:32 AM, Nicolas Zinovieff <[EMAIL PROTECTED]>  
wrote:

David,

the images are GIFs, roughly 40KB each, 200x100 (or 100x200).
Nothing fancy.



--
David Duncan
Apple DTS Animation and Printing
[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: CGImageSourceCreateFromURL failed with error -11

2008-08-06 Thread Gary L. Wade
Off the top of my head, with a number of files being opened so high and 
relatively close to the value you get from getrlimit with a parameter of 
RLIMIT_NOFILE, I'd suggest checking to see if that's the problem.

>Hi Nicolas, David,
>
>I'm having the exact same problem. Loading collections of small images
>(jpeg in my case).
>
>The only slight difference for me is that if I run my application
>under XCode (Debug build), I don't get any errors. All of the images
>load fine. However, when I run the (Debug) binary, I'm able to load
>around ~180 small jpegs, then just a whole bunch of the following
>error for each image I try to load past that ~180 image limit.
>
>CGImageSourceCreateWithURL failed with error code -11.
>
>I'd like to get this figured out if anyone has any insight. I'd also
>like to know if there are any *expected* differences between running
>the same (Debug) binary through XCode versus as a standalone... I
>wouldn't think so, but that's not what I'm seeing. In other parts of
>my app, the standalone will simply crash without explanation, whereas
>the XCode version will perform the expected behavior without
>complaint.
>
>-j
>
>On Tue, Aug 5, 2008 at 2:32 AM, Nicolas Zinovieff <[EMAIL PROTECTED]> wrote:
>> David,
>>
>> the images are GIFs, roughly 40KB each, 200x100 (or 100x200).
>> Nothing fancy.
>>
>> On 05 Aug 2008, at 01:05, David Duncan wrote:
>>
>>> What types of images are you trying to load?
>>
>> --
>> Zino
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Andrew Merenbach

On Aug 6, 2008, at 10:36 AM, mm w wrote:


usually, in a better design view you do the opposite, a safe copy of
the keys that you need in a new dict, then you release the old man,
you have a really strange programming approach,

aDictionary -> aNewDictionary with only my wanted keys,

with your solution you ought to get some surprises


Hi!  With all due respect, if you are referring to my own approach, I  
was attempting to answer the OPs actual question, which involved the  
task of removing selected items from an NSMutableDictionary.  You  
have, however, piqued my curiosity immensely, and I am *not* being  
facetious when I ask, quite seriously: what sort of surprises?


Cheers,
Andrew


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: post events to NSApplication

2008-08-06 Thread Michael Ash
On Tue, Aug 5, 2008 at 10:18 PM, Jim Crafton <[EMAIL PROTECTED]> wrote:
> Is it possible to create a custom event for an apps internal usage and
> have it posted to the NSApp, and then processed later on? If so, how
> would one do this? I'm not sure how to
> a) create the event
> b) get notified when the event is recv'd and ready for processing
>
> The event loop is whatever is being run by calling [NSApp run].

Ken already answered your question, but I would propose that it is the
wrong question to ask. In my many years of writing code with Cocoa,
I've almost never had to do this.

("Almost" because there are two cases where it is useful: pinging an
event tracking runloop, and working around the Cocoa bug where
autorelease pools are only popped when an NSEvent is processed.)

Rather than use an event, it sounds like you just want to use a timer.
Create an NSTimer, set the time interval to whatever you need (0 if
you want it "as soon as possible), set the target and selector to
whatever it is you want to run, and that target/selector pair will be
invoked at the next opportunity.

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: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Andrew Merenbach


On Aug 6, 2008, at 3:01 PM, mm w wrote:


i will return the question why fast enumerator prevents against this?
maybe in-memory Pile?, you should have answered to the question alone



Without knowing the workings of fast enumeration, I am at a loss as to  
why it would prevent it -- unless it has something to do with the fast  
enumerator not wanting to make an copy of the array before iterating,  
a copy which might slow things down.


My apologies, but I don't know much about the Pile data structure  
type, unfortunately, so I am unable to answer your other question.


Best,
Andrew



On Wed, Aug 6, 2008 at 2:56 PM, Andrew Merenbach
<[EMAIL PROTECTED]> wrote:

On Aug 6, 2008, at 10:36 AM, mm w wrote:


usually, in a better design view you do the opposite, a safe copy of
the keys that you need in a new dict, then you release the old man,
you have a really strange programming approach,

aDictionary -> aNewDictionary with only my wanted keys,

with your solution you ought to get some surprises


Hi!  With all due respect, if you are referring to my own approach,  
I was
attempting to answer the OPs actual question, which involved the  
task of
removing selected items from an NSMutableDictionary.  You have,  
however,
piqued my curiosity immensely, and I am *not* being facetious when  
I ask,

quite seriously: what sort of surprises?

Cheers,
  Andrew





--
-mmw




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: handling idle events

2008-08-06 Thread Michael Ash
On Tue, Aug 5, 2008 at 10:16 PM, Jim Crafton <[EMAIL PROTECTED]> wrote:
> Is there a way to handle idle time in an NSApplication? In Win32 or
> Carbon, since you manually write the actual while loop that processes
> the events, this is pretty easy to do. Is there anything like this in
> Cocoa? I've got some objects whose state (possibly) needs to be
> updated, and I was planning on handling this in the "idle" handler.
>
> My other idea, if this is not possible, would be to simply have a
> timer that fires off every 0.5 seconds or so.

In addition to the solutions already proposed, there are some other
techniques available depending on exactly what you need:

1) If you need to check on your status at every pass through the event
loop, and your object is tied to a particular window, you can use
NSWindowDidUpdateNotification.

2) If as above but your object is not tied to a particular window,
there is NSApplicationDidUpdateNotification.

3) And lastly if you want to check at every pass through the runloop
(note: not the same as the event loop, although they are closely
related, and an application's main thread will be running both), or
otherwise need more control over when your code is run,
CFRunLoopObserver will let you register callbacks for various stages
of runloop processing.

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]


[Newbie] Extracting a specific character number from a string

2008-08-06 Thread Phil Faber
I'm trying to learn more about string manipulation and want to be able  
to extract a single character from a string.  I think I need to use  
subStringWithRange (exacting from and to the same character location)  
but I'm not sure and I'm also unsure how to code it.


Basically I'm after the equivalent of the old-fashioned BASIC command  
MID$ [ i.e. MID$("This is the sentence to check",4,1) to get character  
4. ]


The following code works fine except for the..

NSLog(@"Character %i of %@ is %@",i,pass1,[pass1 substringWithRange: 
1,2]);


...line simply because I don't know how to code that line.  I think  
it's something to do with how to set the range that I'm getting wrong.


Can anyone please advise what than line is supposed to be to pull out  
the correct character?


Thanks.

Phil


{
NSMutableString *pass1;
int i;

pass1=@"This is the sentence to check";

NSLog(@"length of %@ is %i",pass1,[pass1 length]);

for (i=1;i<=[pass1 length];i++)
{
// This displays characters UP to character 'i'
		NSLog(@"Characters up to %i of %@ are %@",i,pass1,[pass1  
substringToIndex:i]);


// This is SUPPOSED to display character number 'i' ONLY
		NSLog(@"Character %i of %@ is %@",i,pass1,[pass1  
substringWithRange:i,i]);

}



}
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Newbie] Extracting a specific character number from a string

2008-08-06 Thread Ricky Sharp


On Aug 6, 2008, at 5:23 PM, Phil Faber wrote:

I'm trying to learn more about string manipulation and want to be  
able to extract a single character from a string.  I think I need to  
use subStringWithRange (exacting from and to the same character  
location) but I'm not sure and I'm also unsure how to code it.


Basically I'm after the equivalent of the old-fashioned BASIC  
command MID$ [ i.e. MID$("This is the sentence to check",4,1) to get  
character 4. ]


The following code works fine except for the..

NSLog(@"Character %i of %@ is %@",i,pass1,[pass1 substringWithRange: 
1,2]);


The parameter to substringWithRange is a NSRange.  So, you'll need to  
pass in something like:


NSMakeRange(1, 1)

Note also the second param to NSMakeRange is actually a length value  
and not an index.


...line simply because I don't know how to code that line.  I think  
it's something to do with how to set the range that I'm getting wrong.


Can anyone please advise what than line is supposed to be to pull  
out the correct character?


But that is all overkill if you want to extract individual characters  
from a string.   See NSString's characterAtIndex: API.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
Instant Interactive(tm)   http://www.instantinteractive.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: [Newbie] Extracting a specific character number from a string

2008-08-06 Thread Kyle Sluder
On Wed, Aug 6, 2008 at 6:23 PM, Phil Faber <[EMAIL PROTECTED]> wrote:
> NSLog(@"Character %i of %@ is %@",i,pass1,[pass1 substringWithRange:1,2]);

You need to pass an NSRange struct to -[NSString substringWithRange:].
 You can make one using the NSMakeRange() function.  If you didn't
know that function existed, you could always have just created one
manually:

NSRange range;
range.location = 1;
range.length = 1;

Also, be careful with NSString character-related functions, because
you get into very thorny issues with respect to "byte" versus
"character" versus "unichar" versus "Unicode code point".  String
slicing is not for the faint of heart (or for those unfamiliar with
surrogate pairs).

--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: Dumb Q

2008-08-06 Thread Marco Masser
I want to make a simple filter that takes the output of "ls -la" and  
reformats it to appear more like the MS-DOS directory listing. So, I  
would do something like "ls -la | mydosfilter" and get a directory  
listing with the filename first, the # bytes second, then the  
timestamp (leaving out everything from the UNIX permissions bits to  
the group, and rearranging the rest.)


Why don't you simply add an alias named "dir" to a global bashrc file  
that translates to something like this: ls -la | awk '{ print $9"\t 
\t"$5"\t"$6,$7,$8 }'
This simply outputs the file name, two tabs, the size in bytes, a tab  
and then the date & time. I'm no awk expert, maybe this could be done  
prettier.


Marco
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Rotate NSString... I give up :(

2008-08-06 Thread Graham Cox
Bear in mind you are moving the co-ordinate system to the object, not  
the object around the co-ordinate system...


I find it useful to "read" NSAffineTransform operations in reverse  
order. The operations you list in the code are applied to the object  
in the opposite order.



cheers, Graham


On 6 Aug 2008, at 6:46 pm, Vitaly Ovchinnikov wrote:


Will test this too, but I don't think it will work.
In my case I moved rectangle from it's real position to zero, then
rotate around zero and then moved back.
In your case I will move it far from zero and then rotate...
But I will give it a try.

On Wed, Aug 6, 2008 at 11:20 AM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:

Shouldn't be this instead (check the translations' signs) ?

[tr translateXBy:dx yBy:dy]; // center or rect will be the center of
rotation
[tr rotateByDegrees:90]; // rotate it
[tr translateXBy:-dx yBy:-dy]; // move it back




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Rotate NSString... I give up :( [SOLVED]

2008-08-06 Thread Nathan Vander Wilt


On Aug 6, 2008, at 2:08 PM, Vitaly Ovchinnikov wrote:


Yes, you right, but I expected what I need to move text to the zero
point, rotate it and move it back. But NSAffineTransform works quite
the contrary and requires to move the zero point to the text and then
back. That was a big surprise for me.



Remember that affine transforms are of the form v' = Mv. So if you  
want to transform a vector by a matrix:

v' = Mv

...and then by another matrix:
v'' = Nv'

But if you want to do it all in one step, you would do:
v'' = NMv

See how it's not MNv but NMv? What this means is that you must  
concatenate your transformation matrix in the opposite order of how  
you want it to transform your points. I'd agree this is surprising, I  
myself spent a long time one day trying to "debug" NSAffineTransform  
just on account of forgetting this relationship.


hope this helps,
-natevw



On Thu, Aug 7, 2008 at 12:55 AM, Kyle Sluder
<[EMAIL PROTECTED]> wrote:

On Wed, Aug 6, 2008 at 4:37 PM, Vitaly Ovchinnikov
<[EMAIL PROTECTED]> wrote:

Yes, he right. I've just tested it and it works fine.
I though that -translateXBy:yBy: will move my object, but it moved
pivot point... This is hard, especially with revesed OY axis ;)


Well, it all happens in one transformation matrix.  If I recall  
matrix

math correctly (probably not), rotation is a linear transformation,
but translation isn't, so in order to get rotation to work right the
pivot point must be the origin.  Since you want to rotate the object
around its center, you need to translate it twice.  This is all
chained together in one transformation matrix, so when the
multiplication's done the net result is one matrix that does all  
three

operations.

Anyone, please feel free to correct me, I would very much appreciate
any clarification.  :D

--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/nate-lists%40calftrail.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: How to enable/disable buttons immediately after focus transfer

2008-08-06 Thread an0
I can see that would work; but I am wondering whether a simpler and
more elegant mechanism exists, something just like
NSUserInterfaceValidations and NSValidatedUserInterfaceItem.
But thank you all the same.

On Wed, Aug 6, 2008 at 6:37 PM, Negm-Awad Amin <[EMAIL PROTECTED]> wrote:
> Did you try a subclass of NSWindow and overriding -setFirstResponder:?
>
> Amin
> Am Di,05.08.2008 um 15:36 schrieb an0:
>
>> I know how to do this for NSValidatedUserInterfaceItem by implementing
>> `- (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem
>>>
>>> )anItem'; however, NSSegmentedControl and NSButton do not conform to
>>
>> NSValidatedUserInterfaceItem protocol, then how can I switch the
>> enable status of  these controls as an IMMEDIATE response to the focus
>> transfer?
>> Thanks in advance.
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de
>>
>> This email sent to [EMAIL PROTECTED]
>
> Amin Negm-Awad
> [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]


Command Line Argument - Choosing a Style

2008-08-06 Thread hac
Hi,
I'm developing an application to support third-party extensions that filter
text. Each filter consists mainly of a property list and an executable. The
idea is that the text of the current document goes into the executable along
with settings specified in the property list (as arguments); text to replace
the document text comes out as the standard output.

Right now I am stuck trying to decide how I should pass both the document
text and the settings to the executable. I see three options:

   1. Have the first argument be the document text, and the second an XML
   string containing the settings as key-value pairs.
   2. Have the first argument be the docucument text, the second a setting
   key, the third a setting value, the fourth a setting key, etc...
   3. Have the first argument be the docucument text, have each successive
   argument be a setting value, in an order specified in the property list so
   as to determine the key for each.

I can easily set up the application to support any of these methods. My
problem is that each one seems to have some inconveniences for the developer
of the filter, and I would like to make this as convenient as possible for
anyone who makes a filter. Could someone tell me which method would be the
most appropriate?

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]


NSOperationQueue Memory Leak

2008-08-06 Thread Mike Simmons
I have an audio application that processes numerous audio streams into  
ten-second clips, compresses the clips, and saves them to disk.  
Naturally, I wanted to move from single-threaded processing to  
multithreaded processing for the clip compression/writing. That was  
easily done using the NSOperationQueue and the NSInvocation classes,  
and it worked nicely, apart from a bad memory leak that I can't seem  
to eradicate. So I finally wrote a small test application to  
encapsulate what I was doing in the larger program, and it too has a  
leak -- a big one!


The test application simply spawns 1 threads whose sole job is to  
display "Hi, I am thread xx" on the console. It then sleeps and spawns  
1 more. At the end of the run some 38 MB of  real memory has been  
used, and it never goes down.  (I'm not using garbage collection, but  
I think I'm doing things correctly with the autorelease pool.)


Can someone tell me what I'm doing wrong?

Thanks!

Mike

---
#import 


@interface OperationQueueTester : NSObject
{
}

- (void) run;
- (void) sayHi:(id)blah;
- (void) queueOperations:(int) count;

@end

@implementation OperationQueueTester

- (id) init
{
return self;
}

- (void) run
{
// Allow a bit of time to have a look at the initial memory usage.
NSLog(@"Starting in 5 seconds...");
sleep(5);

// Throw a bunch of simple operations into the operation queue.
[self queueOperations:1];
sleep(10);
[self queueOperations:1];

// Allow a bit of time to look at the final memory usage.
NSLog(@"All threads have finished processing.");
sleep(3600);
}

- (void) queueOperations:(int) count
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSInvocationOperation *processor;
	NSOperationQueue *operationQueue = [[[NSOperationQueue alloc] init]  
autorelease];

NSLog(@"Preparing to queue operations");

// Add multiple "process:" operations to the queue with no argument.
for (int i = 0; i < count; i++)
{
		processor = [[NSInvocationOperation alloc] initWithTarget:self  
selector:@selector(sayHi:) object:nil];

[operationQueue addOperation:processor];
}
NSLog(@"All threads queued.");
[operationQueue waitUntilAllOperationsAreFinished];
[pool release];
}

- (void) sayHi:(id)blah
{
static int counter = 0;
NSLog(@"Hi. I am thread %d", counter++);
}

@end

/**
Main routine, in which an object is instantiated to queue a large  
number of operations into an operation queue.

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

	OperationQueueTester *queueTester = [[OperationQueueTester alloc]  
init];

[queueTester run];
[pool drain];
return 0;
}

___

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

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

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

This email sent to [EMAIL PROTECTED]


NSSpellChecker (foundation) broken for custom NSSpellServer servers

2008-08-06 Thread Adam Strzelecki

Hello,

I'm one of the supporters of custom NSSpellServer effort called  
SpellCheck that does provide spell support for Eastern Europe  
languages missing in Leopard built-in spell checker (We got Polish  
interface but no Polish spell checker). SpellCheck uses Cocoa's  
NSSpellServer interface, everything is working fine except there's  
apparently a bug inside Foundation.framework regarding calls to proper  
Spell Servers (via Mach ports).


It seems Foundation is often stubbornly calling wrong spell server.

AppleSpell.service NSSpellServer is registered with  
registerLanguage:byVendor: for "en", "fr" .. etc. languages and  
"Apple" vendor.
CheckSpell.service NSSpellServer is registered for exclusively other  
languages as "pl", "cs", "lt", "lv", "sk" ... with "Apple" vendor  
(also I checked changing to "Check" vendor, same problem).


So it often happens that Foundation calls CheckSpell.service for "en"  
and vice-versa AppleSpell.service for "pl"! This happens by instance  
in Mail.app, when I first use English spell checking via  
AppleSpell.service, and switch to Polish (pl) via CheckSpell.service  
for my next mail, Foundation (NSSpellChecker) is getting crazy, and  
asking AppleSpell for "pl", which results in totally wrong (empty)  
response. In order to get proper "pl" via CheckSpell.service I need to  
restart Mail.app, but then when I want to switch to English, . yes  
again I need to restart.


This thing is really bothering me much in OSX, I was writing to  
Apple's feedback regarding OSX and Mail.app about this issue once  
there was just 10.5.0 release, since then nothing has changed, this  
bug is still there unfixed.


Maybe someone from Apple OSX devs is reading this list, and could take  
a peek into this problem?
I'm aware there's a bug tracker for paid & registered Apple  
developers, where I could report those problems, but since I'm not one  
of them I have no access there.


Thanks,
--
Adam Strzelecki | nanoant.com

P.S. Also very very annoying thing about Cocoa is that changing spell  
language with ⇧⌘; does not revalidate all words in NSTextView, but  
only current word under the cursor, so either I need to scroll trough  
whole document to have the text revalidated with new language or I  
need to press Next many many times in Spelling & Grammar window. I  
believe it would make life easier for double- or tripe- language  
writers under OSX so whole document gets automatically revalidated  
once I switch the language.___


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

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

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

This email sent to [EMAIL PROTECTED]


how to create the special modal dialog

2008-08-06 Thread pan xuan

Hi,
 
In some of Preferences's pane, when clicking a "+" sign, a modal dialog comes 
up not separately but as a child shadowed dialog sticking out from the bottom 
of the tool bar. What is that kind of dialog called? and how to program it?
 
Thanks for the help.
 
Pan
_
Get more from your digital life.  Find out how.
http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home2_082008___

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

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

2008-08-06 Thread Sandro Noel


Greetings! :)

I'm experimenting with core data, bindings work just fine, I love them  
and it's great and all. :)
but I want to import a massive file into the database. so I'm trying  
to create it programatically.


So far I've been able to insert records in simple entities, using some  
code from the Core Data Documentation.
Where my problem lies, is with relationships, and data types other  
than NSString, so here comes the code.

--
I have entities like this.

TransactionTypes
Atributes : Name:String
Relationships: Transaction

Transactions
Atributes: Amount:Double, Date:Date, Memo:String, Payee:String
Relationships: TransactionType
---
I retrieve/create/insert (not quite sure yet :)) an object from the  
context, and set the values like this.


NSManagedObject *transaction = [NSEntityDescription  
insertNewObjectForEntityForName:@"Transactions"

 inManagedObjectContext:[self 
managedObjectContext]];

[transaction setValue:tr.transactionAmount forKey:@"Amount"];
[transaction setValue:tr.transactionType
forKey:@"TransactionType.Name"];

[transaction setValue:tr.displayName   forKey:@"Name"];
[transaction setValue:tr.memo  forKey:@"Memo"];
[transaction setValue:tr.datePostedforKey:@"Date"];

---
The Transaction(tr) Object Used in the code above is defined like this:

@interface OFXTransaction : NSObject {
NSString*transactionType;
	NSDate	  	*datePosted; //-mm-dd / converted from string  
20080201125910

NSNumber*transactionAmount;
NSString*uniqueID;
NSString*displayName;
NSString*memo;
}
@property (readwrite, copy) NSString*transactionType;
@property (readwrite, copy) NSDate  *datePosted;
@property (readwrite, copy) NSNumber*transactionAmount;
@property (readwrite, copy) NSString*uniqueID;
@property (readwrite, copy) NSString*displayName;
@property (readwrite, copy) NSString*memo;
-
Now, when I try to set the value for the [date] or [Amount] or  
[TransactionType], of the ManagedObject, i get an error:
*** -[NSCFString managedObjectContext]: unrecognized selector sent to  
instance 0xXeXX
The only thing that really works fine are the strings, I don't get  
it... must be a simple mistake from my part here.

or something I missed in the documentation...:S

another thing I would like to understand, do relationships work like  
constraints in SQL ?
in the sense that if there is no transactionType defined in the  
TransactionTypes Entity,
I would not be able to insert a value in the transactionType field of  
the transactions entity?


do I have to first select/fetch an object from the transactionsType  
entety, and assign that to the transactionType atribute of the

transactions entety...?


Again, thank you guy's for being there, and helping out the newcomers :)
Sandro.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to create the special modal dialog

2008-08-06 Thread Andy Mroczkowski

Pan,

I think you're referring to are "sheets".

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

Good luck =]

- Andy


On Aug 6, 2008, at 8:41 AM, pan xuan wrote:



Hi,

In some of Preferences's pane, when clicking a "+" sign, a modal  
dialog comes up not separately but as a child shadowed dialog  
sticking out from the bottom of the tool bar. What is that kind of  
dialog called? and how to program it?


Thanks for the help.

Pan
_
Get more from your digital life.  Find out how.
http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home2_082008___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Recommended way of checking OS version

2008-08-06 Thread Jason Bobier
Hey folks, does anyone know the recommended way of checking whether my  
app is running on Tiger or Leopard? It used to be that you could just  
check that appkit version against one of the #defines, but apple  
appears to have stopped updating them. At least 10.3.5 is the latest  
that I see.


Is Gestalt really the way?

Thanks,

Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSOperationQueue Memory Leak

2008-08-06 Thread Nick Zitzmann


On Aug 6, 2008, at 7:38 AM, Mike Simmons wrote:

processor = [[NSInvocationOperation alloc] initWithTarget:self  
selector:@selector(sayHi:) object:nil];



Why aren't you releasing this object?

Nick Zitzmann


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Recommended way of checking OS version

2008-08-06 Thread Nick Zitzmann


On Aug 6, 2008, at 6:37 PM, Jason Bobier wrote:

Hey folks, does anyone know the recommended way of checking whether  
my app is running on Tiger or Leopard? It used to be that you could  
just check that appkit version against one of the #defines, but  
apple appears to have stopped updating them. At least 10.3.5 is the  
latest that I see.


Is Gestalt really the way?



Yes; Gestalt() works just fine and is even present in the 64-bit API.

Nick Zitzmann


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Recommended way of checking OS version

2008-08-06 Thread Jason Bobier
Cool. I was wondering how they would get it to work with 10.4.11, but  
then noticed that they added specific gestalts for major, minor, and  
bug fix in 10.4.


Thanks,

Jason

On Aug 6, 2008, at 5:46 PM, Nick Zitzmann wrote:



On Aug 6, 2008, at 6:37 PM, Jason Bobier wrote:

Hey folks, does anyone know the recommended way of checking whether  
my app is running on Tiger or Leopard? It used to be that you could  
just check that appkit version against one of the #defines, but  
apple appears to have stopped updating them. At least 10.3.5 is the  
latest that I see.


Is Gestalt really the way?



Yes; Gestalt() works just fine and is even present in the 64-bit API.

Nick Zitzmann




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Command Line Argument - Choosing a Style

2008-08-06 Thread Jonathan deWerd
I would make plugins of a different type: standard cocoa bundles  
(there are a handful of tutorials on google). This way, people could  
install and uninstall using the finder (a little known but helpful  
feature of the info box), you could use standard cocoa APIs, you  
wouldn't have to deal with the overhead of spawning a new process, and  
you could provide a template to get devs started. Then I'd just pass  
configuration info in a dictionary.


If that isn't an option, I would pass a bunch of --key value pairs to  
retain some semblance of standard-ness :)


On Aug 6, 2008, at 4:33 PM, hac wrote:


Hi,
I'm developing an application to support third-party extensions that  
filter
text. Each filter consists mainly of a property list and an  
executable. The
idea is that the text of the current document goes into the  
executable along
with settings specified in the property list (as arguments); text to  
replace

the document text comes out as the standard output.

Right now I am stuck trying to decide how I should pass both the  
document

text and the settings to the executable. I see three options:

  1. Have the first argument be the document text, and the second an  
XML

  string containing the settings as key-value pairs.
  2. Have the first argument be the docucument text, the second a  
setting

  key, the third a setting value, the fourth a setting key, etc...
  3. Have the first argument be the docucument text, have each  
successive
  argument be a setting value, in an order specified in the property  
list so

  as to determine the key for each.

I can easily set up the application to support any of these methods.  
My
problem is that each one seems to have some inconveniences for the  
developer
of the filter, and I would like to make this as convenient as  
possible for
anyone who makes a filter. Could someone tell me which method would  
be the

most appropriate?

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/jjoonathan 
%40gmail.com


This email sent to [EMAIL PROTECTED]




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Core Data question

2008-08-06 Thread Quincey Morris

On Aug 6, 2008, at 12:31, Sandro Noel wrote:

Now, when I try to set the value for the [date] or [Amount] or  
[TransactionType], of the ManagedObject, i get an error:
*** -[NSCFString managedObjectContext]: unrecognized selector sent  
to instance 0xXeXX
The only thing that really works fine are the strings, I don't get  
it... must be a simple mistake from my part here.

or something I missed in the documentation...:S


The error says you are sending a 'managedObjectContext' message to a  
string (instead of to a NSManagedObject). Set a breakpoint at  
objc_exception_throw and you should see in the stack trace where this  
is happening, and then work out what to do about it. You may actually  
be sending the message to the wrong object, or you might have a memory  
management error.


another thing I would like to understand, do relationships work like  
constraints in SQL ?
in the sense that if there is no transactionType defined in the  
TransactionTypes Entity,
I would not be able to insert a value in the transactionType field  
of the transactions entity?


If you don't have a TransactionTypes object for a Transactions object,  
you can leave the TransactionType relationship unset (i.e. nil). If  
the Transactions entity says it's optional, you can leave it that way  
forever and there's no problem. If it's not optional, there's no  
immediate error, but you'll get a validation error when you try to  
save the persistent store.


do I have to first select/fetch an object from the transactionsType  
entety, and assign that to the transactionType atribute of the

transactions entety...?


If you're starting from a transaction type name as you show in your  
sample code, you'll have to do a fetch to find the object with that  
name (every time you need it, or do it once during startup and create,  
say, a dictionary that ties the names to the objects in a more  
convenient way).


This line:

[transaction setValue:tr.transactionType
forKey:@"TransactionType.Name"];


isn't going to work. You've given it a key path, so you would need to  
use [setValue:forKeyPath:] instead of [setValue:forKey:]. But in any  
case it's the wrong key path. This isn't going to fetch the correct  
transaction type, it's going to change the name of the transaction  
type, which is not what I think you want to do.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Editing NSTableView

2008-08-06 Thread Chris Idou
If I have a NSTableView controlled by a NSArrayController, how do I get 
notification that the user edited a field?





  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: remove elements during the iteration on NSMutableDictionary

2008-08-06 Thread Michael Ash
On Wed, Aug 6, 2008 at 6:08 PM, Andrew Merenbach
<[EMAIL PROTECTED]> wrote:
>
> On Aug 6, 2008, at 3:01 PM, mm w wrote:
>
>> i will return the question why fast enumerator prevents against this?
>> maybe in-memory Pile?, you should have answered to the question alone
>
> Without knowing the workings of fast enumeration, I am at a loss as to why
> it would prevent it -- unless it has something to do with the fast
> enumerator not wanting to make an copy of the array before iterating, a copy
> which might slow things down.

It is extremely difficult, in the general case, to efficiently support
mutation during enumeration.

Take an array as a simple case. Let's say you delete every
odd-numbered element during enumeration. In an NSArray, the remaining
elements move down to occupy the newly emptied slots. If you want
sensible enumeration, you need to either decouple the enumeration from
the storage (which means copying the array, which is inefficient) or
you need to somehow track all of the enumerators currently active on
the array so that you can re-point them when you make a change (which
is difficult and potentially inefficient).

In the more general case, you even have open-ended semantic questions.
For example, let's say that during enumeration you add a new object to
the end of the array. Should that object be enumerated or not? How
about if you add the new object to the beginning of the array? If you
delete an object that you haven't enumerated yet, should it still be
enumerated or should it now be skipped?

For more complicated data structures, it goes from merely being
difficult to being completely nuts. Adding a new entry to a
dictionary, for example, can trigger a memory reallocation and a
subsequent rehash which completely shuffles the order of the objects
within. If you're in the middle of enumerating the dictionary when
that happens, how can you sensibly continue?

For one interesting technique, check out TransactionKit
(http://transactionkit.sourceforge.net/). With those collections,
mutation during enumeration doesn't affect the enumeration at all.
It's as if you were iterating a copy of the collection, but without
the cost of doing a full copy. However, this design does create
significant overhead for all operations, so once again, it's a
tradeoff.

Since there are multiple strategies for dealing with mutation during
enumeration and multiple desired semantics, Apple has decided that
rather than incurring a bunch of overhead and forcing semantics that
may be undesirable, they'll simply disallow it. For cases where you
really need it, it's relatively easy to simply enumerate a copy, or
accumulate changes for batch modification afterwards.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to use a button to update an application with a text field value

2008-08-06 Thread Tron Thomas
The only the the controller's action does in response to the button 
action is call commitEditing.  I'm not sure what you mean by having the 
text field use the same action.  I don't see any action method in the 
Interface Builder connection dialog for the text field.  There is 
something called selector, I'm not sure what that is for.


In this case, the user interface is so simple there is no need to worry 
about the user tabbing to another control.  There is no other control 
they can tab to.

Ken Thomases wrote:

On Aug 6, 2008, at 12:22 AM, Tron Thomas wrote:

The program is a simple game.  The player answers questions by typing 
something in and then either pressing enter or clicking on the button 
to commit their answer.  Although not likely it is, possible the user 
may try to use the previous information as the answer to the current 
question, so they might simply click the button to resubmit an answer 
without editing anything.


Right, and?  As far as I can see, your button's action method should 
just call -commitEditing and then proceed to do whatever it is that 
should happen when the user provides an answer.  For what it's worth, 
your text field should use the same action method.  I do _not_ think 
that the mere setting of the model value by the text field's binding 
should be taken to mean the user has finished entering their answer.  
For example, the user may simply have tabbed to another control.


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: autorelease CGImageRef?

2008-08-06 Thread Peter N Lewis

At 7:48 AM -0700 6/8/08, Shawn Erickson wrote:

Likely best to point folks at the documentation...




Yes, that is quite helpful (except that the imagined implementation 
of CFMakeCollectable omits the fact that it is a no-op in managed 
memory mode).


This email sent to [EMAIL PROTECTED] 2:26 PM +0200 6/8/08, 
Jean-Daniel Dupas wrote:

If I'm not wrong, it should be something like this:

[NSMakeCollectable(aCGImageRef) autorelease];


This appears correct, except for the fact that, for reasons known 
only to Apple, although CFMakeCollectable is available in 10.4, the 
trivial NSMakeCollectable macro is available only in 10.5.  So 
expanding the NSMakeCollectable macro gives:


return [(id)CFMakeCollectable(aCGImageRef) autorelease];

However, the working of this line of code is rather subtle.

In memory managed mode CFMakeCollectable is a no-op and autorelease 
works, so the code is equivalent to


return [(id)aCGImageRef autorelease];

while in garbage collected mode, CFMakeCollectable is equivalent to 
CFRelease, and autorelease is a no-op, so the code is equivalent to:


CFRelease(aCGImageRef);
return (id)aCGImageRef

The documentation is well worth readings because it is quite tricky 
the way CFRetain/CFRelease always work, even in garbage collection 
mode, and CFRetainCount > 0 stops garbage collection from happening 
on the object, while retain/release/autorelease work only in memory 
managed mode and are no-ops in garbage collection mode (that part is 
well known I think).


Thanks for the enlightenment!
   Peter.
--
  Keyboard Maestro 3 Now Available!
Now With Status Menu triggers!

Keyboard Maestro  Macros for your Mac
   
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to use a button to update an application with a text field value

2008-08-06 Thread Ken Thomases

On Aug 6, 2008, at 9:39 PM, Tron Thomas wrote:

The only the the controller's action does in response to the button  
action is call commitEditing.


And that's the problem.  You're overloading the text field's binding  
to your model with semantics of a user action, when it's not.


The action triggered by the button should explicitly do your game  
logic (check the user's answer, give them points, advance them to the  
next question, etc.).


I'm not sure what you mean by having the text field use the same  
action.  I don't see any action method in the Interface Builder  
connection dialog for the text field.  There is something called  
selector, I'm not sure what that is for.


When you hit return in a text field, it fires off an action to its  
target.  This is conceptually just like when you click a button.  In  
IB, you set up the target-action in the same way.  You control-drag  
from the text field to the target, and then select the action  
(selector) in the target.


Note that hitting return _does_ carry the semantics of a user action,  
and so would be an appropriate occasion for your game to check the  
user's answer and give them points, or whatever.  That's why I  
recommend that the text field be set up to invoke the same action on  
the same target as the button.  Both should do the same thing.



In this case, the user interface is so simple there is no need to  
worry about the user tabbing to another control.  There is no other  
control they can tab to.


You're wrong.  Look in System Preferences > Keyboard & Mouse >  
Keyboard Shortcuts.  There's a setting called Full Keyboard Access  
which a user can configure to allow them to tab among all controls in  
a window, not just text fields.  So, the mere existence of a button in  
the window is enough to allow the user to tab away from your text  
field.  That would update the binding but should not (in my opinion)  
count as them entering their answer.


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: autorelease CGImageRef?

2008-08-06 Thread Ken Ferry
The hope is that most people are either writing GC code, in which case
CFMakeCollectable is a less scary looking version of CFRelease, or
non-GC code in which case they aren't using the function at all.

However, for people who are writing code that needs to work both ways,
here's how I think of it:

(1) You need to balance the NS reference count and the CF reference
count separately.
(2) NSMakeCollectable transfers one reference from the CF column to
the NS column.

Ken Ferry
Cocoa Frameworks

On Wed, Aug 6, 2008 at 7:44 PM, Peter N Lewis <[EMAIL PROTECTED]> wrote:
> At 7:48 AM -0700 6/8/08, Shawn Erickson wrote:
>>
>> Likely best to point folks at the documentation...
>>
>>
>> 
>
> Yes, that is quite helpful (except that the imagined implementation of
> CFMakeCollectable omits the fact that it is a no-op in managed memory mode).
>
> This email sent to [EMAIL PROTECTED] 2:26 PM +0200 6/8/08,
> Jean-Daniel Dupas wrote:
>>
>> If I'm not wrong, it should be something like this:
>>
>> [NSMakeCollectable(aCGImageRef) autorelease];
>
> This appears correct, except for the fact that, for reasons known only to
> Apple, although CFMakeCollectable is available in 10.4, the trivial
> NSMakeCollectable macro is available only in 10.5.  So expanding the
> NSMakeCollectable macro gives:
>
> return [(id)CFMakeCollectable(aCGImageRef) autorelease];
>
> However, the working of this line of code is rather subtle.
>
> In memory managed mode CFMakeCollectable is a no-op and autorelease works,
> so the code is equivalent to
>
> return [(id)aCGImageRef autorelease];
>
> while in garbage collected mode, CFMakeCollectable is equivalent to
> CFRelease, and autorelease is a no-op, so the code is equivalent to:
>
> CFRelease(aCGImageRef);
> return (id)aCGImageRef
>
> The documentation is well worth readings because it is quite tricky the way
> CFRetain/CFRelease always work, even in garbage collection mode, and
> CFRetainCount > 0 stops garbage collection from happening on the object,
> while retain/release/autorelease work only in memory managed mode and are
> no-ops in garbage collection mode (that part is well known I think).
>
> Thanks for the enlightenment!
>   Peter.
> --
>  Keyboard Maestro 3 Now Available!
>Now With Status Menu triggers!
>
> Keyboard Maestro  Macros for your Mac
>    
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%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: Recommended way of checking OS version

2008-08-06 Thread Charles Srstka

On Aug 6, 2008, at 7:37 PM, Jason Bobier wrote:

Hey folks, does anyone know the recommended way of checking whether  
my app is running on Tiger or Leopard? It used to be that you could  
just check that appkit version against one of the #defines, but  
apple appears to have stopped updating them. At least 10.3.5 is the  
latest that I see.


It goes up to 10.4, but you have to be using the 10.5 SDK.

#define NSAppKitVersionNumber10_4 824

In general, each SDK seems to have the NSAppKit versions for each OS  
version up to but not including the OS version that goes with the SDK.


Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSOperationQueue Memory Leak

2008-08-06 Thread Shripada Hebbar

Hi Mike


processor = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(sayHi:) object:nil];
You are not releasing the operation objects you create!.  You should  
have released them soon

after they were added to the queue.
--
[operationQueue addOperation:processor];
[processor release];   //<<<
--

Also you are not releasing the OperationQueue that you create.  Since  
you are not using garbage collection,

you will have to manage the memory on your own.  Read more on it:

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


Regards
Shripada



On 07-Aug-08, at 6:33 AM, [EMAIL PROTECTED] wrote:


Message: 7
Date: Wed, 06 Aug 2008 08:38:09 -0500
From: Mike Simmons <[EMAIL PROTECTED]>
Subject: NSOperationQueue Memory Leak
To: Cocoa-dev@lists.apple.com
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

I have an audio application that processes numerous audio streams into
ten-second clips, compresses the clips, and saves them to disk.
Naturally, I wanted to move from single-threaded processing to
multithreaded processing for the clip compression/writing. That was
easily done using the NSOperationQueue and the NSInvocation classes,
and it worked nicely, apart from a bad memory leak that I can't seem
to eradicate. So I finally wrote a small test application to
encapsulate what I was doing in the larger program, and it too has a
leak -- a big one!

The test application simply spawns 1 threads whose sole job is to
display "Hi, I am thread xx" on the console. It then sleeps and spawns
1 more. At the end of the run some 38 MB of  real memory has been
used, and it never goes down.  (I'm not using garbage collection, but
I think I'm doing things correctly with the autorelease pool.)

Can someone tell me what I'm doing wrong?

Thanks!

Mike

---
#import 


@interface OperationQueueTester : NSObject
{
}

- (void) run;
- (void) sayHi:(id)blah;
- (void) queueOperations:(int) count;

@end

@implementation OperationQueueTester

- (id) init
{
return self;
}

- (void) run
{
// Allow a bit of time to have a look at the initial memory usage.
NSLog(@"Starting in 5 seconds...");
sleep(5);

// Throw a bunch of simple operations into the operation queue.
[self queueOperations:1];
sleep(10);
[self queueOperations:1];

// Allow a bit of time to look at the final memory usage.
NSLog(@"All threads have finished processing.");
sleep(3600);
}

- (void) queueOperations:(int) count
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSInvocationOperation *processor;
NSOperationQueue *operationQueue = [[[NSOperationQueue alloc] init]
autorelease];
NSLog(@"Preparing to queue operations");

// Add multiple "process:" operations to the queue with no argument.
for (int i = 0; i < count; i++)
{
processor = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(sayHi:) object:nil];
[operationQueue addOperation:processor];
}
NSLog(@"All threads queued.");
[operationQueue waitUntilAllOperationsAreFinished];
[pool release];
}

- (void) sayHi:(id)blah
{
static int counter = 0;
NSLog(@"Hi. I am thread %d", counter++);
}

@end

/**
Main routine, in which an object is instantiated to queue a large
number of operations into an operation queue.
**/
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

OperationQueueTester *queueTester = [[OperationQueueTester alloc]
init];
[queueTester run];
[pool drain];
return 0;
}



--




---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Token Field tags selected when raising panel window ...

2008-08-06 Thread vince
I have a token field in a drop panel that I am using to store keyword search
tags. When I raise the panel all previously saved tags are selected.
Clicking within the field alleviates the problem. All is working fine. It's
mainly an aesthetic issue.
is there something that I can do to prevent this?

thanks for the help.

v.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Properties, read only and bindings

2008-08-06 Thread Steven W Riggins

Hi!

I'm winding my way through KVO, readonly properties and bindings.

I have an object which has a bool state.  I have a method that toggles  
that state.


I have a button that calls the method that toggles the state.  The  
button has a title, which I've bound to a readonly property, which has  
a getter that returns a localized label based on the state.


So when I change the state, obviously the readonly property doesn't  
change, and thus the button label does not change.


Changing the readonly property to a normal ivar works fine.

Is there a way to use a synthesized property in this manner, or is it  
even proper?


Thanks!

Steve
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Properties, read only and bindings

2008-08-06 Thread Bill Bumgarner

On Aug 6, 2008, at 9:51 PM, Steven W Riggins wrote:

I'm winding my way through KVO, readonly properties and bindings.

I have an object which has a bool state.  I have a method that  
toggles that state.


I have a button that calls the method that toggles the state.  The  
button has a title, which I've bound to a readonly property, which  
has a getter that returns a localized label based on the state.


So when I change the state, obviously the readonly property doesn't  
change, and thus the button label does not change.


Changing the readonly property to a normal ivar works fine.

Is there a way to use a synthesized property in this manner, or is  
it even proper?


You can solve this in the following two ways (amongst others):

(1) Redeclare the property as readwrite in a class extension in  
your .m file and then use dot syntax or the synthesized setter/getter  
to set the value.


I.e.

.h:
@interface Foo : NSObject
{
BOOL f;
}

@property(readonly, nonatomic) BOOL f;
@end

.m
@interface Foo()
@property(readwrite, nonatomic) BOOL f;
@end

@implementation Foo
@synthesize f;
// ... use the setter and getter as needed
@end

(2) Call willChange/didChange before/after you change the value:

- (void) toggle: sender
{
 logic ...
[self willChangeValueForKey: @"f"];
f = ... new state ...;
[self didChangeValueForKey: @"f"];
}

b.bum

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Properties, read only and bindings

2008-08-06 Thread Steven W Riggins

Aha!

I was missing the willChangeForKey: call.

- (IBAction) toggleIsCloning: (id) sender
{
[self willChangeValueForKey:@"cloningLabel"];
self.isCloning = !self.isCloning;
[self didChangeValueForKey:@"cloningLabel"];
}

Now it works fine, thanks!

On Aug 6, 2008, at 10:07 PM, Bill Bumgarner wrote:


On Aug 6, 2008, at 9:51 PM, Steven W Riggins wrote:

I'm winding my way through KVO, readonly properties and bindings.

I have an object which has a bool state.  I have a method that  
toggles that state.


I have a button that calls the method that toggles the state.  The  
button has a title, which I've bound to a readonly property, which  
has a getter that returns a localized label based on the state.


So when I change the state, obviously the readonly property doesn't  
change, and thus the button label does not change.


Changing the readonly property to a normal ivar works fine.

Is there a way to use a synthesized property in this manner, or is  
it even proper?


You can solve this in the following two ways (amongst others):

(1) Redeclare the property as readwrite in a class extension in  
your .m file and then use dot syntax or the synthesized setter/ 
getter to set the value.


I.e.

.h:
@interface Foo : NSObject
{
BOOL f;
}

@property(readonly, nonatomic) BOOL f;
@end

.m
@interface Foo()
@property(readwrite, nonatomic) BOOL f;
@end

@implementation Foo
@synthesize f;
// ... use the setter and getter as needed
@end

(2) Call willChange/didChange before/after you change the value:

- (void) toggle: sender
{
 logic ...
[self willChangeValueForKey: @"f"];
f = ... new state ...;
[self didChangeValueForKey: @"f"];
}

b.bum


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Properties, read only and bindings

2008-08-06 Thread Roland King
If your isCloning is a property itself, can you use the dependent key 
registration logic instead?


[ self setKeys:[ NSArray arrayWithObjects:@"isCloning", nil ] 
triggerChangeNotificationsForDependentKey:@"cloningLable" ];


I've never tried this, but it's documented here and I recall reading 
about it.


http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/DependentKeys.html#//apple_ref/doc/uid/20002179

Rols

Steven W Riggins wrote:


Aha!

I was missing the willChangeForKey: call.

- (IBAction) toggleIsCloning: (id) sender
{
[self willChangeValueForKey:@"cloningLabel"];
self.isCloning = !self.isCloning;
[self didChangeValueForKey:@"cloningLabel"];
}

Now it works fine, thanks!

On Aug 6, 2008, at 10:07 PM, Bill Bumgarner wrote:


On Aug 6, 2008, at 9:51 PM, Steven W Riggins wrote:


I'm winding my way through KVO, readonly properties and bindings.

I have an object which has a bool state.  I have a method that  
toggles that state.


I have a button that calls the method that toggles the state.  The  
button has a title, which I've bound to a readonly property, which  
has a getter that returns a localized label based on the state.


So when I change the state, obviously the readonly property doesn't  
change, and thus the button label does not change.


Changing the readonly property to a normal ivar works fine.

Is there a way to use a synthesized property in this manner, or is  
it even proper?



You can solve this in the following two ways (amongst others):

(1) Redeclare the property as readwrite in a class extension in  your 
.m file and then use dot syntax or the synthesized setter/ getter to 
set the value.


I.e.

.h:
@interface Foo : NSObject
{
BOOL f;
}

@property(readonly, nonatomic) BOOL f;
@end

.m
@interface Foo()
@property(readwrite, nonatomic) BOOL f;
@end

@implementation Foo
@synthesize f;
// ... use the setter and getter as needed
@end

(2) Call willChange/didChange before/after you change the value:

- (void) toggle: sender
{
 logic ...
[self willChangeValueForKey: @"f"];
f = ... new state ...;
[self didChangeValueForKey: @"f"];
}

b.bum



___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Properties, read only and bindings

2008-08-06 Thread Negm-Awad Amin


Am Do,07.08.2008 um 07:32 schrieb Roland King:

If your isCloning is a property itself, can you use the dependent  
key registration logic instead?


[ self setKeys:[ NSArray arrayWithObjects:@"isCloning", nil ]  
triggerChangeNotificationsForDependentKey:@"cloningLable" ];


I've never tried this, but it's documented here and I recall reading  
about it.
It works and this is what - 
setKeys:triggerChangeNotificationForDependentKey: is for - running  
under tiger.


The dependent keys mechanism changed in leopard:
+keyPathsForValuesAffectingValueForKey:
+keyPathsForValuesAffecting

// Simple sample
+ (NSArray*)keyPathForValuesAffectingButtonTitle {
   return [NSArray arrayWithObject:@"myState"];
}

Amin



http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/DependentKeys.html#/ 
/apple_ref/doc/uid/20002179


Rols

Steven W Riggins wrote:


Aha!

I was missing the willChangeForKey: call.

- (IBAction) toggleIsCloning: (id) sender
{
   [self willChangeValueForKey:@"cloningLabel"];
   self.isCloning = !self.isCloning;
   [self didChangeValueForKey:@"cloningLabel"];
}

Now it works fine, thanks!

On Aug 6, 2008, at 10:07 PM, Bill Bumgarner wrote:


On Aug 6, 2008, at 9:51 PM, Steven W Riggins wrote:


I'm winding my way through KVO, readonly properties and bindings.

I have an object which has a bool state.  I have a method that   
toggles that state.


I have a button that calls the method that toggles the state.   
The  button has a title, which I've bound to a readonly property,  
which  has a getter that returns a localized label based on the  
state.


So when I change the state, obviously the readonly property  
doesn't  change, and thus the button label does not change.


Changing the readonly property to a normal ivar works fine.

Is there a way to use a synthesized property in this manner, or  
is  it even proper?



You can solve this in the following two ways (amongst others):

(1) Redeclare the property as readwrite in a class extension in   
your .m file and then use dot syntax or the synthesized setter/  
getter to set the value.


I.e.

.h:
@interface Foo : NSObject
{
   BOOL f;
}

@property(readonly, nonatomic) BOOL f;
@end

.m
@interface Foo()
@property(readwrite, nonatomic) BOOL f;
@end

@implementation Foo
@synthesize f;
// ... use the setter and getter as needed
@end

(2) Call willChange/didChange before/after you change the value:

- (void) toggle: sender
{
    logic ...
   [self willChangeValueForKey: @"f"];
   f = ... new state ...;
   [self didChangeValueForKey: @"f"];
}

b.bum



___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de

This email sent to [EMAIL PROTECTED]


Amin Negm-Awad
[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]