Re: ARC and Singletons

2011-08-01 Thread Karl Goiser
Yes they are. They are a kludge that came about because C++ doesn’t implement object behaviour properly. Try this: http://www.google.com/search?hl=en&q=Singleton%2Bevil You have not said what about NSFileManager is a great example of the singleton pattern. Of course class methods have thei

Re: ARC and Singletons

2011-08-01 Thread Kyle Sluder
On Mon, Aug 1, 2011 at 7:14 PM, Karl Goiser wrote: > Wow, class methods finally get the tick of approval!  Only 30+ years after > being specified in the Smalltalk standard.. > > > Forget about singletons: they are just a workaround for not having class > methods/variables. No, they're not. I me

Re: ARC and Singletons

2011-08-01 Thread Karl Goiser
Wow, class methods finally get the tick of approval! Only 30+ years after being specified in the Smalltalk standard.. Forget about singletons: they are just a workaround for not having class methods/variables. Each class is a single object that exists for the life of the application therefo

Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?

2011-08-01 Thread Greg Parker
On Aug 1, 2011, at 5:51 PM, Wade Tregaskis wrote: >>> Any code that throws exceptions will probably leak a few objects, since >>> according to the ARC design doc the ABI requires not draining autorelease >>> pools while unwinding the stack. >> >> Are you sure (or does ARC work differently)? >>

Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?

2011-08-01 Thread Graham Cox
Only vaguely following this thread, but two observations occur (rather obvious ones at that): a) NSKeyed(Un)Archiver can take a delegate b) NSKeyed(Un)Archiver can be subclassed The first allows you to refine the behaviour of the standard object, the second allows you to reimplement it any way

Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?

2011-08-01 Thread Wade Tregaskis
>> Any code that throws exceptions will probably leak a few objects, since >> according to the ARC design doc the ABI requires not draining autorelease >> pools while unwinding the stack. > > Are you sure (or does ARC work differently)? > >

Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?

2011-08-01 Thread Wade Tregaskis
>>> Granted that NSKeyedUnarchiver might have left some memory leaks or >>> partially uninitialized objects somewhere, but unarchiving an invalid >>> object should happen rarely if at all... and ordinarily my own code should >>> never get pointers to such objects, anyway. >> >> Indeed there may

Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?

2011-08-01 Thread Kyle Sluder
On Mon, Aug 1, 2011 at 4:29 PM, Jerry Krinock wrote: > Thus, My New Code gives the same result as the Classic Approach, but it does > so without raising an exception.  So I'm thinking about changing from Classic > Approach to My New Code in my next project.  I always like to think long and > ha

Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?

2011-08-01 Thread Jerry Krinock
On 2011 Aug 01, at 12:45, Martin Wierschin wrote: > This is even worse than the original problem. Rather than getting an > exception at the time of encoding, now you're silently converting unencodable > objects to strings. Thank you, Martin. That is correct. > When you unarchive one of those

Re: NSAttributedString -initWithPath RTFD crash on Lion

2011-08-01 Thread jonat...@mugginsoft.com
On 1 Aug 2011, at 20:48, Martin Wierschin wrote: > I don't have any advice on the actual crash, but: > >> The following workaround seems reliable: >> >> // get path to rtf file >> NSString *filePath = [path stringByAppendingPathComponent:@"TXT.rtf"]; > > Be aware that would probably miss any i

Re: core data migration - delete old store

2011-08-01 Thread Dave Fernandes
I'm not using autosave. In fact this is done in my document controller before the NSPersistentDocument is even created. Does the Core Data stack have some awareness of an autosave mode? Perhaps, as you suggest, Apple has dropped this feature and this is just a documentation bug. Hope someone fro

Re: Unnecessary Boolean Warning

2011-08-01 Thread Scott Ribe
On Aug 1, 2011, at 2:36 PM, Jeffrey Walton wrote: > I wish I had a dollar for every time I lazy fingered `=` rather than > `==`. And another buck for each time the compiler caught it (I use > `-Wall` -Wextra` and firends). Well, firend, I believe you ;-) -- Scott Ribe scott_r...@elevated-dev.co

Re: Unnecessary Boolean Warning

2011-08-01 Thread Jeffrey Walton
On Mon, Aug 1, 2011 at 4:08 PM, Greg Parker wrote: > > On Aug 1, 2011, at 8:47 AM, Gordon Apple wrote: > >> It’s not that I object to anyone doing it, if that makes them more >> comfortable, but a warning on ““&&” inside of “||”” is ridiculous.  Everyone >> knows that multiplication takes preceden

Re: Unnecessary Boolean Warning

2011-08-01 Thread Greg Parker
On Aug 1, 2011, at 8:47 AM, Gordon Apple wrote: > It’s not that I object to anyone doing it, if that makes them more > comfortable, but a warning on ““&&” inside of “||”” is ridiculous. Everyone > knows that multiplication takes precedence over addition. “&&” is a > multiplication. “||” is, we

Re: NSAttributedString -initWithPath RTFD crash on Lion

2011-08-01 Thread Martin Wierschin
I don't have any advice on the actual crash, but: > The following workaround seems reliable: > > // get path to rtf file > NSString *filePath = [path stringByAppendingPathComponent:@"TXT.rtf"]; Be aware that would probably miss any images/attachments saved in the RTFD package. ~Martin ___

Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?

2011-08-01 Thread Martin Wierschin
>>> I don't think so, Jens. "They" is Apple. Apple has the source code for >>> -initWithCoder: and -encodeWithCoder:. >> >> No they don’t — not for the implementations of those methods in our own >> classes… > > Thank you, Jens. I see the problem. > > Here's a fairly radical solution: ...

Re: ARC and Singletons

2011-08-01 Thread Jeff Kelley
Traditionally, I used the standard +sharedInstance type of singleton, but I returned it autoreleased and in its dealloc method, set the sharedInstance variable to nil if it was the shared instance: > - (void)dealloc > { > if (self == sharedInstance) { > sharedInstance = nil; > }

Re: ARC and Singletons

2011-08-01 Thread David Duncan
On Aug 1, 2011, at 10:12 AM, Kyle Sluder wrote: > On Mon, Aug 1, 2011 at 9:05 AM, Dave Zarzycki wrote: >> The simplest and most ARC friendly way to implement the singleton pattern is >> to switch from instance methods to class methods – because the class itself >> is by definition a singleton.

Re: [iOS] Block animation kills performance

2011-08-01 Thread Rick Mann
Thank you, Roland, for that thorough explanation. Now I understand what's going on and why. I will write a bug, if only to get the docs improved. -- Rick On Aug 1, 2011, at 3:38 , Roland King wrote: > > On Aug 1, 2011, at 8:08 AM, Rick Mann wrote: > >> >> On Jul 31, 2011, at 17:04 , Roland

Re: ARC and Singletons

2011-08-01 Thread Kyle Sluder
On Mon, Aug 1, 2011 at 10:12 AM, Kyle Sluder wrote: > if it's necessary to store the shared instance in an ivar, why not do > the following: Wow, I need coffee. ivars vs class variables… Wow. Forget that second example. That's just terrible. Imagine, instead, I used whatever storage mechanism

Re: ARC and Singletons

2011-08-01 Thread Kyle Sluder
On Mon, Aug 1, 2011 at 9:05 AM, Dave Zarzycki wrote: > The simplest and most ARC friendly way to implement the singleton pattern is > to switch from instance methods to class methods – because the class itself > is by definition a singleton. In other words: Eek, this might be conceptually simpl

Re: autoresizingMask and transformation

2011-08-01 Thread David Duncan
On Jul 31, 2011, at 7:18 PM, Tales Pinheiro De Andrade wrote: > I have a custom view that have a square subview. The superview is stretched > in both directions when the device is rotated. > > The subview has autoresizingMask=UIViewAutoresizingFlexibleHeight | > UIViewAutoresizingFlexibleWidth

Re: Unnecessary Boolean Warning

2011-08-01 Thread Jean-Daniel Dupas
If this warning bother you, just disable it. clang is smart enough to tell you what flag you have to turn off in the warning message. For instance, just add -Wno-constant-logical-operand in your other warning flags. Le 1 août 2011 à 17:47, Gordon Apple a écrit : > It’s not that I object to a

Re: ARC and Singletons

2011-08-01 Thread Dave Zarzycki
On Aug 1, 2011, at 9:08 AM, Jeff Kelley wrote: > Interesting. Your +setFoo: example, I’m assuming, sets a global int. Correct. > What about objects? I’m assuming that if I declare a global NSArray pointer > like so: > > NSArray *foo = nil; In general, globals default initialize to zero/nil/N

Re: ARC and Singletons

2011-08-01 Thread Dave DeLong
That would work. However, you lose out on being able to declare "foo" as an @property (not a big deal) and have to write the accessors yourself (annoying, since the compiler knows how to do this already but can't in this case). Dave On Aug 1, 2011, at 9:05 AM, Dave Zarzycki wrote: > The simpl

Re: Receiving Unicode Input in NSView

2011-08-01 Thread Bill Appleton
Hi Aki and others, So implementing the NSTextInputClient protocol works great in our stand-alone product, we get unicode as expected In the browser product we synthesize NSEvents for key downs and send them through the same system with handleEvent this does NOT work as expected, which i think is

Re: ARC and Singletons

2011-08-01 Thread Jeff Kelley
Interesting. Your +setFoo: example, I’m assuming, sets a global int. What about objects? I’m assuming that if I declare a global NSArray pointer like so: NSArray *foo = nil; and then have a +setFoo:(NSArray *)array method, that calling it with nil will be sufficient to clean up the array (that is

Re: ARC and Singletons

2011-08-01 Thread Dave Zarzycki
The simplest and most ARC friendly way to implement the singleton pattern is to switch from instance methods to class methods – because the class itself is by definition a singleton. In other words: + (MyClass *)sharedInstance; // and maybe override alloc/retain/release to enforc

Re: ARC and Singletons

2011-08-01 Thread Thomas Davie
On 1 Aug 2011, at 16:48, Jeff Kelley wrote: > Is there a new recommended way to implement a singleton with ARC? I remember > hearing something about it, but I’m not sure what it was. Was it perhaps… don't use singletons, they're just globals in disguise? Bob_

Re: Unnecessary Boolean Warning

2011-08-01 Thread Sean McBride
On Sun, 31 Jul 2011 15:13:45 -0500, Gordon Apple said: >The following expression generates a warning message (3&&2 within 3||2) and >says to include the 3anded2 expression in parens. Anybody who understands >basic boolean operator precedence knows this is unnecessary. Bug report? > >BOOL isI

ARC and Singletons

2011-08-01 Thread Jeff Kelley
Is there a new recommended way to implement a singleton with ARC? I remember hearing something about it, but I’m not sure what it was. Jeff Kelley ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator com

Re: Unnecessary Boolean Warning

2011-08-01 Thread Gordon Apple
It¹s not that I object to anyone doing it, if that makes them more comfortable, but a warning on ³³&&² inside of ³||²² is ridiculous. Everyone knows that multiplication takes precedence over addition. ³&&² is a multiplication. ³||² is, welll, almost an addition. (Exor is addition in a mod 2 sys

Re: Telling Auto Save, "No, I'm busy now"

2011-08-01 Thread Kevin Perry
AppKit-initiated autosaves generally happen for two main reasons: the autosave timer, and file coordination. These are both initiated with -autosaveWithImplicitCancellability:completionHandler:. The "implicitly cancelable" flag indicates whether it's appropriate for an NSDocument subclass to ca

Re: Multithreaded Coredata save in Lion

2011-08-01 Thread Jim Thomason
> -saveDocument: has never been expected to do its work immediately. Instead, > you want to call: > > -saveDocumentWithDelegate:didSaveSelector:contextInfo: > > Then, when the delegate is called, spawn off your new MOC. That's exactly what I needed. A little rewiring of the app to use the delegat

Re: Initializing Radio buttons in an NSMatrix problem

2011-08-01 Thread Fritz Anderson
On 1 Aug 2011, at 7:47 AM, John James wrote: > Using Lion: I have a NSMatrix 1 row 3 cols. > at Startup I can not get the first radio button to show an indication; works > fine if user clicks on any one. > Relavent code (called from awakeFromNib): > (framesPersec is an outlet for the NSMatrix w

Initializing Radio buttons in an NSMatrix problem

2011-08-01 Thread John James
Using Lion: I have a NSMatrix 1 row 3 cols. at Startup I can not get the first radio button to show an indication; works fine if user clicks on any one. Relavent code (called from awakeFromNib): (framesPersec is an outlet for the NSMatrix with tags 1,2,3 respectively) - (void) initFramespersec

Re: CALayer memory management [was: Tracking down CALayer problem in iTunes plug-in]

2011-08-01 Thread Dave Keck
> I've narrowed this error down to a very simple test case. Could you post you test case? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-ad

NSAttributedString -initWithPath RTFD crash on Lion

2011-08-01 Thread jonat...@mugginsoft.com
On OS X 10.7 the following is crashing on occasion in a GC app when the path contains an RTFD document: On SL the issue does not occur. NSAttributedString *atext = [[NSAttributedString alloc] initWithPath:Path documentAttributes:NULL]; The kernel log states: 01/08/2011 09:44:29.000 kernel: Dat

Re: [iOS] Block animation kills performance

2011-08-01 Thread Roland King
On Aug 1, 2011, at 8:08 AM, Rick Mann wrote: > > On Jul 31, 2011, at 17:04 , Roland King wrote: > >> On Aug 1, 2011, at 7:32, Rick Mann wrote: >> >>> >>> On Jul 31, 2011, at 16:23 , Hunter Hillegas wrote: >>> Are you sure you don't need UIViewAnimationOptionAllowUserInteraction and >>

Re: Custom autocompletion with NSTextField

2011-08-01 Thread Joe White
Hi Kyle, thanks for the reply. On 1 August 2011 01:12, Kyle Sluder wrote: > On Sun, Jul 31, 2011 at 4:29 PM, Joe White wrote: > > Hi all, > > > > I'm currently implementing custom autocomplete functionality into a > > NSTextField. I've managed so far to generate a list of my own available > > w

CALayer memory management [was: Tracking down CALayer problem in iTunes plug-in]

2011-08-01 Thread Graham Cox
I've narrowed this error down to a very simple test case. I have a CALayer subclass. In this subclass, I've added properties which are synthesized and retained (in fact, they are NSColors). I don't attempt to animate these properties. In my -dealloc method, I'm setting these properties to nil,