Re: Which is the lightest way to draw images and text?
On Feb 2, 2011, at 9:22 PM, Omar Hagopian wrote: Hi there! I am planning to implement a component similar to the iphone's photo album.. I guess that using uviews will make the component to have a bad performace , I mean scrolling slow and all of the stuff ... so which way should I take? Is CALayer better than UIViews in terms of performance? Is there any other (lighter) way to draw images or text without using UIView subclasses? With iOS and UIKit, all UIViews are backed by a CALayer. UIView merely provides convenient ways to render the content of the backing CALayer, and after that, all rendering to screen is provided by CALayer and the Quartz compositor which in turn uses OpenGL. As long as the content of your UIView does not change frequently, there will be zero measurable performance difference between using UIView and using CALayer directly. That is because static images and text are rendered into the CALayer using whatever technique (OpenGL, Core Graphics, Core Image, Core Video, etc.) UIView and subclasses provide convenient methods to help you use OpenGL, Core Graphics, Core Image, Core Video, etc. and respond to events. If the content of your UIView does change frequently, that means that the content of the CALayer must be re-rendered frequently. Depending on re-render frequency, OpenGL, Core Graphics, Core Image, or Core Video may be preferred over higher level API for performance reasons. CALayers are implemented as OpenGL texture buffers, and OpenGL benefits from hardware acceleration on iPhone/iPad/iPod Touch. Therefore, OpenGL typically provides that absolute fastest rendering possible on the devices. However, OpenGL does not always produce the best quality output for a variety of reasons, so the trade-off becomes programmer productivity vs. quality of output vs. performance of rendering. Note that Core Graphics, Core Image, and Core Video most likely are already substantially implemented using OpenGL. IFAIK, text rendering in iOS doesn't use OpenGL except to provide the buffer for storing pixels. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: sending a message from an initializer method
Fair enough. On Jan 13, 2011, at 1:19 PM, Uli Kusterer wrote: On Jan 13, 2011, at 1:27 AM, Erik Buck wrote: Class or instance method makes no difference in this case with regard to polymorphism. It does. He's only passing the two instance variables to the class method. And, being a class method, self is the class, not the half-initialized instance. So what using a class method does, is it makes it possible for subclasses to change the computation by overriding the method (assuming he's using [[self class] compute:...] to call the class method, and doesn't hardcode the class name). However, since it's a class method, subclasses can't accidentally mess with the half-initialized object. Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: sending a message from an initializer method
Class or instance method makes no difference in this case with regard to polymorphism. On Jan 12, 2011, at 4:51 PM, Gordon Apple wrote: What I would do use a class method and pass the two arrays as parameters. On 1/12/11 2:03 PM, cocoa-dev-requ...@lists.apple.com cocoa-dev-requ...@lists.apple.com wrote: Yes, you can, but... don't forget that in -computeVar3... self is not fully initialized. If you have all control on self it can be without problems, but Objective-C is an OO language. Consider this : - Your class is ClassA with it's init method. - Then you have ClassB, subclass of ClassA. ClassB override -init cleanly (call super in the beginning etc.) - Then ClassC, subclass of ClassB. ClassC override -computeVar3. And then the problems can begin, in -[ClassC computeVar3] self is not fully initialize from the point of view of ClassA, but the initialization has not even began from the point of view of ClassB and ClassC. I think it's a break of encapsulation principle. If you want to put the code outside -init only for code readability, just use a plain C function. Frédéric Le 12 janv. 2011 à 12:41, Luc Van Bogaert a écrit : Hi, I have a question about how to design a initializer mehod. I have defined a class with three instance variables. Two of them are arrays and their value can be initialized straightforward in the initializer method, but the value of the third instance variable is the result of a complex algorithm, based on the contents of the two arrays. I would like to implement that algorithm in a seperate method, instead of writing it directly in the initializer. Is that OK, and could I then message self in the initializer like: - (id) init { self = [super init]; if (self) { var1 = ...; var2 = ...; var3 = [self computerVar3With:var1:var2]; } return self; } Or is it better to write the algorithm directly as part of the initializer? Thanks, -- Luc Van Bogaert luc.van.boga...@me.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/ftestuz%40bluewin.ch This email sent to ftes...@bluewin.ch -- Gordon Apple Ed4U Little Rock, AR ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSView drawing with superimposed text
Each time -drawRect: is called, the rect parameter is a dirty rectangle calculated by the frameworks to be the smallest area that needs to be redraw. With your implementation, you are probably filling several small sub-rectangles of the view's bounds with white and then stroking lines in only one of the small rectangles that the framework thinks need update. If you want to erase the entire view every time drawRect is called, try either [NSBezierPath fillRect:[self bounds]]; or [NSBezierPath fillRect:[self visibleRect]]; If you want the entire view to redraw for some reason, then send -setNeedsDisplay:YES to the view. If you want to redraw a sub rect of the view, send -setNeedsDisplayInRect:. Don't send either message from within the implementation of -drawRect: because it is too late then. The area that needs to be redrawn has already been calculated and the changes you make via setNeedsDisplay will be replaced/recalculated by the framework after -drawRect: returns. Also, don't call any variant of [self display] within -drawRect: because it may result in infinite recursion. Finally, if you want to be cleaver and optimize drawing, you can use [self getRectsBeingDrawn:rects count:count]; and implement method -wantsDefaultClipping to return NO. Reference: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaViewsGuide/SubclassingNSView/SubclassingNSView.html On Jan 2, 2011, at 1:36 PM, Michael McLaughlin wrote: With Xcode 3.2.5 and the corresponding IB, I have a custom NSView into which I want to draw. This view has 15 static text views in front of it, in the contentView only, all of which are filled in before the custom drawing and none of which draw their own backgrounds. The code for the custom drawing is -(void)drawRect:(NSRect)rect { [[NSColor blackColor] setStroke]; [[NSColor whiteColor] setFill]; [NSBezierPath fillRect:rect]; if (phase3) { // draw line NSBezierPath *path = [NSBezierPath bezierPath]; [path moveToPoint:NSMakePoint(0, 0)]; [path lineToPoint:NSMakePoint(520, 240)]; [path stroke]; } } This method is called three times during a complete rendering. Without the conditional (if statement), the result is as expected but, with it, the final (third) call to this method references a rect that does not correspond to anything in the window and the final window shows only a small portion of the line even though all of the superimposed text items should be transparent apart from their text. Obviously, I am missing something important about Cocoa drawing but could find no hints anywhere to help. Any tips? TIA. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Ensuring no selection in a table view
Enabling empty selection in IB should do the trick. You can also control selection programmatically with the delegate. http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSTableViewDelegate_Protocol/Reference/Reference.html Out of curiosity: Why not allow selection? Users might want to copy and paste information about documents. Selection doesn't have to mean editable.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView vs NSTextField
NSTextField doesn't display or edit text at all. It uses an instance of NSTextView calle dthe filed editor to provide all text dispay and editing. So you are right: NSTextFiled cannot do anythingthat NSTextView can't because NSTextField uses NSTextView. NSTextView is a large and heavy weight object. If you research the text subsystem, you will find multiple classes that collaborate to provide text display and editing. NSTextView is just the tip of the ice burg. It is the user visible View part of a huge infrastructure that includes Model and Controller components. It is a big deal to set-up and tear-down the whole infrastructure each time an NSTextField becomes editable. Therefore, all NSTextFields (Actually NSTextFiledCells) share a single NSTextView, the filed editor, per window. As for why not set-up the whole text infrastructure for every label and leave it set up...the best answer is that all of this software worked well on 8MB NeXT Cubes, and not instantiating the entire text system for every field is one reason why. --- On Thu, 11/11/10, Eric Gorr mail...@ericgorr.net wrote: From: Eric Gorr mail...@ericgorr.net Subject: NSTextView vs NSTextField To: Cocoa Dev cocoa-dev@lists.apple.com Date: Thursday, November 11, 2010, 8:45 AM It seems to me that NSTextView can do everything that NSTextField can and more. For example, on a NSTextView, one can use the method setHorizontallyResizable: and then call sizeToFit to get it to resize itself vertically instead of horizontally. Is this correct? If so and if I am programmatically creating one of these controls, is there any reason why I would want to use a NSTextField? (I know that IB uses a NSTextField for Labels, for example...is this just a historical artifact?) If not, what are the key differences between them that would cause me to want to use a NSTextField? Would it basically come down to whether or not I need more then a single line of text or not...NSTextField seems to be optimized for single lines of text, but one can still get the same behavior out of a NSTextView with a bit more work. Now, I know that NSTextFieldCell is commonly used as a superclass for one's own cell based stuff, but I would consider that as separate from the issue of NSTextField vs NSTextView. 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/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView vs NSTextField
Change Filed to Field where appropriate. Grumble...auto-correct...grumble. --- On Thu, 11/11/10, Erik Buck erik.b...@sbcglobal.net wrote: From: Erik Buck erik.b...@sbcglobal.net Subject: Re: NSTextView vs NSTextField To: Cocoa Dev cocoa-dev@lists.apple.com, Eric Gorr mail...@ericgorr.net Date: Thursday, November 11, 2010, 10:50 AM NSTextField doesn't display or edit text at all. It uses an instance of NSTextView calle dthe filed editor to provide all text dispay and editing. So you are right: NSTextFiled cannot do anythingthat NSTextView can't because NSTextField uses NSTextView. NSTextView is a large and heavy weight object. If you research the text subsystem, you will find multiple classes that collaborate to provide text display and editing. NSTextView is just the tip of the ice burg. It is the user visible View part of a huge infrastructure that includes Model and Controller components. It is a big deal to set-up and tear-down the whole infrastructure each time an NSTextField becomes editable. Therefore, all NSTextFields (Actually NSTextFiledCells) share a single NSTextView, the filed editor, per window. As for why not set-up the whole text infrastructure for every label and leave it set up...the best answer is that all of this software worked well on 8MB NeXT Cubes, and not instantiating the entire text system for every field is one reason why. --- On Thu, 11/11/10, Eric Gorr mail...@ericgorr.net wrote: From: Eric Gorr mail...@ericgorr.net Subject: NSTextView vs NSTextField To: Cocoa Dev cocoa-dev@lists.apple.com Date: Thursday, November 11, 2010, 8:45 AM It seems to me that NSTextView can do everything that NSTextField can and more. For example, on a NSTextView, one can use the method setHorizontallyResizable: and then call sizeToFit to get it to resize itself vertically instead of horizontally. Is this correct? If so and if I am programmatically creating one of these controls, is there any reason why I would want to use a NSTextField? (I know that IB uses a NSTextField for Labels, for example...is this just a historical artifact?) If not, what are the key differences between them that would cause me to want to use a NSTextField? Would it basically come down to whether or not I need more then a single line of text or not...NSTextField seems to be optimized for single lines of text, but one can still get the same behavior out of a NSTextView with a bit more work. Now, I know that NSTextFieldCell is commonly used as a superclass for one's own cell based stuff, but I would consider that as separate from the issue of NSTextField vs NSTextView. 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/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[ANN] A new book by Erik M. Buck
Of interest to Cocoa and OpenGL ES programmers: OpenGL ES for iOS: All of the Important Parts Addison-Wesley Professional (Developer's Library) [Paperback] Expected publication November 29, 2010. http://cocoadesignpatterns.squarespace.com/updates/ This book contains an introduction to modern graphics programming and succinctly explains effective uses of OpenGL ES of iOS. There are many demonstrative example programs because the best way to learn a graphics programming concept is to see it. The target audience for this book includes programming students and professionals who want to learn about graphics. The Internet is cluttered with obsolete code, suboptimal approaches, and anachronistic practices that have built up over decades. At least 12 different versions of the OpenGL standard exist, but modern OpenGL ES omits support for techniques that were common in previous versions. This book focuses on modern efficient approaches and avoids distractions from irrelevant and obsolete practices. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSImage
On Sep 19, 2010, at 12:36 PM, k...@highrolls.net wrote: Am I on the right track or is there something even easier? IMHO, No. Please explain why you would subclass NSImage to accomplish any of your goals. I suspect that the effort of making that explanation will be insightful. Hint: has-a vs. is-a What you want was called a palette in the original Interface Builder in 1988 and remained in vogue for 20 years or so until the invention of libraries in a recent update. You can still see a palette in Microsoft Visio which copied Diagram which copied the idea from Interface Builder. A quick search identified an interesting get-started tutorial that I just skimmed: http://cocoadevcentral.com/articles/56.php ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatic Cocoa (Interface Builder accessibility)
http://www.informit.com/articles/article.aspx?p=1211756seqNum=5 http://lapcatsoftware.com/blog/?s=without+a+nib http://lapcatsoftware.com/blog/2007/05/16/working-without-a-nib-part-1/ http://lapcatsoftware.com/blog/2007/07/10/working-without-a-nib-part-5-open-recent-menu/ http://forums.macrumors.com/showthread.php?t=598272 http://blog.kleymeyer.com/2008/05/creating-cocoa-applications-programatically-ie-nib-less/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: keyDown:theEvent
http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/Introduction.html See NSResponder or, in UIKit, UIResponder http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/EventHandlingBasics/EventHandlingBasics.html%23//apple_ref/doc/uid/1060i-CH5-SW11 http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/EventsiPhoneOS/EventsiPhoneOS.html%23//apple_ref/doc/uid/TP40009541-CH2-SW4 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/Introduction/Introduction.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UIView animation
I would add that any graph of objects that implements the NSCoding protocol can also be trivially copied. Interface Builder encodes and decodes object graphs when saving the xib/nib files and also when entering test interface mode. As a blatant plug: See Cocoa Design Patterns ISBN: 0-321-53502-2 Chapters 11, Archiving Unarchiving, and 12 Copying. --- On Fri, 9/3/10, Matt Neuburg m...@tidbits.com wrote: From: Matt Neuburg m...@tidbits.com Subject: Re: UIView animation To: Christian Ziegler chris.zieg...@me.com Cc: cocoa-dev@lists.apple.com Date: Friday, September 3, 2010, 11:50 AM On Fri, 03 Sep 2010 00:11:43 +0200, Christian Ziegler chris.zieg...@me.com said: Hi all, I could use your help because I'm running out of ideas! Here's the situation. I got this custom view on screen which I want to remove from the screen by moving it outside the left border of the screen. However at the same time, I want to move it back in from the right side but at a different y-Coordinate. So for instance it moves out at y=44 and at the same time it moves back in from the other side at y=0. I tried several approaches and the most promising (I reckon) is to create a copy of the view. This is not so easy though because UIView does not implement NSCopying. My custom view also has subviews and well the animation apparently gets a little confused if you animate two different (equal but different object) views which share the same subviews. I'm sure it's not true that you're running out of ideas; it seems to me that you're just avoiding the obvious: two different views that look alike. You created this view and its subviews at some time; therefore you can do it again. It's probably just a question of planning ahead. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Sample App Similar to Core Data Data Modeler?
You will find a similar connected lines to inputs and outputs interface in Quartz Composer. I don't think Apple has provided source code for either approach, but it is not that hard. One of my company's products contained a similar interface in NeXTstep (proto-Cocoa) in ~1996. We collaborated with some contract engineers who adapted a famous circuit board layout algorithm to our purposes so that connection lines would automatically reroute to preserve 90 deg. angles and minimize crossing lines as the boxes containing inputs and outputs are dragged around. Apple still hasn't caught up to our implementation ;) You can start from Apple's Sketch sample application source code for inspiration creating the graphics that can be dragged. Our application used NSCell subclasses to represent the inputs and outputs and host connection lines. For another example, there is a simple drawing application from Cocoa Design Patterns available freely in CocoaDesignPatternsSampleCode.zip at http://www.cocoadesignpatterns.com/sample-code/ See Ch29. It would be fun and interesting to add connection lines between the boxes in the Ch29 example. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Making an NSMethodInvocation from the current method
use blocks and gcd, or use a proxy http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSProxy_Class/Reference/Reference.html A proxy can forward all invocations to the main thread. Create a subclass of NSProxy. Implement – (void)forwardInvocation:(NSInvocation *)anInvocation { [anInvocation setTarget:realObject]; [anInvocation performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:NO ]; return; } See also Higher Order Messaging which uses proxies of a sort: http://www.metaobject.com/papers/Higher_Order_Messaging_OOPSLA_2005.pdf See also http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DistrObjects/DistrObjects.html On Aug 22, 2010, at 1:03 AM, Roland King wrote: Is there a built-in function to make an NSMethodInvocation from 'the current method I'm in with all current parameters', or does anyone have any code they've written to do this? Motivation, I'm writing a display class which can get updated from a background thread, it has a whole load of methods, some of which don't lend themselves to performSelectorOnMainThread (some take more than two arguments, some take primitives and I don't really want to wrap and unwrap into NSNumbers all over the place). What I really would like is in each method to be able to write something like if( ![ NSThread isMainThread ] ) [ NSMagicFunctionReturningAnInvocationForThisCurrentFunction() performSelectorOnMainThread:@selector( invoke ) withObject:nil waitUntilDone:NO ]; else { // method performing code here } but there is of course no such function I'm aware of nor can I easily think how I'd write such a thing. I have a current solution for those methods which are properties using forwarding because forwardInvocation: is the only function I know of which gives me a pre-packaged invocation object but I find it a bit inelegant and it only works for properties. That method briefly works as follows, if I want a property 'foo', I declare it, then use @dynamic to suppress the compiler warnings. In the class continuation I declare the same property prepended with an given prefix (I'm using TS_ for threadsafe) and implement it. I then override forwardInvocation: and methodSignatureForSelector: to check for the existance of a method TS_called selector and if it exists I switch the selector in the NSInvocation forwardInvocation: gives me and invoke it if I'm on the main thread or forward it to the main thread if I'm not. eg setFoo:123 is not implemented so methodSignatureForSelector: is called for setFoo: and I return the signature for TS_setFoo:. Then forwardInvocation: is called with a prepacked NSInvocation, I switch the selector to that for TS_setFoo: and invoke it. This only works for properties because I can only use @dynamic to suppress the warnings on those, other declared methods in the interface need to be implemented (or is there a way to suppress that warning) and the whole TS_ prefix thing seems a bit hokey to me so I was looking for a more direct way to make an NSInvocation. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Design pattern for core data, document based, graphical application
You have too many design options on the table. Try some of them in mini-prototypes to see how well they work and then drop some of the ideas. I have used Core Data to store Model data for 2D and 3D drawing/visualization applications. My approach was to use the Core Data designer to specify custom subclasses of each Core Data entity (NSManagedObject subclass). Then I don’t touch the custom subclass files themselves. I add methods for drawing to each subclass in categories. That way, the designer can regenerate the subclass interface and implementation files as many times as needed without impact to the code added in categories. For example, a Core Data entity for a “GraphicalThing” might have a “color” attribute stored as an archived NSColor instance in NSData. It might have an “isFilled” attribute stored as a Boolean. Then, a “CircleGraphicalThing” sub-entity of “GraphicalThing” is implemented as a subclass of GraphicalThing and add float attributes for “centerX”, “centerY”, and “radius”. Drawing pseudo code might be @implementation CircleGraphicalThing (Drawing) - (void)drawInContext:(id)aContext { NSColor *currentColor = [self transientColor]; if(nil == currentColor) { currentColor = [NSUnarchiver unarchiveObjectWithData:[self color]]; [self setTransientColor: currentColor]; } [aContext setColor: currentColor] [aContext drawCircleAtCenter:CGPointMake([self center], [self centerY]) radius:[self radus]]; } @end Drawing is not the Controller's responsibility. Drawing is a View responsibility, but in a drawing application, Model objects draw. If you need to support multiple types of View such as an OpenGL View in addition to a Quartz2D View, just have multiple categories. Add a -drawInOpenGLContext: method in a different category. Store the category implementation files as part of the View subsystem even though they extend Model objects. Most of your other questions are resolved using Controllers in ways that are independent of the Model details. For example, synchronous side effects are handled nicely by bindings that are set up in Interface Builder without any impact to the Model. A synchronous notifications are discouraged but can be accomplished with -performSelector:withObject:afterDelay: or by putting notifications in an NSOperationQueue, etc. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: concludeDragOperation
I have never seen the specific problem reported, but I have some suggestions: 1) Are you using a retained or non-retain window as opposed to a buffered window? You want a buffered window. 2) Is the view layer backed? I don't know ifthat could cause the problem, but I is a path to investigate. 3) Have you turned on Quartz Debugging to see which areas of the window are being redrawn? If so, where the highlighted areas redrawn or not? 4) Are you recursively causing displays? That doesn't work, so don't do it. Have you tried [outlineView performSelector:@selector(display) withObject:nil afterDelay:0.0f] instead of calling display again as the side effect of a display message? --- On Mon, 8/16/10, k...@highrolls.net k...@highrolls.net wrote: From: k...@highrolls.net k...@highrolls.net Subject: concludeDragOperation To: Cocoa-Dev Cocoa-Dev cocoa-dev@lists.apple.com Date: Monday, August 16, 2010, 6:02 PM The docs say: Invoked when the dragging operation is complete, signaling the receiver to perform any necessary clean-up. My question is how does one clean up all highlight artifacts in an NSOutlineView such as these: http://highrolls.net/high_light_issue/page.html I have tried -display , -reloadItem and reloadData all to no avail. Steve Jobs was stumped and suggested this list might be helpful. Was he right? -koko ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Wow! Just installed OPENSTEP ENTERPRISE 4.2
I had a shrinkwraped OPENSTEP Enterprise 4.2 CD from March 1997 in my file cabinet, so I just installed it on a crap 1.83GHz Core 2 (not-duo) running Windows XP SP3. - OPENSTEP Enterprise 4.2 installes from CD in less than 1 minute (not counting the neccessary reboot that follows) It is amazing how fast 13 year old software installs by today's standards. I have already built about huge amounts of code. Some is left over from the OPENSTEP days, but some is recent Mac OS X software. It is nice to be reminded how good stuff was 13 years ago. Alternately, it is sad how little Cocoa development has improved in 13 years. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Wow! Just installed OPENSTEP ENTERPRISE 4.2
For comparison, I installed MS Visual Studio 2010 Express Edition C++ on the same machine. It takes 14 minutes not counting the 2 reboots required. The first time Visual Studio 2010 C++ starts, it takes more than one minute to get past the splash screen. The user interface MS Visual Studio 2010 Express Edition C++ is painfully slow and has modal pop-up windows beseeching me to upgrade that that and the other thing. Microsoft seems to love modal dialogs and dialogs that can't be resized. For example, starting Visual Studio for the first time displays a small dialog containing a table. Only three or four lines of the table are visible at a time. I can scroll the table, but why can't I resize the dialog to reveal more rows? The 2010 built in Win Forms editor is a sad joke compared to a 13 year old Interface Builder. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
What patterns did we miss in Cocoa Design Patterns?
Don Yacktman and I have received feedback that Cocoa Design Patterns should have more coverage of multi-threaded and distributed design patterns. Some readers have asked for comparison and contrast between Cocoa design patterns and patterns in .Net or other frameworks. Is it worthwhile to restate the patterns in terms specific to Cocoa Touch, or are you comfortable extrapolating examples from Cocoa to Cocoa Touch? I am considering adding some supplemental articles to the book's web site or to http://www.cocoadev.com/. What additional patterns should be discussed? Should I make supplemental content editable as a wiki? For reference: site www.cocoadesignpatterns.com Table Of Contents http://my.safaribooksonline.com/9780321591210 Free samples: Prefacehttp://my.safaribooksonline.com/9780321591210/pref03 Chapter 1 http://www.informit.com/articles/article.aspx?p=1398611 Chapter 29 http://www.informit.com/articles/article.aspx?p=1397563 Chapter 30 http://www.informit.com/articles/article.aspx?p=1397564 Chapter 03 http://www.informit.com/articles/article.aspx?p=1339553 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Carbon is C++?
On Feb 28, 2010, at 10:49 PM, David Rowland wrote: On Feb 28, 2010, at 7:24 PM, Erik Buck wrote: I disagree. I have written very low latency device drivers in Objective-C. Why do you think Objective-C has too much latency for audio? When properly used, Objective-C programs are no more likely to be preempted than any other kind of program. Message dispatch generally has constant time and is only 2.5 times the cost of a C function call. That just cannot be true. But if you need speed you can write a direct C style subroutine and call, and it will be swift. The dynamic binding of ObC messages often isn't needed. http://www.mikeash.com/pyblog/performance-comparisons-of-common-operations-leopard-edition.html http://www.friday.com/bbum/2009/12/18/objc_msgsend-part-1-the-road-map/ http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/ http://www.mulle-kybernetik.com/artikel/Optimization/ See gcc option -fobjc-direct-dispatch Interesting research: http://www.jot.fm/issues/issue_2009_01/article4/ There aren't many function calls or messages sent in audio processing anyway. Signal processing routines tend to be long loops. Objective-C _IS_ C which means it is likely usable in any situation where C is usable. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: High Level Toolkit -- is it obsolete or not?
Never call -drawRect: directly. It is a Template Methods i.e. Don't call us; we'll call you. (Note: there might be some exceptions that prove the rule.) As of Leopard and possibly sooner, individual dirty rectangles are available through the - getRectsBeingDrawn:count: method if you use it within the implementation of -drawRect:. Use - (void)getRectsBeingDrawn:count: for more detail beyond the automatically coalesced rectangle passed into -drawRect:. - (void)getRectsBeingDrawn:(const NSRect **)rects count:(NSInteger *)count Parameters rects On return, contains a list of non-overlapping rectangles defining areas to be drawn in. The rectangles returned inrects are in the coordinate space of the receiver. count On return, the number of rectangles in the rects list. On Feb 26, 2010, at 9:30 AM, Joel May wrote: Nick, I'm using [NSView setNeedsDisplayInRect: r] and [NSView drawRect: r], so I'm not explicitly flushing and that's not goofing things up. Beam-sync is related to flushing, I think. I don't know how to turn it on or off programmatically and it does not appear in QuartzDebug -- I think it was removed in Snow Leopard or the newest XCode. It might be renamed to AutoFlush drawing. However, I've found that I was not using the right CG function: I was using CGContextDrawTiledImage() and should have been using CGContextDrawImage(). In my early testing I came to the mis-conclusion that CGContextDrawTiledImage() was faster. It is actually about twice as slow. I was jumping between machines and not being methodical about my testing. I've redone speed tests and now if I don't stretch the window, the screen update is fine on my new iMac. If I do stretch to full screen, CGContextDrawImage() takes about 80 ms and CGContextDrawTiledImage() takes about 140ms. Then I turned on QuartzGL (which I had never heard of until your email, thanks) with HIWindowSetBackingLocation(windowRef, kHIWindowBackingLocationVideoMemory). Now, CGContextDrawImage() takes 4ms or less to update the entire screen. This is beautiful. I still need to test on my Tiger, PPC mac. I'm thinking screen updates with Quartz will be a problem there, but I don't know yet. I might have to use a separate executable with QuickDraw. I use copybits in my own dirty rectangle handling in Carbon code. [NSView drawRect: r] seems to coalesce all the dirty rectangles into one big rectangle that also contains a lot of area that is not dirty. My old code has smaller, non-overlapping dirty rectangles updated with copybits which should be more efficient. Conclusion: * Quartz is actually sufficiently speedy to update the screen, at least on a new mac. * QuartzGL is great, esp when stretching the image. * Not sure about Tiger (no QuartzGL) or older machines yet. Might need to stay with QuickDraw/copybits. Thanks for your help. I would have wasted a lot of time with CoreAnimation, which I don't need for this project. Joel On Feb 23, 2010, at 5:50 PM, Nick Zitzmann wrote: On Feb 23, 2010, at 4:35 PM, Joel May wrote: Thanks for the info about drawing in a different thread. I won't waste my time and sanity. I guess I need to figure out how to speed up the drawing instead and keep it in the main thread. How often does your app flush its changes? If it's more than 30 f/s, then you're wasting redraws, and either need to disable beam sync, or cut back on the animation. You can use Quartz Debug to find out, and control the beam sync feature. Did you also try QuartzGL? It didn't work correctly in Tiger, and it's off by default in Leopard Snow Leopard, but it ought to work on most Macs. Again, you can experiment with this using Quartz Debug. Nick Zitzmann http://www.chronosnet.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/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stop editing session of NSTextField
send [[textField window] makeFirstResponder:[textField window]]; to finish any editing in progress in textField or any other text field within the window. or see Forcing the End of Editing at http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextEditing/Tasks/BatchEditing.html Some people like if (![myWindow makeFirstResponder: myWindow]) { [myWindow endEditingFor: nil]; } FYI: This question has been answered many times in the list archives. :) On Feb 24, 2010, at 8:05 AM, Nikhil Khandelwal wrote: Hi, How can I end the editing session for NSTextField forcefully. I tried abortEditing however it does not accept the changes made to NSTextField. I want the changes made to NSTextField acceptable when I quit the editing session. Thanks in advance. Nikhil DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erik.buck%40sbcglobal.net This email sent to erik.b...@sbcglobal.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data with OpenGL
For a variety of reasons, I use Core Data with OpenGL all of the time. One of my presentations this weekend at Voices That Matter: iPhone Developers Conference uses a Core Data application with two different Views as an example of the MVC design pattern. One View presents information about the Model using Core Graphics/Quartz. The other View presents information using OpenGL ES. I think that the Core Data model and any generated classes should be left untouched because you may want to regenerate the classes later. I use Categories to add View specific drawing methods to the objects that represent Core Data entities. There are different categories with different methods in each View. E.g. there are -drawInOpenGLContext: methods added to entity objects within the OpenGL View subsystem and there are -drawWithCoreGraphics methods added in the Core Graphics View subsystem. There is ample precedent for adding View specific capabilities to Model objects via categories. AppKit adds string drawing methods to NSString. You definitely don't want your View subsystem constantly asking Model objects what kind they are in order to present information. If you have ifs or switches based on the class of objects or even based on an attribute of an Entity, you are doing it wrong. It is much cleaner to use the built in language polymorphism. Just keep View related code implementation within the View. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: enabling/ disabling a uitextfield
Do you have some objection to [myTextFiled setEnabled:YES]; and [myTextFiled setEnabled:NO]; ?Perhaps you prefer myTextFile.enabled = NO; ? UITextField is a subclass of UIControl which means that all of UIControls properties and methods are available in UITextField. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: XC IB 3.2 overlapping siblings
Remember that all controls are views. Overlapping sibling controls have a definite user interface smell. Assuming that the overlapping controls are visible at the same time, the appearance is likely to be unsatisfactory. Issues of mouse based picking arise. Which control will be hit by which mouse click particularly when controls have transparent rounded edges etc? If nothing else, this will be a violation of the Aqua user interface guidelines, and that might matter to some users. Assuming that the overlapping controls are not visible at the same time, the issues of user discoverability and disappearing user interface elements mentioned earlier in this thread arise. Regarding views in general: Overlapping sibling views degrade direct frame buffer operations such as the ones used by movie views and open gl views. That may or may not be an issue. Overlapping sibling views degrade operations like copy on scroll when a sibling of a clip view overlaps a scroll/clip view. Overlapping sibling views that accept mouse input may have issues with picking etc. Regarding the specific example of controls that appear over a movie view: I suppose it is common enough behavior now that it won't surprise users although I am still surprised every time the mouse is jiggled (by the dog or the wind or a child or turbulence) while I am watching a show (Glee) in iTunes and a translucent panel obscures my view of the show (Cheerleaders). Nevertheless, the solution from both a performance and user interface perspective is to use an overlay view implemented with Cocoa's child windows as demonstrated here: http://developer.apple.com/mac/library/samplecode/GLChildWindowDemo/ Modern Core Animation layers are also a good choice (that uses the same technique) if your movie view is also a layer. I don't think it ever makes sense for a movie view to have an overlapping sibling view. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: XC IB 3.2 overlapping siblings
Don't overlap sibling views. Even though it works reliably now, it is still a poor practice for controls and has a definite user interface smell. If you must use the same area of the user interface for different purposes at different times, consider using a tab view with no visible tabs and programmatically changing which subview of the tabview is visible. However, you should reconsider your user interface design. When the user interface changes based on application mode and buttons appear, disappear, change size or title, etc., users are confused. Such interfaces are not discoverable. How is a user supposed to know that a different button will appear in some circumstances? How does the user know what options are sometimes available but aren't available now? Users are frustrated when they remember that there used to be a handy button and now it isn't there. User interface elements that are not currently applicable should be disabled but not hidden. If different interfaces are needed for different application modes, use established conventions like tab views and disclosure areas. Instead of changing a button to reflect application mode, allow the user to control the change of application mode by deliberately selecting a different tab or expanding a disclosure area or pressing a next button. Users should be in control, and every user interface change should have a cause that is obvious to the user. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSImage rotation regression?
The -bestRepresentationFirDrevice: method is doing nothing better than [anImage size] would do for you. You are not doing anything useful with rotatedSize in your code. Your test for if (degrees == 180.0) is completely pointless. If you were going to do it anyway, you should be looking for 90, 180, and 270 degrees as well as all other multiples of 90 deg. Why do you copy originalSize into rect? How about the following alternative code typed in Mail @implementation NSImage (MYAdditions) - (NSImage *)copyRotatedByDegrees:(CGFloat)degrees { NSSize originalSize = [self size]; NSRect originalRect = NSMakeRect(0.0, 0.0, originalSize.width, originalSize.height); NSSize halfOriginalSize = NSMakeSize(originalSize.width / 2.0, originalSize.height / 2.0); NSAffineTransform* transform = [NSAffineTransform transform]; [transform rotateByDegrees: fmod(degrees, 45.0)]; NSSize halfRotatedSize = [transform transformSize:halfOriginalSize]; NSSize rotatedSize = NSMakeSize( (2.0 * halfRotatedSize.width), (2.0 * halfRotatedSize.height)); [transform rotateByDegrees: -fmod(degrees, 45.0)]; NSImage *rotatedImage = [[[NSImage alloc] initWithSize:rotatedSize] autorelease]; [rotatedImage setBackgroundColor:[NSColor clearColor]]; [rotatedImage lockFocus]; [transform translateXBy:halfRotatedSize.width yBy:halfRotatedSize.height]; [transform rotateByDegrees: degrees]; [transform translateXBy: -halfRotatedSize.width yBy: - halfRotatedSize.height]; [transform concat]; [self drawAtPoint:NSZeroPoint fromRect:originalRect operation:NSCompositeSourceOver fraction:1.0]; [[NSColor blackColor] set]; NSFrameRect(originalRect); [rotatedImage unlockFocus]; return rotatedImage; } @end ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What's actually important to do before exiting?
- Posix message queues are a finite kernal resource that is not freed when processes terminate incorrectly. - Posix semaphores are a finite kernal resource that is not freed when processes terminate incorrectly. - MACH IPC message queues are a finite kernal resource that is not freed when processes terminate incorrectly. - Socket's left open may tie up a port for several minutes when processes terminate incorrectly. - NFS file locks may tie up a file for several minutes when processes terminate incorrectly. - The /tmp directory can be littered with junk until the next reboot or cron job when processes terminate incorrectly. Few Cocoa programmers ever deal directly with the above system resources, but I am a Cocoa programmer, and I use them every day Unix is generally good about cleaning up when processes exit, but there are holes large enough to drive trucks through. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to find active user in the cocoa
http://developer.apple.com/qa/qa2001/qa1133.html answers your question perfectly. That was the first hit when I typed console user into the search field at developer.apple.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 arch...@mail-archive.com
Dynamic UI with scroll view
NSLog(@%@, [scrollView documentView]); //outputs (null) What does NSLog(@%@, scrollView ); tell you ? // the following is a memory leak if you are not using garbage collection [scrollView setDocumentView:[[NSView alloc] initWithFrame:NSMakeRect(0, 0, 500, 500)]]; Try [scrollView setDocumentView:[[[NSView alloc] initWithFrame:NSMakeRect(0, 0, 500, 500)] autorelease]]; If scrollView is not nil, the above code will do what you want except that an instance of plain NSView doesn't draw anything so the scroll view will look empty with scroll bars appropriate for a 500 by 500 document view. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: dragging to move objects around?
I didn't see any actual question. I think you also need to post more code if you want anything better than wild guesses about what you are doing. Start here: http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/DragandDrop.html I assume you are using - (void)dragImage:(NSImage *)anImage at:(NSPoint)imageLoc offset:(NSSize)mouseOffset event:(NSEvent *)theEvent pasteboard:(NSPasteboard *)pboard source:(id)sourceObject slideBack:(BOOL)slideBack What offset are you using, and does that account for changes in x position? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
List FAQ and Cocoa learning resources
Didn't there used to be a FAQ list for Cocoa-Dev? Several people recently asked me for links to introductory Cocoa and Cocoa Touch information. I pointed iPhone folks to http://developer.apple.com/iphone/library/navigation/GettingStarted.html and the others to http://developer.apple.com/referencelibrary/GettingStarted/GS_Cocoa/index.html . The Cocoa Getting Started link was actually hard to find. It is buried under Reference Library and then Cocoa. I seem to remember it being on the front page of Mac Dev Center the way the similar link is on the front page of iPhone Dev Center. Anyway, I didn't find a FAQ for this list. Does one exist? Did I miss it because I always read through Cocoabuilder ? Do any of you recommend technical conferences or training for introductory Cocoa developers? At least one person asked me to recommend training that his company could reimburse. I have always heard great things about the Big Nerd Ranch and enjoy Aaron Hillegass' books. Are there other formal training opportunities outside of full blown university courses? Are there informal courses beyond the fabulous university pod casts on iTunes? There is the annual WWDC. Isn't there a conference in Chicago too? I think MacHack in Flint MI is defunct - right? I know about http://www.voicesthatmatter.com/iphone2009/ in Boston because I will be speaking at it (blatant plug - contact me for attendee discounts...) Are there any other conferences? Are there any in Europe, Asia, or Australia? Is the http://www.cocoadev.com/ Wiki a good place to send newbies in your opinion? I used to think so, but the site seems chaotic and stale now... I would love to be corrected though. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Found Re: List FAQ and Cocoa learning resources
Sorry. Right after I posted, I found http://www.cocoadev.com/index.pl?FAQs On Jul 21, 2009, at 6:07 PM, Erik Buck wrote: Didn't there used to be a FAQ list for Cocoa-Dev? Several people recently asked me for links to introductory Cocoa and Cocoa Touch information. I pointed iPhone folks to http://developer.apple.com/iphone/library/navigation/GettingStarted.html and the others to http://developer.apple.com/referencelibrary/GettingStarted/GS_Cocoa/index.html . The Cocoa Getting Started link was actually hard to find. It is buried under Reference Library and then Cocoa. I seem to remember it being on the front page of Mac Dev Center the way the similar link is on the front page of iPhone Dev Center. Anyway, I didn't find a FAQ for this list. Does one exist? Did I miss it because I always read through Cocoabuilder ? Do any of you recommend technical conferences or training for introductory Cocoa developers? At least one person asked me to recommend training that his company could reimburse. I have always heard great things about the Big Nerd Ranch and enjoy Aaron Hillegass' books. Are there other formal training opportunities outside of full blown university courses? Are there informal courses beyond the fabulous university pod casts on iTunes? There is the annual WWDC. Isn't there a conference in Chicago too? I think MacHack in Flint MI is defunct - right? I know about http://www.voicesthatmatter.com/iphone2009/ in Boston because I will be speaking at it (blatant plug - contact me for attendee discounts...) Are there any other conferences? Are there any in Europe, Asia, or Australia? Is the http://www.cocoadev.com/ Wiki a good place to send newbies in your opinion? I used to think so, but the site seems chaotic and stale now... I would love to be corrected though. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iTunes COM interface for Windows; need the equivalent for
I doubt Apple is going to port Cocoa/CoreData to Windows just for iTunes database� Not that I disagree, but what makes you think Cocoa doesn't already work on Windows? Openstep worked on Windows before it worked on Mac OS X. Cocoa is derived from Openstep. Project Builder (the predecessor to Xcode) is a nifty Cocoa application that Apple delivered for the Windows flavor of Web Objects as recently as September 17, 2003. If Cocoa apps from 2003 work on Windows, why would modern Cocoa not compile and run on Windows if Apple wanted it to? Core Foundation seems to be largely present in iTunes already, and Core Foundation is also partly derived from Openstep. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Clarification on accessors? (was: Yet another memory management question)
I have re-written the Accessors chapter of Cocoa Design Patterns several times because of controversy over whether accessors should, can, must or must not be used in initializers and dealloc. The bottom line is that accessors are the only way to set synthesized instance variables to nil in the modern (64bit) Objective-C runtime. Furthermore, you must use accessor for properties that are not backed by instance variables e.g. properties stored in axillary dictionaries etc. Accessor must be used in initializers and dealloc in at least some cases. I like consistency, and I use accessors within initailizers and dealloc. An excerpt of my current recommendation (especially a note:) follows: Confining Memory Management to Accessors If the Accessors pattern is -[if supportFields]consistently applied, almost all memory management for objects can be confined to accessors. When initializing object instances, use a set accessor to set the value of each object property. For example, the following implementation of -(id)initWithStringValue:(NSString *)aValue method uses an accessor to store the string value rather than making a direct assignment to an instance variable: - (id)initWithStringValue:(NSString *)aValue { self = [super init]; [self setStringValue:aValue]; // set the initial value of the property return self; } The process of initializing instances is described in Chapter 3, Two-Stage Creation. The -dealloc method can indirectly release referenced objects using the set accessors and avoid memory management code in its implementation as follows: - (void)dealloc { [self setStringValue:nil]; // any previous string value is released [super dealloc]; } Note Some programmers have historically avoided using accessors within initializer methods and -dealloc because a subclass may override inherited accessors to cause side effects. Using the overridden accessors within the superclass’s initializer might invoke side effects before the subclass instance is fully initialized. Similarly, accessors called from within the superclass’s -dealloc may cause side effects in partially deallocated instances. However, there is no practical alternative to using accessors when you use synthesized instance variables with the modern Objective-C 2.0 runtime or use properties that are not implemented as instance variables. In such cases, accessors provide the only way to initialize the properties or set the properties to nil. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Clarification on accessors? (was: Yet another memory management question)
What about properties that aren't backed by instance variables? Accessors are still needed to set properties stored in an auxiliary dictionary etc. There are literally only hours left for me to change a recommendation in Cocoa Design Patterns that you SHOULD use accessors in initializers and -dealloc. Remind me again why I shouldn't ? --- On Wed, 7/8/09, Bill Bumgarner b...@mac.com wrote: From: Bill Bumgarner b...@mac.com Subject: Re: Clarification on accessors? (was: Yet another memory management question) To: Sean McBride s...@rogue-research.com Cc: Erik Buck erik.b...@sbcglobal.net, cocoa-dev@lists.apple.com Date: Wednesday, July 8, 2009, 7:23 PM On Jul 8, 2009, at 1:40 PM, Sean McBride wrote: On 7/8/09 11:20 AM, Erik Buck said: The bottom line is that accessors are the only way to set synthesized instance variables to nil in the modern (64bit) Objective-C runtime. True. But if I remember previous discussions correctly, that's a bug, not a feature. Correct. 'Tis a bug. A fixed one, too, if you have access to the Snow Leopard seeds or grab the clang compiler from the llvm.org repository. 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 arch...@mail-archive.com
Re: What is the best way to store some kind of identifying string in an interface builder object?
It compiles because NO == nil == NULL == 0. I shouldn't have posted the silly example which doesn't work in most cases. how about this typed in mail: @interface NSView (MYGroupEnable) /// Enable all controls nested within the receiver - (void)enableSubviews { for(NSView *currentView in [self subviews]) { if([currentView respondsToSelector:@selector(setEnabled:)]) { [currentView setEnabled:YES]; } else { [currentView enableSubviews]; } } } /// Disable all controls nested within the receiver - (void)disableSubviews { for(NSView *currentView in [self subviews]) { if([currentView respondsToSelector:@selector(setEnabled:)]) { [currentView setEnabled:NO]; } else { [currentView disableSubviews]; } } } @end On Jun 19, 2009, at 3:23 AM, Graham Cox wrote: On 19/06/2009, at 3:59 AM, Erik Buck wrote: use [[myBox subviews] makeObjectPerformSelector:@selector(setEnabled:) withObject:NO]; or similar. Are you certain that works? 'NO' isn't an object, so I didn't think you could use -makeObjectsPerformSelector:withObject: in this fashion - or is there some magic available that isn't mentioned in the docs? The docs appear to state explicitly that the single argument to the selector must be type id. However it does seem to compile without complaint, though I'm not sure why... If this is permitted, does it work with rects, points, etc? Alternatively you can use: [[box subviews] setValue:[NSNumber numberWithBool:NO] forKey:@enabled]; since KVC converts to scalars as needed. Another problem here is that setEnabled: only works on NSControls or derivative, not NSViews. So you'd have to be certain that all your subviews were controls, otherwise it will throw with an unknown property error when it hits the first non-control view. Or you could implement -setEnabled for NSView in a category. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What is the best way to store some kind of identifying string in an interface builder object?
See the - (void)setRepresentedObject:(id)anObject method of NSCell. You can set a string or dictionary and the represented object and retrieve it via -representedObject. You can also instantiate an array and add objects to the array within IB. Then you only need an outlet instance variable to reference the array and not separate instance variables for all of the user interface objects. See Foundation Collections Palette You can populate the array entirely within IB. Make any target/action connections in IB. http://www.geocities.com/kritter_cocoadev/ For some final advice: Don't do what you are contemplating. Users hate interfaces that change outside the user's control. If a group of objects are going to appear or disappear, consider whether they should become enabled or disabled instead. If objects are logically associated, group the objects together visibly in boxes or matrix or tabs or through other means. Then you can enable or disable all elements of the box in code without needing to have outlets for every element. You can even hide or unhidden the whole box. use [[myBox subviews] makeObjectPerformSelector:@selector(setEnabled:) withObject:NO]; or similar. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Group CGAffineTransform Animations?
Only a little bit of math is neccessary to use affine transforms. A lot of math is needed for general 3D programming, but let's ignore that for now. My third grader was tought about associative and communitive math operstions. Some matrix operations are associative and some are communitive. That's why the order of operations matters. To scale and rotate a square without moving the center of the square, do the following: A) translate to the center of the square making that position the new origin for scaling and rotation. B) Scale the coordinate system. C) Rotate the coordinate system D) Translate back to the original origin F) Draw the square It's not so hard typed in web-mail: CGAffineTransform TransformToScaleAndRotateAboutCenterOfSquare(NSRect someSquare) { CGAffineTransform transform = CGAffineTransformMakeTranslation( NSMidX(someSquare), NSMidY(someSquare)); transform = CGAffineTransformScale (transform, 2.0f, 2.0f); transform = CGAffineTransformRotate(transform, DEGS_TO_RADS(90)); transform = CGAffineTransformTranslate(transform, -NSMidX(someSquare), -NSMidY(someSquare)); return transform; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Group CGAffineTransform Animations?
My third grader was taught about associative and commutative math operations. Some matrix operations are associative and some are commutative. That's why the order of operations matters. Just in case: I didn't mean to imply that even third graders should understand matrix math. It was just a stream of consciousness statement intended to express that my son actually caused me to remember the terms associative and commutative. I was reminded by a third grader :) You're absolutely correct in general, but - if I'm not mistaken - CGAffineTransform rotations and scalings already do their thing with respect to the center of the view they're being applied to. In fact, I tested that before writing my solution to the OP's problem. And that is indeed the source of the problem. Rotations and scalings, as implemented by CGAffineTransform, are with respect to the view's center but translations are with respect to the view's origin. Therefore, if you scale while you translate, the view's origin changes and the translation is no longer being applied with the correct offset. To be honest, I'm a bit surprised that CGAffineTransform rotations and scalings are already defined with respect to the center of the view. There's still a part of my brain that thinks that that isn't true, but my tests indicated otherwise. Wagner OK. I will have to try this at home. If you create a CGAffineTransform as I did and then use [myUIView setTransform:myTransform], how can a UIView know that part of my transform matrix applies one way and another part applies another way ? I think it is mathematically impossible unless the view is pulling components out of the transform matrix rather than just concatenating the matrix I supply with whatever matrix it's superview uses. If it pulls components out of the transform matrix, it is not a proper affine transform (because shear and skew and some degenerate cases will not work) and all of the functions are misnamed. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: to NIB or not to NIB
I have a pet theory about why IB is totally obvious at the first encounter for some people and prompts other people to write about ...5 failed attempts (over the years) to learn IB... Before I share my theory and bias the responses, I hereby ask those readers who resisted IB for a long time or never adopted it a few questions: Did you have a firm intellectual concept of software objects and object oriented programming before using IB ? Did you consider yourself to be an intermediate or advanced C++ programmer before using IB ? Did you consider yourself an expert user of any other interface building tool before using IB ? Had you ever heard of the Model View Controller pattern before using IB ? Had you ever made non-trivial use of COM, OLE, Active X, or Java Beans before using IB? If you have the time, I would love to read about the problems, misconceptions, or dislike you have or had for IB. Feel free to send email to me off-list. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Card Game (like Spider-Solitaire) in Cocoa -- Conceptual ideas needed
http://developer.apple.com/samplecode/GeekGameBoard/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSButtonCell never asked to draw its whole rect -- clips at width 54.0
Set the frame of the NSMatrix. Use -sizeToFit. - or- create and size the matrix the way you want it in IB; save it as a stand alone view; load it; add it as a subview, and add/remove cells to suit your needs. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: A couple questions about graphics
Announced publicly today: Digital Asset Exchange support. Collada Digital Asset Exchange (.dae) files are a popular way to share 3D models and scenes between applications. Preview now displays these files with OpenGL-powered 3D graphics, so you can zoom and rotate around a 3D scene and play viewpoint animations. You can also print the scene or save it as an image or movie file. And you can use Quick Look to display them as well. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: A couple questions about graphics
I have not used any of these VRML resources, but some may be helpful. I think that Blender can output VRML. SketchUp definitely can. http://www.apple.com/downloads/macosx/imaging_3d/freewrlvrmlx3dviewer.html http://sketchup.google.com/support/bin/answer.py?hl=enanswer=114420 http://www.macweb3d.org/ --- Blender includes a game engine: http://download.blender.org/documentation/NaN_docs/BlenderGameReference/ketsji.html --- There are lots of open source samples of loading 3D models from various tool chains. For example, the entire Quake game engine is available including Quake model exporters for popular commercial 3D editors. Effective 3D graphics programming requires math beyond high school. Moderately advanced software data structures are involved. Loading models is to tip of the iceberg. You will need Euler angles, view frustum culling, and lots of linear algebra. You will need to understand the archaic and sometimes absurd quirks of the OpenGL API that are left over from the dark ages of programming. Basically, SGI documented the current capabilities of its esoteric graphics hardware in about 1991 and that became the OpenGL standard. If SGI hardware couldn't do something, that feature was not in the original standard. If SGI hardware did something stupid like not scaling vertex lighting calculations, OpenGL has been forced to preserve the stupidity ever since. For example, OpenGL 1.1 partly solved a problem that had been in OpenGL from the beginning because the reference SGI hardware could not correctly calculate lighting if there was any scaling in the current transformation matrix. See glEnable(GL_NORMALIZE). That solution doesn't work very well so OpenGL 1.2 added glEnable(GL_RESCALE_NORMAL). The OpenGL ARB works at a glacial pace... As a Mac fanboy, I have to say that Apple and the open source community are a decade or more behind Microsoft in every regard to 3D graphics programming. OpenGL ES cuts a lot of crud out of OpenGL and offers a hopeful future... Don't be too discouraged. If you choose to learn OpenGL programming and write your own model loading and display code, you will likely find it a rewarding and educational experience. I certainly did. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSString initWithFormat and stringWith
Don't ever write either of the following lines: NSString *string1 = [NSString stringWithFormat:@myFirstString]; NSString *string2 = [[NSString alloc] initWithFormat:@mySecondString]; the WithFormat methods parse the argument string. If your argument string contains any '%' characters those lines will likely crash. Use NSString *string1 = [NSString stringWithString:@myFirstString]; or NSString *string2 = [[[NSString alloc] initWithString:@mySecondString] autorelease]; As I have written it above, you are not taking responsibility for later releasing either string1 or string2. As an alternative, use NSString *string1 = [[NSString stringWithString:@myFirstString] retain]; or NSString *string2 = [[NSString alloc] initWithString:@mySecondString]; or NSString *string3 = [@myThirdString copy]; In all of the alternate cases, you are taking responsibility for later releasing string1, string2, and string3. As requested by the moderators for good reason and rather than misstate the simple memory management rules, I will just reference the official answer which is clear and precise and easy to follow: http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Categories and splitting an app into logical blocks.
Is it a good idea to split all those classes into categories for writing, reading and testing? For example, Database (Writing), Database(Reading), Database(Testing) and so on? Or is it a silly thing to do for some reason? Maybe ? What trade-offs have you considered ? On reason to use categories is just to break large class implementations into separate files for whatever reason: logical grouping, separate authors, short files, incremental compilation,... Don't implement the same method in multiple categories though. That least to chaos quickly because the order in which categories load is unspecified and can change. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: custom NSViews and subviews - creating in IB
Do you have a question ? Why don't you just create a subview with various controls in IB. Then, in code, make a copy of that object and in turn make modifications to some of the objects in that view. For example, set a text field to a value. Then, add it to a super view. You seem to know exactly what to do. Which step eludes 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 arch...@mail-archive.com
Re: question about mutable vs. non-mutable
The whole debate about mutable and immutable classes, the inheritance hierarchy, what it means to return a pointer to a supposedly immutable object, what it means to store a pointer to a supposedly immutable object, the substitutability principle of object oriented programming, whether alternative designs should have been used, comparisons to the const keyword in C++, documentation criticisms, and countless inane comments were conducted in 1996. There is nothing to add now (13 years later): http://groups.google.com/groups/search?hl=enas_q=immutableas_epq=as_oq=as_eq=num=100scoring=lr=as_sitesearch=as_drrb=qas_qdr=as_mind=1as_minm=1as_miny=1981as_maxd=1as_maxm=1as_maxy=2009as_ugroup=comp.sys.next.programmeras_usubject=as_uauthors=safe=off ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Full content of Cocoa Design Patterns available as Rough-Cut on-line
The full content of the forthcoming book, Cocoa Design Patterns, is now available as Rough-Cut on-line: http://my.safaribooksonline.com/9780321591210?portal=informit ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Any interest in an article comparing and contrasting Cocoa with MS Managed C++ with CLI
I am a Cocoa expert, and I have been teaching myself Microsoft Managed C++ (a language very different from ANSI/ISO standard C++) along with Microsoft's CLR/CLI (.Net) frameworks. I am still a novice with Managed C++ and .Net, but I have already drawn some conclusions that were surprising to me. Is anyone interested in an article or series of articles comparing and contrasting Managed C++ with Objective-C and CLI (.Net) with Cocoa ? I started with the ubiquitous Currency Converter example, and so far I have worked up to a flexible interactive engineering units conversion calculator. I have examined interface building tools, model development support tools, binding and data source techniques, etc. Assuming there is interest, is there a preferred venue ? Scott, are you interested in articles for Stepwise ? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: MVC, storing VIEW-specific information and core data
Let me explain how I solved the same problem: I have an application that stores large data files via Core Data. Multiple users access the same data at different times, and each user has a preferred way of visualizing the data. E.g. starting point, filter sets, color coding, etc. all differ for every user for every document. The user's want their view configurations preserved even if the last person who modified the data used a different view configuration. My solution: Most of my Core Data entities have a Data blob attribute which is actually and archived dictionary of extra data. Each user's per-document view configuration is stored under keys within each blob. The Data blobs start out nil which just defaults to something reasonable in each view. Question 1: Why not store the view attributes in separate Core Data attributes or in relationships ? Answer 1a: The application allows users to strip all view configuration information out before delivering to a customer. That makes the files smaller and removes information that won't benefit the customer anyway. It's easy to strip the information by just walking through all entities and setting the extra data attribute to nil. Answer 1b: Most user's never set most extra data attributes, so why reserve storage for pointless default values. Plus, I can invent new view attributes at any time by just using new dictionary keys without changing the Core Data model. Question 2: Why store the extra data in Core Data at all instead of a separate file in a bundle?: Answer 2: I tried it both ways, and there didn't seem to be any reason to create an extra file per document just for this. Question 3: Doesn't this violate the MVC pattern? Answer 3: The Model is any data the user cares about, so if the user cares about the position and color of elements, that information is part of the Model. The only issue is that different users want different information about the same data. Sometimes a single user wants multiple conflicting sets of information about the same data. I actually show the user all of the named view configurations that are available in a particular document and let the user pick which one to view at that moment. The user can have multiple views of the same data open at once. Question 4: Why not use Core Data's context merging features and store extra data in a separate context? Answer 4: I didn't know how, and it didn't seem necessary to learn at the time. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: MVC - Model View Control
As an author, I humbly recommend http://my.safaribooksonline.com/9780321591210. Check out the table of contents. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView very slow, any remedies?
Why is NSTextView slow for you ? What profiling have you done, and what does it say is taking all the time ? I have used NSTextView happily with 100 MB text files before. I have seen slow behavior under the following conditions: - Change the text content (NSTextStorage) from within -drawRect: or one of the layout methods. This is unsupported and in the best case causes combinatorial re-layout. In the worst case it produces incorrect display. Don't do this. - Pragmatically insert text just before the visible page: NSTextView may have to perform page layout of text before it can redraw the visible page. The solution that works for me is to coalesce frequent changes to text and perform fewer total inserts. - Use of complex text containers. They need to be fast in order to keep layout fast. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Running Cocoa applications from file servers
There is a interesting but long rant about software installers at http://www.bynkii.com/archives/2009/02/on_installers.html. Most of the rant is about problems with pushing applications to remote client computers. I'll try to keep this Cocoa related: All of the applications I develop are Cocoa applications, so for me at least, the answers will only be relevant to Cocoa. We have had the discussion about drag and drop vs. installers before, so let's avoid that. My question is about why we install anything locally at all? For years, I used a lab full of NeXTstep and Openstep machines that all NFS mounted a Sun file server. The applications were placed (I don't want to say installed) on the Sun server. From any particular computer in the lab, I would just double click on someapplication.app in the /LabApps folder, and the application would start up an run. It didn't matter if I sat at an Intel, 68K, or SPARC system due to the magic of fat binaries. The application was never on the local hard disk at all. If we wanted to deploy a new application, we just copied it to the Sun server and anyone who wanted it could double click. When we upgraded an application, we just copied the new version to the Sun server. There was no pushing of applications. Where did the fetish for installing every single application on the local hard disk come from ? Isn't it insane to have 35 installed copies of OmniGraffle using up disk space just because you have 35 licenses ? Why is MS Word on every disk instead of just the server? So, to keep this Cocoa specific, have there been any framework changes that impede running Cocoa applications from a read-only server mount ? Are preferences a problem? Are fonts an issue ? Is access to ~/Library/Application Support an issue ? I can't think of any reason running from a remote read only mount would be a problem, but I'm not in a position to try right now. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
I like the addition of Related Sample Code sections to Cocoa Docs.
I like the addition of Related Sample Code sections to the Cocoa reference Docs. Good work Apple. Keep it up. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: I like the addition of Related Sample Code sections to Cocoa Docs.
I just used the feedback button at the bottom of every Cocoa document page to tell Apple that I like the addition of the Related Sample Code sections. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to force a message to a overriding method from within an init method
Calling a subclass's overridden implementation of a superclass member function from within the super class constructor is very very dangerous in C++. I don't believe if is even supported by the ANSI/ ISO standard, and to the extent it works at all, it is probably compiler and linker dependent. I could be wrong of course. This may be one of the more obscure border cases in the world's most complex language. In Objective-C, the subclass's override of the base class method will be be called polymorphicly because there is no such thing as a constructor in Objective-C. Methods like +alloc and -init are just regular methods. #import Foundation/Foundation.h @interface Base : NSObject { } - (void)printName; @end @implementation Base - (id)init { self = [super init]; [self printName]; return self; } - (void)printName { printf(I am the base class implementation.\n); } @end @interface Subclass : Base { } @end @implementation Subclass - (void)printName { printf(I am the subclass implementation.\n); } @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; Subclass *sample = [[Subclass alloc] init]; [sample release]; [pool drain]; return 0; } Output will be [Session started at 2009-02-11 21:27:00 -0500.] I am the subclass implementation. The Debugger has exited with status 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 arch...@mail-archive.com
Re: NSTextField - dynamic resizing while editing
The Sketch.app example on your hard disk may provide guidance. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Sliding Split Views, part II
As I recall, this sample code does exactly what you want: http://developer.apple.com/samplecode/Reducer/ I haven't looked at it for a while, so I may be mistaken. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSScroller buttons not scrolling?
One possibility that answers the following question which is similar to yours: When I drag the scroll bar, the view scrolls appropriately. When I click in the empty space beside the scroll bar, the view scrolls appropriately. When I click on the scroll arrows, they highlight, but the view does NOT scroll. http://www.cocoabuilder.com/archive/message/cocoa/2007/8/28/188423 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Cocoa and the need for a dynamic language
In this forum, Scott Ribe recently wrote ...but just as you can't rewrite Cocoa in C++ as we've seen demanded by people who don't really understand Objective-C... I claim that a relatively dynamic language is necessary to effectively use Cocoa. I also claim to have very deep and thorough understanding of Objective-C and several variations of its run-time. As with all Turing Complete languages, it is certainly possible to create a message dispatching system similar to Objective-C's objc_msgSend() using C++. In fact, objc_msgSend() and related functions are C functions that compile without modification as C++. Obviously, there is nothing that can be done in C++ that can't be done in C. There is nothing that can be done in C++ that can't be done in Objective-C. There is nothing that can be done in either Objective-C or C that can't be done in C++. Should we declare the languages all equally suited to solving any particular problem? I don't think so. Direct language support for various programming paradigms is usually an advantage over cobbled together solutions or hacks - at least when those paradigms are germane. I write a lot of high performance numerical code for high performance computing systems. Among other things, I write real-time emulators for super-computers so that scientific applications can be easily migrated to new hardware, and sometimes a few nanoseconds matter. Most of my numerical code is written in old style C++ and primarily a C subset of C++. As far as I know, there is still no compiler in the world that completely implements the ANSI/ISO C++ standard which was ratified in 1998. If the standard hasn't been implemented in a decade, something is amiss. This is in spite of the fact that the standard has holes in it large enough to drive trucks through, but I digress. All that aside, modern C++ can be highly optimized by modern compilers. Templates and non-virtual function calls can be in-lined in many cases. Just in-lining removes function call overhead and is sometimes a major optimization. Then, once the code is in-lined, the compiler may detect additional opportunities for common code simplification, loop unrolling, and/or auto-vectorization. However, remember that templates are in most respects type-safe replacements for C macros. There is no magic happening. Both Objective-C message sending and C++ virtual function calls commonly prevent in-lining because the _compiler_ can not determine which code will actually be called. If you use Objective-C message sending or C++ virtual member functions, you forego most low level optimizations at the call sites. Of course, the implementations of the methods and member functions (respectively) can still be optimized. All possible C++ virtual member function implementations must be determined at link time to enable generation of code at call sites and/ or vtables. Determination of the code that will ultimately be executed as the result of Objective-C messages sends is postponed until run time. Postponing determination until run time is one of the key aspects of dynamism that enable Cocoa as we know it. Postponing until link time just doesn't postpone the decision long enough. Therefore, I take issue with Scott Ribe because I don't think Cocoa can be implemented as we know it in C++. COM, SOM, IDL, and other mechanisms have been added to C and C++ to selectively implement a solution that postpones determination of the receiver of a call until run time. Why were those mechanisms created ? Answer: someone perceived a need for them. I claim that using COM, SOM, IDL, etc. to retrofit dynamism into C++ is a poor solution to the problem. I would not want to use a Cocoa that was implemented using COM for all messaging. Would you ? In summary, I am a C++ guru who writes real live high performance numerical code, and I limit myself to a small subset of old style C+ + as a conscious decision. I write almost everything else in dynamic languages including Objective-C. Modern template meta- programming surely has utility or it wouldn't have been invented. However, it doesn't provide the kind of dynamism needed to implement Cocoa as we know it, and it isn't necessary for high performance computation. As another aside, I concede that _my decisions_ relegate modern C++ to a vanishingly small subset of all programming problems _I_ solve. Others will have different circumstances and experiences. I do perceive a similar phenomenon in the larger world: Modern C++ is being squeezed between C and languages like Python, Java, and C#. My perceptions may not reflect reality. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at
Re: NSTableView
The code provided looks very unusual and clearly does not follow the Model-View-Controller design. It is almost always a bad idea to store information in the user interface. The following line is extremely suspect: int count = _browserView-fileList.GetCount(); Why doesn't your tableView's data source have its own direct reference to fileList ? I suggest the following: - (int)numberOfRowsInTableView:(NSTableView *)tableView { int count = 0; if(_fileList != NULL) { count = _fileList.GetCount(); } return count; } What is going on with the following? [_browserView selectAll:self]; [_browserCells release]; _browserCells = [_browserView selectedCells]; [_browserCells retain]; Don't select stuff in - (int)numberOfRowsInTableView: Even if you wanted the cells from the matrix for some reason, why not [_browserCells release]; _browserCells = [[_browserView cells] copy]; But using the cells of a matrix outside the matrix is extremely suspect. The cells should not contain any information that you can't get from some other source like _fileList. The rest of teh code that copies information out of cells in a matrix in order to set information in cells used by a tableView is so horrific that I won't comment any more. Please read about Model-View-Controller. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Quartz Composer For Games?
http://www.quartzcompositions.com/phpBB2/upload/details.php?file=378 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSApp beginSheet:NSWindow notification of sheet opening?
Custom sheets don't spontaneously show themselves. Right before you send messages to display a sheet, reconfigure the sheet as desired. Better yet, add a method to the window controller for the sheet and implement that method to both do the special configuration and show the sheet on the specified window. Make all code that shows the sheet call through the method you added. Inside your window controller subclass: - (void)configureAndShowSpecialSheetOnWindow:(NSWindow *)aWindow { // do your configuration // show your sheet on aWindow } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem drawing outside of drawRect: in a custom table cell
You don't have to draw outside of -drawRect:. Instead of invalidating the table, just call -setNeedsDisplayInRect: or -displayInRect: and pass only the rect of the row that needs to be redrawn. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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 display simple dialog at application startup?
See http://www.stepwise.com/Articles/2006/eb1/index.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Live image preview, huge memory usage...
See http://theocacao.com/document.page/497 See http://www.wilshipley.com/blog/2005/09/jpeg2000-cool-but-slow.html See http://www.macresearch.org/cocoa-tutorial-image-kit-and-image-browser-views-part-i See http://www.macresearch.org/cocoa-tutorial-image-kit-cover-flow-and-quicklook-doing-things-we-shouldnt-are-too-fun-resist ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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 vector modeling query
I use Core Data to store large amounts of 3D vector data. I solved your problem in the following way: I have a Vector3D entity that you can think of as an end point in your model. My Vector3D entity has x,y,z attributes. I have a Vector3DReference entity. Vector3D has a to many relationship to Vector3DReference which has a to one relationship to Vector3D. I can ask any Vector3D for all of its references, and I can as a reference for its Vector3D. Vector3DReference is abstract. I have derived Vector3DReference for all of the cases where I have other entities with relationships to Vector3DReference. For example, I have a Billboard entity that has a to one relationship to BillboardAnchorVector3DReference which has a reciprocal to one relationship back to Billboard. It is common in 3D systems to have a large collection or database of points/vectors and then reference the points/vectors for index or ID. E.g. consider multiple triangles that all share a vertex. When the vertex changes, all of the triangles that share the vertex are updated. Sharing vertex data also reduces the storage required vs. lots of copies of the vertex. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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 vector modeling query
As another refinement, store all of your end points as an array of float. Store the array in NSData. Have an entity called EndPointStorage that has an NSData attribute, endpoints. The Vector3DReference entity can then have an integer attribute called endPointIndex. Use endPointIndex to lookup the end point in the EndPointStorage.endpoints. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)
If you write correct accessors for all outlets, then the retain/release memory management is entirely handled in one method. the -set retains the new value and releases the old value. Any confusion regarding memory management for IB outlets seems to stem from failure to write the accessors and reliance on syntactic sugar. Just remember that @property (nonatomic, retain) IBOutlet UILabel *label; results in synthesis of the appropriate accessor methods. It does nothing more than save you some typing and document your intention. The -set method that results from the above property declaration retains the new value and releases the old value. The memory management is therefore all handled in one place just the way it should be and the way you want. So what's the problem again ? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: OpenGL + NSTextView/NSTextContainer?
Open GL has no built-in capability for drawing text. Open GL provides lower level primitives like lines and curves and meshes. Open GL also provides texture compositing. There are some free and some open text drawing/font solutions for Open GL. You can use the GLUT library up to a point. On Mac OS X, the traditional way to mix Open GL and Cocoa text is by rentering the text into a texture and then using Open GL to composite the texture. The sample I think you want is http://developer.apple.com/samplecode/CocoaGL/index.html See other samples at http://developer.apple.com/samplecode/GraphicsImaging/idxOpenGL-date.html For modern Mac OS X, you might do what you want with layer backed views to use a Cocoa text view as an Open GL texture. See also CATextLayer http://developer.apple.com/samplecode/CALayerEssentials/index.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Enumerating outlets automatically?
See http://www.cocoabuilder.com/archive/message/cocoa/2002/6/16/69399 Just put an array in you nib. Connect all of the objects of interest to the array. In you controller code, use one outlet to the array. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: MVC
Blatant plug: See also http://safari.informit.com/9780321591210 Part I: One Pattern to Rule Them All Model View Controller Examples of MVC in Apple Frameworks Chapter 1. Model View Controller ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
What's the modern solution for sharing data between Cocoa to Windows
If you watch this video from 1995 and the particularly three subsequent parts of the video, you'll see that NeXT offered an interesting technology for seamless communication between Openstep/ Cocoa objects on the server and rich Windows clients running Excel and Visual Basic applications: http://www.youtube.com/watch?v=Hu-jvAWTZ9ofeature=related All of that is gone now. Apple chucked it all 10 years ago. What is the modern solution ? Suppose I have Excel running on a Windows machine and I want to grab data from Cocoa objects running on a remote Mac OS X server. How do I get the data out of the Cocoa objects and into Excel ? Suppose I succeed in getting the data out of a Cocoa application and I then I use the data to produce pie chart in Excel. Now, how do I get an image of that chart show to up on a web page produced by a web server running on Mac OS X ? I apologize in advance if the answers are obvious. I have little to no experience in the realm of web publishing, so I might not be asking the right questions ?I basically just want to do what Steve Jobs demoed in 1995. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: wasting space?
--- On Mon, 10/6/08, I. Savant [EMAIL PROTECTED] wrote: What of the Graphics Bindings example mmalc has on his examples page? Here: http://homepage.mac.com/mmalc/CocoaExamples/controllers.html I am not sure what Mmalc was attempting in his example. I looked at it again just now.It seems to me to be a very old example. He uses the deprecated method + (void)setKeys:(NSArray *)keys triggerChangeNotificationsForDependentKey:(NSString *)dependentKey.I think that NSArrayController can do everything his GraphicsArrayController is doing without requiring any application specific code.I think Mmacl's implementation of GraphicsView is sub-optimal unless I am just not understanding what he was trying to do.Chapter 29, Controllers, in the forthcoming Cocoa Design Patterns book coincidentally implements a simple drawing program. I wish I had thought to review Mmalc's example while I was writing.Chapter 29 takes the reader on a journey to discover why NSArrayController and other NSController classes exist. The chapter starts with a simple problem, solves it, and the evolves the solution to be general and reusable. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: wasting space?
I am very confused here. KVO has nothing to do with a call like valueForKeyPath:, other than the obvious fact that they are both built on the idea of key paths. The observeValueForKeyPath:ofObject:change:context: method doesn't interact with valueForKeyPath: in any way, and so I don't really understand what you're getting at here. If you don't override observeValueForKeyPath:ofObject:change:context:, how are you supposed to use KVO at all? As far as I understand it, that is the *only* way to get notified of changes to things you observe. Apple's various NSController subclasses handle KVO and bindings for you. NSController subclasses automatically call -valueForKeyPath: or -valueForKey: or -setValue:forKey:. The -observeValueForKeyPath:ofObject:change:context: _does_ interact with -valueForKeyPath: because the various NSController subclasses exist in part to provide exactly that interaction. You do often need to call -bind:toObject:withKeyPath:options:. You really don't need to override -observeValueForKeyPath:ofObject:change:context:. Or at least I haven't needed to override it because one of the existing NSController subclasses usually meets my needs. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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 track Slider's value while dragging the mouse?
- setContinuous: setContinuous: Sets whether the receiver’s cell sends its action message continuously to its target during mouse tracking. - (void)setContinuous:(BOOL)flag Parameters flag YES if the action message should be sent continuously; otherwise, NO. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Validating MenuItems before adding them to the menu
See the - (id)targetForAction:(SEL)aSelector method. When adding context menu items, if the target for the menu item's action would be nil, just don't add the menu item. However, I recommend adding all menu items that are ever available and just disabling the ones that aren't currently available. Doing that will preserve user's muscle memories about where each item is in the list. Plus, it will let users know what items are sometimes available even if they are not currently available. For more options, see targetForAction:to:from: Finds an object that can receive the message specified by the given selector. - (id)targetForAction:(SEL)anAction to:(id)aTarget from:(id)sender Discussion If anAction is NULL, nil is returned. If aTarget is nil, NSApp looks for an object that can respond to the message—that is, an object that implements a method matching anAction. If aTarget is not nil, aTarget is returned. The search begins with the first responder of the key window. If the first responder does not handle the message, it tries the first responder’s next responder and continues following next responder links up the responder chain. If none of the objects in the key window’s responder chain can handle the message, NSApp asks the key window’s delegate whether it can handle the message. If the delegate cannot handle the message and the main window is different from the key window, NSApp begins searching again with the first responder in the main window. If objects in the main window cannot handle the message, NSApp tries the main window’s delegate. If it cannot handle the message, NSApp asks itself. If NSApp doesn’t handle the message, it asks the application delegate. If there is no object capable of handling the message, nil is returned. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Naming alert panel buttons.
We have all seen the ubiquitous OK Cancel buttons. Many people have recommended more descriptive names that include verbs for button labels. I just ran across a Cocoa application that shall remain nameless. I attempted to cancel a long running operation by pressing a Cancel button, and an alert panel appeared asking if I wanted to OK or Cancel. I correctly interpreted that as do I want to OK the cancel or do I want to cancel the cancel. It did boggle my mind a little. I bring this up because I ran across another application today that took the advice of using more informative verbs for button labels. I tried to cancel an operation, and a panel appeared. The two choices were Cancel and Cancel. I assume they meant cancel the operation or cancel the cancel. The mind boggles. To make this more Cocoa related, is it worthwhile to add a feature to AppKit so that you can't have two buttons with the same label on one panel ? Is there some other way that Cocoa or the tools can help application developers avoid silly errors ? The layout guides in IB helped a lot to standardize layout. Is there a way to standardize other aspects of user interface presentation ? Is this something better left to individual developers and used as an indicator of overall application quality ? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Programmatically inserting text into NSTextView and scrolling
To add to the answer: http://www.cocoabuilder.com/archive/message/cocoa/2005/9/30/147205 It's also worth noting that a search of the archives reveals literally 100 answers to this and similar questions. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Design Question: Bindings Custom Views
Cocoa Design Patterns Chapter 29, Controllers, contains an MVC solution to exactly the problem Oleg Krupnov describes. The chapter presents a relatively simple MVC MYShapeDraw application. The chapter leads the reader through the step by step process of re-inventing NSArrayController as part of the MYShapeDraw application. The goal is to highlight the rationale and use pattern for array controller and other controllers. One of the reasons to use an array controller as a mediator between model objects and views is precisely so that it's easy to have multiple different views and potentially different models. Therefore, the application provides multiple views. The example even discusses sharing selection information by multiple views or letting each view have a different notion of the current selection. The application also uses the Associative Storage pattern from chapter 19 to enable any view to store whatever extra information it wants along with model objects. Categories are used to separate view related code from the model code. Apple uses this approach in several places to add view layer capabilities to model layer objects. See NSString and NSStringAdditions. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Design Question: Bindings Custom Views
Sorry. When I posted about the problem Oleg Krupnov describes, I wasn't caught up on my reading of the list. The VC MYShapeDraw application I describe is a drawing application and not related to image thumbnail caching. Of course, the pattern is general and applicable to image thumbnail caching. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Design Question: Pro Cons of KVC/KVO
On Aug 21, 2008, at 7:12 PM, Ken Thomases wrote: I have some quibbles... On Aug 21, 2008, at 12:54 PM, Erik Buck wrote: So, in summary, the whole point of KVC is to standardize the way an object’s properties are accessed regardless of how they are stored. Well, the real point, to my mind, is to increase the dynamism of property access. It's to allow properties to be accessed using data to select the property rather than code. Data that is determined at runtime or design time (IB). I agree. Cocoa Design Patterns includes an entire chapter about the Associative Storage design pattern, and the whole point of the pattern is to provide dynamism that allows determination at runtime. I perhaps over simplified out of a desire to avoid pasting the whole Associative Storge pattern into the essay. KVC also provides support (hooks) for change management so that any change to a property can have application defined side effects like registering an undo event or validating the change. Hooks other than the accessors it might invoke? I'm not aware of that. In order to make your classes KVC compliant, you must either write the appropriate accessors or override the valueForKey: and related methods. The hooks in fact are the accessor methods or the valueForKey: type methods. KVO Key Value Observing takes advantage of the change management hooks provided by Key Value Coding in order to notify other interested objects whenever an observed property changes. Again, I don't think KVO takes advantage of existing hooks. It adds those hooks by generating subclasses dynamically and isa-swizzling. Unless and until you add a KVO observer to an object, it doesn't have any hooks. The hooks are just the accessor methods or KVC compliance methods. They exist for every KVC compliant class. However, you can use KVO with a class that is not totally KVC compliant if you call the appropriate willChangeValueForKey: and didChangeValueForKey: methods. Obviously it works best with KVC compliant classes. OK - I'll concede that KVO should only be used with KVC compliant classes. The last time I described all this in email, I was shot down for even bringing up the isa-swizzling becaust that's an obscure implementation detail... KVO is also the basis of “Bindings”. I would go so far as to say “Bindings” are just a way to specify which objects observe which properties in which other objects using Interface Builder instead of writing code to register all those notification observers. Bindings do more than merely set up KVO observations. The classes which support bindings also determine what to do when changes are observed. That's a detail. The essay was intentionally kept to the main points. I wanted to focus on the notification aspect because that's whate the original poster was trying to re-implement. Although KVO is “built upon KVC”, KVO really only needs change notifications. So, if you provide the change notifications, KVO will work even if you don’t really use KVC. I don't think that's true. KVO relies on KVC. How else can a KVO change notification include the old or new value? KVO will perform a KVC query for will/didChange... messages (including the implicit, automatic invocations of will/didChange... performed in the hooks it installs). OK OK - I'll concede that KVO should only be used with KVC compliant classes. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Does NSNotificationCenter have zeroing weak references to observers ?
Does NSNotificationCenter use zeroing weak references to observers ? I want to say When using Cocoa’s automated memory garbage collection, NSNotificationCenter automatically un-registers observers that are no longer in use somewhere else in the application. I'm just not sure it's true. Can anyone save me the time of writing a test application? In my test program, how can I tell the difference between an observer for which the NSNotificationCenter has a strong reference and an observer that is about to be finalized but hasn't been yet ? Is this the classic halting problem? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Challenge 18 in Hillegass Book
But the question I think is still valid and one I'm I'm trying to figure out myself. How, for instance, would you have the view request data from the document (or any other object for that matter). I understand that it may not always be the best design choices but how is it done? Posting notifications is about the only way I can think of and perhaps sending self as the context info. Ashley Perrien How would you have a view request data from the documet ? - You could use a Data Source like NSTableView and let the document instance be the Data Source (connected via File's Owner). - You could use NSViewController instances like NSCollectionView and give each NSViewController a pointer to a document. - You could send a message up the responder chain on the usually valid assumption that the right document instance will be in the responder chain. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Bindings to display an NSArray of NSStrings as a single NSString?
You could add a category to NSArray... @implementation NSArray (ArrayOfStringsAsSingleString) - (NSString *)arrayOfStringsAsSingleString { return [self componentsJoinedByString:@, ]; } @end ...and then bind to values.arrayOfStringsAsSingleString. Um, why not just bind to values.description the -description method of NSArray will return a string containing comma separated descriptions of the contained objects. It will even work if the contained objects aren't all strings. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: guidelines/tutorial for implementing custom controls
Can anybody point me to some good tutorials/guides for implementing custom controls? Do you have some objection to the examples at developer.apple.com ? http://developer.apple.com/samplecode/Clock_Control/index.html http://developer.apple.com/samplecode/TrackBall/ http://developer.apple.com/samplecode/bMoviePalette/index.html There are some fun third party samples: http://www.sticksoftware.com/software/CircularSlider.html http://developer.snowmintcs.com/controls/smdoubleslider/index.html http://www.stepwise.com/Articles/Technical/NSCell.html See also Omni Group http://www.omnigroup.com/developer/ There are some custom controls in the DrawDemo for DrawKit http://apptree.net/drawkit.htm I've been reading the Cocoa Event Handling Guide, The reference and accompanying conceptual guides for NSControl, NSCell, NSActionCell and NSView, but I'm more confused than when I started. Odd. Those are relevant documents. If anyone could answer these more specific questions or point me to good reference material I'd really appreciate it: 1. How does one setup the target/action mechanism for a custom control, i.e. client code can call setAction: and setTarget: and have these stored in the class? Does this come for free when you subclass NSActionCell? Or is it more correct to implement these methods yourself, in an NSView subclass? Or NSControl subclass? Subclasses of NSControl already have target/action support and can be connected via Interface Builder. You can also use NSActionCell without NSControl but won't automatically get Interface Builder interaction. Target action is also easy to implement on your own via NSApplication's - (BOOL)sendAction:(SEL)anAction to:(id)aTarget from: (id)sender method. 2. Is wrapping existing controls in a custom control class a good idea? I.e. the custom control class is a container for a handful of standard controls, configures them in an appropriate way, and presents an interface to client code as if it were a single control, i.e. a target-action mechanism, and public properties for querying the state of the control? I guess that would work. Why would you want to do that ? My (current) higher level goal is implementing a control that includes 3 momentary buttons, the middle button showing a menu when pressed. These buttons all edit one piece of data, a ratio. This control needs to be invoked (i.e. added to parent view) from code and be reusable. The client code needs to be informed when a button is clicked and be able to query the control's current value. The new control is responsible for the appearance, and the contents of the menu. In future I will also need to implement more complex custom controls/ views, that include custom drawing and a handful of subcontrols (that are all related and present a unified interface to client code). I don't think you need a custom control to meet any of your goals. Just embed your buttons etc. in a convenient parent view and provide suitable Controller logic (ref: Model View Controller). You can save your embedded views in their own interface builder nib file for reuse or even add your pre-configured group of objects to Interface Builder's library. See Adding Modified Objects Back to the Library In Interface Builder's help. You will need to subclass NSView or one of its existing subclasses when you want custom drawing unless you use CALayer's instead. I've noticed that NSSegmentedControl can implement pretty much all of the control, so I think I want to use that internally, implementing all the config for the segmented control, and mapping the actions of the individual buttons to set the data in the control and invoke the custom action (that the client code, the target receives). Is there a way to achieve this? Am I barking up the wrong tree? I think what you are suggesting is workable. Have you tried 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: private methods and variables
@implementation MyClass int privateVariable; // this is an instance variable @end and int privateVariable; // this is a global variable @implementation MyClass @end ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: private methods and variables
On Jul 29, 2008, at 7:19 PM, Erik Buck wrote: @implementation MyClass int privateVariable; // this is an instance variable @end and int privateVariable; // this is a global variable @implementation MyClass @end Never mind. both declarations above are global variables. @interface MyClass : NSObject { int privateVariable; // this is an instance variable } @end and extern int privateVariable; // this is a global variable @interface MyClass : NSObject { } @end ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Repositioning a content view w/in a window
Is something like this a decent Cocoa approach: // create the window myWindow = [[NSWindow alloc] initWithContentRect: ... ]; // insert the existing matrix as it's content view [myWindow setContentView:myMatrix]; // alter the position of the matrix NSPoint newPoint = ... [myMatrix setFrameOrigin:newPoint]; [myWindow display]; No. You want // create the window myWindow = [[NSWindow alloc] initWithContentRect: ... ]; // insert the existing matrix as it's content view //* See here! [[myWindow contentView] addSubview:myMatrix]; // alter the position of the matrix NSPoint newPoint = ... [myMatrix setFrameOrigin:newPoint]; [myWindow display]; A window's content view always fills the whole content area. Therefore, moving it around makes no sense. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Sent Actions, Delegates, Outlets
Warning: Blatant self serving plug: Target/Action, Delegates, and Notifications are all software design patterns. They aren't even unique to Cocoa, but Cocoa has particularly elegant implementations. You can read/review all about these patterns and more including analysis of the motivations for using them, pros and cons, examples of their usage in Cocoa, and sometimes examples of how to re-implement them from scratch. See http://safari.informit.com/9780321591210 I had previously assumed that readers wouldn't care how to re-implement most patterns from scratch because Cocoa already provides reusable implementations. There is no reason to re-implement them. However, I have been receiving feedback from reviewers that they like the sample re-implementations. They tell me that seeing code helps them understand even though the code samples I provide are not the same as the code within Cocoa. If you don't want to spend any money, Apple's own documentation describes some of the Cocoa design patterns. A specific comparison of Delegates vs. Notifications is available at http://www.stepwise.com/Articles/Technical/2000-03-03.01.html A simple Google search is always illuminating: http://www.google.com/search?hl=enq=cocoa+delegate For people who know .Net, there is this nice article among others: http://dotnet.sys-con.com/read/375743.htm ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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 question: How does NSScrollView know the size of the thing it's scrolling?
As is the case with all NSViews, the frame of the view defines the area occupied by the view in its superview's coordinate system. The bounds of a view defines that view's own coordinate system irrespective of the frame. Therefore, if the frame size and bounds size for a particular view are different, that implies a scaling of the view's coordinate system. If the frame and bounds origins are different, that implies a translation of the view's coordinate system. Of course, a view can also use an arbitrary affine transform matrix to implement rotation, scale, translation, and skew to almost any extent. In the case of a scrollview, the sliders are positioned and sized based on the frame of the enclosed clipview relative to the bounds of the scrollview. The clipview automatically increases its own frame to completely enclose the frame of the document view. You can do anything you want to the bounds of the document view without any effect on the clipview EXCEPT for the small fact that by default, setting the bounds of a view also resets the frame. I don't know why; that's probably convenient in some cases. I sometimes do the following to circumvent that: NSRectoldFrame = [self frame]; [self setBounds:someRect]; // set a different bounds [self setFrame:oldFrame]; // restore old frame so bounds and frame have different size See http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/Coordinates/chapter_3_section_3.html#//apple_ref/doc/uid/TP40002978-CH10-SW9 http://developer.apple.com/documentation/Cocoa/Conceptual/NSScrollViewGuide/Articles/Introduction.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: drawRect infinite loop -- argh!
See a break point in drawRect: and then tell us why it is being called. Seriously, do you have some philosophical objection to using the debugger ? Isn't this what it's for ? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: Inverse Regex Library?
You ask an interesting computer science question (that's unrelated to Cocoa). Surely the following sequence of words would produce Word[1-9]{1,2} instead of Word[0-9]{1,2} because there is no representative 0 in the sample ? Word1 Word2 Word5 Word8 Word11 Word19 Word23 Word45 Word77 Anyway, I think this is an unsolvable problem, and I might start with an attempted proof of its unsolvability rather than a solution. Lots of artificial intelligence and/or statistical pattern recognition could be applied to achieve reasonable results in general cases. If you have specific cases like letters followed by numbers you might use a lexer and parser like flex/bison. Have you considered a perfect hash ? What are you really trying to achieve ? http://en.wikipedia.org/wiki/Perfect_hash_function http://www.nist.gov/dads/HTML/minimalPerfectHash.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: how to add modal dialog once application begin to run
Have a look at http://www.stepwise.com/Articles/2006/eb1/index.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: hitTest question
You are off to a good start by trying to mimic something as well conceived and implemented as Cocoa's -hitTest: approach. Now, because you want to re-invent the solution, you will need to know a lot of details about graphics programming and associated mathematics. Determining whether a 2D point is inside a co-planar 2D rectangle is easy. I will leave that up to you. Transforming a 2D point from one 2D coordinate system to another is trivial if you have a proper grounding in graphics programming including affine transform matrixes and associated math. I will simply direct you to google with the terms coordinate system transformation A standard and popular text book is Computer Graphics: Principles and Practice in C (2nd Edition) by James D. Foley (Author), Andries van Dam (Author), Steven K. Feiner (Author), John F. Hughes (Author). Hint: Bounding rectangles aren't rotated. Coordinate systems are rotated. Transform your hit point into the correct coordinate system and then use the standard rectangle contains point test. So, now you know whether your 2D point is within a 2D rectangle that might be in a rotated, scaled, skewed, or transformed coordinate system (e.g. affine transforms). That gives you the NSView base class like implementation of -hitTest:. You might want to determine whether the 2D point hits an opaque portion of a 2D drawing. I will leave that as an exercise but caution that it can be quite difficult and actually hasn't been completely solved in a general way other than via rasterization which you will want to avoid in openGL. Now, since you are using openGL, you might want to test 3D point intersection with 3D volumes. OpenGL provides a picking solution that might meet your needs. Other than that, you are going to have to investigate general collision detection algorithms which are fortunately a highly researched area of computer science. Start with wikipedia for that: http://en.wikipedia.org/wiki/Collision_detection ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: ObjectController and ArrayController tutorials
Ashley, As it happens, I have written a chapter in Cocoa Design Patterns about why NSArrayController and friends exist and how to use them. I am interested in feedback on the chapter. Contact me privately if you want to see if we can arrange some way for you to review the chapter. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.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: adding a delegate to a class
See http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: using Undo with portable C++ data model
There are many pure C++ applications in the world that implement undo. You don't have to use the Cocoa undo at all if portability is important. Implement undo in C++ using the Command pattern or whatever technique you want. Then integrate Cocoa GUI support via menu items etc. for invoking the C++ undo. I realize the Cocoa provides snazzy undo/redo support that is difficult to mimic cleanly in C++. That's one reason many people like Objective-C and Cocoa. The other alternative is to write your portable code in portable Objective-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/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]