Amount of Arguments per Method
clearly simplicity is important, but i'd like to know if there is a limit for the amount of arguments which a method can handle? also, just for fun, what's the longest method name you've seen? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Customize the NSMenu appearances
Does anybody know how to customize the NSMenu appearances, for example, its transparency, background color or foreground color. I want to customize the menu appearances popped up in the HUD panel. Satoshi ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Amount of Arguments per Method
clearly simplicity is important, but i'd like to know if there is a limit for the amount of arguments which a method can handle? The C99 standard states that conforming compilers must support at least 127 function arguments. I don't know if GCC enforces a limit above this, but if it doesn't, then the maximum number of arguments is only limited by the available stack space at run time. I assume Objective-C would support the same functionality, but I'm sure someone will correct me if I'm wrong. (Note that Obj-C uses two hidden arguments when sending messages: self and _cmd. So in the case that GCC supports the bare minimum of 127 function arguments, when sending messages with Objective-C, you'd only be able to use 125. In practice though, I think we all have a better chance of winning the lottery, getting struck by lightning, and contracting swine flu all in the same night, than creating a genuinely useful function that takes 128 arguments.) also, just for fun, what's the longest method name you've seen? Probably my own; I'm relentless when it comes to clarity in method, class and variables names. I've got a class name that's 55 characters, a category (filename) that's 51, and a variable name that's (drumroll) 63 characters. Of course, it's arguable that after a certain length, it's counterproductive. I think I'm just crazy... David ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Amount of Arguments per Method
On Jun 22, 2009, at 8:05 AM, Chunk 1978 wrote: clearly simplicity is important, but i'd like to know if there is a limit for the amount of arguments which a method can handle? I don't know if there's an upper limit, but I don't recall ever writing a method with more than 5 or 6 arguments. When I feel inclined to do otherwise, it typically means that there's a flaw in my design. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Amount of Arguments per Method
This still the longest one or has Apple outdone themselves since? 11 args, you really wouldn't want much more than this. -(id)initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel: WT wrote: On Jun 22, 2009, at 8:05 AM, Chunk 1978 wrote: clearly simplicity is important, but i'd like to know if there is a limit for the amount of arguments which a method can handle? I don't know if there's an upper limit, but I don't recall ever writing a method with more than 5 or 6 arguments. When I feel inclined to do otherwise, it typically means that there's a flaw in my design. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Approaches for this Matching Problem?
Ken Jerry; Thanks for the quick response! So I've been pondering and testing... 1) Why would I have to bust up/loop on thePhrase? This makes me face Jerry's issue of a universal solution for breaking on words. Just on general principal what would that solution be? [thePhrase componentsSeparatedByString:@ ] sure is easy, fast and effective for most of the folks who are going to pay for indie software But what is the right solution?? Seems like a common enough problem that there should be a well- defined, easily obtained, well-documented answer BUT in my case I don't care where, what word or how often - I just want to know IF a tag occurs in thePhrase!! thePhrase = 8 words theTags = 150 words the code below: 0.001 sec on 2Ghz MacBook -- Yeeoowssah! -- added benefits beyond spec -easy code to understand - not prone to error -Search and Comparison options allow for easily implemented flexibility - case-sensitivity; anchored, etc.. - (BOOL) containsTag:(NSString *)thePhrase { BOOL tagFound = NO; NSString *tag; NSEnumerator *tagEnum = [tags objectEnumerator]; //tags is an NSSet instance variable built from Core Data while ((tag=[tagEnum nextObject])!=nil) { if ([thePhrase rangeOfString:tag options:NSCaseInsensitiveSearch].location!=NSNotFound) { tagFound = YES; break; } } return tagFound; } Thanks for making life good! Steve ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Approaches for this Matching Problem?
Hi Steve, On Mon, Jun 22, 2009 at 6:10 PM, Steve Croninsteve_cro...@mac.com wrote: But what is the right solution?? For finding word boundaries, I think you're supposed to use NSAttributedString's nextWordFromIndex:forward: and doubleClickAtIndex: methods. Bear in mind that some languages don't really have the concept of words. Regards, Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to fill rectangle under vertical scroller?
Hi Quincey, On Mon, Jun 22, 2009 at 2:33 PM, Quincey Morrisquinceymor...@earthlink.net wrote: FWIW, the small gotcha in the sample code you linked to (AFAICT, since I never tried it) is that it places the placard in the area normally occupied by a scroll bar. The corner rect that the OP wants to draw is slightly different, in that the NSScrollView deliberately draws white in that corner, unless it's set to not draw a background at all. That means the linked-to code may not be quite complete -- it may also be necessary to ensure that the custom corner view draws above and/or after the scroll view, or else it may get painted over. Subviews are always drawn after the parent (for obvious reasons if you think about it), so if I correctly understand the point you're trying to make, there won't be a problem. Regards, Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Search field in ABPeoplePickerView.
Hi all, In my application, i m using ABPeoplePickerView on NSPanel to show the addresses. It is showing the addresses properly. But search field works properly if i show the panel at launch. If i launch the panel later on clicking on some button search field is not working. I also used the [MyPanel setWorksWhenModal:YES] to make the panel working when modal is running but no effect on search field. Do anyone faced the same issue. Please help me. 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Text Track to Subtitle Track
Hi, Anybody know how to convert a text track to subtitle track. i have doubt in how to read samples from a text track and add it in a subtitle track??? Thanks in Advance Sandeep ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
CIFilter
I can apply filter effects to all the selected graphics and is working as expected when I'm changing its values by using sliders and text fields. When I'm re-selecting the graphics after applying some filter effects,I'm not able to set this graphics as default (by setting the filters default values in the Mouse Down event). What is happening is : the graphics is retaining to the previous position (position before applying the filter) and also the user controls moves to the defaults. How will I accomplish this ? Thanking you in advance Mahaboob. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Amount of Arguments per Method
With that many arguments, i'd make a dictionary and pass only that dictionary. I understand your choice for not doing so however. jack On Jun 22, 2009, at 4:03 AM, Roland King wrote: This still the longest one or has Apple outdone themselves since? 11 args, you really wouldn't want much more than this. - (id )initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel : WT wrote: On Jun 22, 2009, at 8:05 AM, Chunk 1978 wrote: clearly simplicity is important, but i'd like to know if there is a limit for the amount of arguments which a method can handle? I don't know if there's an upper limit, but I don't recall ever writing a method with more than 5 or 6 arguments. When I feel inclined to do otherwise, it typically means that there's a flaw in my design. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/intrntmn%40aol.com This email sent to intrn...@aol.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
Re: Amount of Arguments per Method
That one's not mine, that's Apple's. The original poster asked what the longest one was, that's the longest Cocoa one I've come across. I didn't use it! On Jun 22, 2009, at 7:10 PM, Jack Carbaugh wrote: With that many arguments, i'd make a dictionary and pass only that dictionary. I understand your choice for not doing so however. jack On Jun 22, 2009, at 4:03 AM, Roland King wrote: This still the longest one or has Apple outdone themselves since? 11 args, you really wouldn't want much more than this. - (id )initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel : WT wrote: On Jun 22, 2009, at 8:05 AM, Chunk 1978 wrote: clearly simplicity is important, but i'd like to know if there is a limit for the amount of arguments which a method can handle? I don't know if there's an upper limit, but I don't recall ever writing a method with more than 5 or 6 arguments. When I feel inclined to do otherwise, it typically means that there's a flaw in my design. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/intrntmn%40aol.com This email sent to intrn...@aol.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/rols%40rols.org This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Approaches for this Matching Problem?
On Jun 22, 2009, at 10:10 AM, Steve Cronin wrote: BUT in my case I don't care where, what word or how often - I just want to know IF a tag occurs in thePhrase!! thePhrase = 8 words theTags = 150 words It seems that you have two sets (in the mathematical sense) and all you want to know is if their intersection is non-empty. Easiest solution: create two NSSet objects and use Apple's optimized implementation of set intersection: BOOL tagAppearsInPhrase = [tagSet intersectsSet: phraseSet]; Anything you do otherwise will likely not be as fast. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Warnings suggest compiler confusion between 32 and 64 bit code.
Hi all, In a custom view I have the following code (simplified for the purpose of this post): - (void)drawRect:(NSRect)rect { // Drawing code here. NSRect bounds = [ self bounds ]; NSLog( @size of CGFloat %d, float %d, double %d, literal float %d, literal %d, long literal %d, sizeof( CGFloat ), sizeof( float ), sizeof( double ), sizeof( 0.0f ), sizeof( 0.0 ), sizeof( 0.0L )); CGFloat x = bounds.origin.x; CGFloat y = bounds.origin.y; CGFloat c = 0.0L; / BATCH 3 **/ [[ NSColor colorWithDeviceRed: c green: c blue: c alpha: 0.33L ] setFill ]; /** BATCH 1 **/ NSRect area = NSMakeRect( x, y, x, y ); / ** BATCH 2 **/ } The code works as expected but I get the following warnings: The line at BATCH 1: warning: passing argument 1 of 'colorWithDeviceRed:green:blue:alpha:' as 'float' rather than 'double' due to prototype warning: passing argument 2 of 'colorWithDeviceRed:green:blue:alpha:' as 'float' rather than 'double' due to prototype warning: passing argument 3 of 'colorWithDeviceRed:green:blue:alpha:' as 'float' rather than 'double' due to prototype warning: passing argument 4 of 'colorWithDeviceRed:green:blue:alpha:' as 'float' rather than 'double' due to prototype The line at BATCH 2: warning: passing argument 1 of 'NSMakeRect' as 'float' rather than 'double' due to prototype warning: passing argument 2 of 'NSMakeRect' as 'float' rather than 'double' due to prototype warning: passing argument 3 of 'NSMakeRect' as 'float' rather than 'double' due to prototype warning: passing argument 4 of 'NSMakeRect' as 'float' rather than 'double' due to prototype The line at BATCH 3: (no warnings) Note that if I change the assign of c to just plain 0.0 (ie, no L) I get the following warnings: The line at BATCH 1: (as above) The line at BATCH 2: (as above) The line at BATCH 3: warning: implicit conversion shortens 64-bit value into a 32-bit value Note that the NSLog line logs this: size of CGFloat 4, float 4, double 8, literal float 4, literal 8, long literal 16 What's going on? NSLog shows that CGFloat is a float. GCC complains about storing an 8 byte floating point literal into a 4 byte floating point literal but is silent when storing a 16 byte floating point literal... weird. The prototypes of expect floats and I'm giving floats. So why the warnings? I vaguely recall that there's some old C rule that says all floats are passed as doubles (and all ints shorter than int are passed as int or something) but a) I'm not sure that applies in C99 b) GCC should be clever enough to not provide a warning in this instance c) It didn't in the past and I don't recall changing the GCC settings in my project - it's not something I've bothered with yet. Any ideas or suggestions? thanks, Brian ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Approaches for this Matching Problem?
On 22 Jun 2009, at 11:41, Chris Suter csu...@sutes.co.uk wrote: On Mon, Jun 22, 2009 at 6:10 PM, Steve Croninsteve_cro...@mac.com wrote: But what is the right solution?? For finding word boundaries, I think you're supposed to use NSAttributedString's nextWordFromIndex:forward: and doubleClickAtIndex: methods. There also is CFStringTokenizer which can do plain (non-attributed) NSStrings. Bear in mind that some languages don't really have the concept of words. Could you please elaborate? Maybe some examples? (There are many languages which do not seperate words by spaces - but languages without words: this is something new for me.) Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Text Track to Subtitle Track
Don't cross-post. Pick the most relevant list for your question and post only to that list. For this question, your first choice was correct: quicktime-api. -- I.S. On Monday, June 22, 2009, Sandeep Nair ac.sandeep.ad...@gmail.com wrote: Hi, Anybody know how to convert a text track to subtitle track. i have doubt in how to read samples from a text track and add it in a subtitle track??? Thanks in Advance Sandeep ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/idiotsavant2005%40gmail.com This email sent to idiotsavant2...@gmail.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
Re: Amount of Arguments per Method
On Jun 22, 2009, at 6:10 AM, Jack Carbaugh wrote: With that many arguments, i'd make a dictionary and pass only that dictionary. I understand your choice for not doing so however. Why? If you break up the call by hitting return after each argument and line up the colons (which Xcode will do automatically), it is about as clear as it can get. With a dictionary there is no validation during compilation that you have set up all of the parameters, you can't pass scalar values directly, and it adds all kinds of unnecessary additional dependencies (like memory management, if in non-GC). Still, I avoid such a monstrosity of a method when defining APIs. 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: Amount of Arguments per Method
On Jun 22, 2009, at 4:03 AM, Roland King wrote: This still the longest one or has Apple outdone themselves since? 11 args, you really wouldn't want much more than this. - (id )initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel : That's still the longest, both by name length (148) and number of arguments, if you look only at the most commonly used frameworks. However, as of Leopard, the longest *documented* method name (150, though with only 9 arguments) is [QCPlugInContext outputImageProviderFromBufferWithPixelFormat:pixelsWide:pixelsHigh:baseAddress:bytesPerRow:releaseCallback:releaseContext:colorSpace:shouldColorMatch :] http://developer.apple.com/documentation/Cocoa/Reference/QCPlugInContext_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/QCPlugInContext/outputImageProviderFromBufferWithPixelFormat:pixelsWide:pixelsHigh:baseAddress:bytesPerRow:releaseCallback:releaseContext:colorSpace:shouldColorMatch: . I also found two undocumented methods with 15 arguments, both in DOMMouseEvent: initMouseEvent:canBubble:cancelable:view:detail:screenX:screenY:clientX:clientY:ctrlKey:altKey:shiftKey:metaKey:button:relatedTarget : initMouseEvent::: On the iPhone [2], the longest by name (113), with 6 arguments, is [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero :] Until recently, the method with the most arguments (7) was [NSString drawAtPoint:forWidth:withFont:minFontSize:actualFontSize:lineBreakMode:baselineAdjustment :] In the 3.0 SDK there is now [NSMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error :] with 8 arguments. --Andy [1] Based on a search of: AddressBook, AirPort, AppKit, ApplicationServices, Automator, CalendarStore, Collaboration, CoreData, DiscRecording, DiscRecordingUI, ExceptionHandling, Foundation, InputMethodKit, InstantMessage, IOBluetooth, IOBluetoothUI, Message, OpenDirectory, PreferencePanes, PubSub, QTKit, Quartz, QuartzCore, ScreenSaver, ScriptingBridge, SecurityFoundation, SecurityInterface, ServerNotification, SyncServices, WebKit, XgridFoundation [2] Based on a search of: AddressBook, AddressBookUI, AudioToolbox, AudioUnit, AVFoundation, CFNetwork, CoreAudio, CoreData, CoreFoundation, CoreGraphics, CoreLocation, ExternalAccessory, Foundation, GameKit, MapKit, MediaPlayer, MessageUI, OpenGLES, QuartzCore, Security, StoreKit, SystemConfiguration, UIKit ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Warnings suggest compiler confusion between 32 and 64 bit code.
On Jun 22, 2009, at 5:09 AM, Brian Bruinewoud wrote: warning: passing argument 1 of 'colorWithDeviceRed:green:blue:alpha:' as 'float' rather than 'double' due to prototype Turn off -Wconversion, which isn't a very useful warning these days that everybody uses ANSI C. -- Dave Carrigan d...@rudedog.org Seattle, WA, USA PGP.sig Description: This is a digitally signed message part ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Opinion on managed memory and garbage collection
Being relatively new to Cocoa and Objective-C, what is the consensus on using the new version 2.0 managed memory features (garbage collection). If you were writing a new Cocoa application from scratch, would garbage collection be the preferred method over the reference counting (retain/release) method. Having spent years in Java I would prefer a GC'd approach but I have also seen the great improvement of GC in Java over the years. Therefore, I am also curious on how the new Objective- C design for GC compares. The applications I have in mind are mostly graphic (Quartz 2D) oriented and likely also some OpenGL work. Thanks for your opinions and comments. phil ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
number box class from NSTextField
Morning Cocoa-Dev, I need a scrolling number box type object for my GUI. At the moment I am subclassing NSTextField and overriding mouse and scroll wheel events so a user can drag the numeric value up/down. This seems a bit clumsy somehow. Perhaps a better idea would be a custom view that sits invisibly above an NSTextField taking mouse events and passing the numeric value to the text field via setFloatValue messages. Any comments? I'm sure a few people must have made something similar - I'm surprised there isn't a standard Cocoa object like this already. Thanks, Stephen ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Amount of Arguments per Method
On Jun 22, 2009, at 4:14 PM, Andy Lee wrote: On Jun 22, 2009, at 4:03 AM, Roland King wrote: This still the longest one or has Apple outdone themselves since? 11 args, you really wouldn't want much more than this. - (id )initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel : That's still the longest, both by name length (148) and number of arguments, if you look only at the most commonly used frameworks. However, as of Leopard, the longest *documented* method name (150, though with only 9 arguments) is snip This brings to mind a peeve of mine: Apple's unofficially sanctioned practice, followed by a lot of people, of NOT throwing in some white space in between parts of method names. Programmers spend most of their time *reading* code (their own or other people's), and with method names as verbose as those found in Cocoa, it seems to me that adding some white space ought to be a common practice. Alas... I mean, seriously, how easy is it to read - (id) outputImageProviderFromBufferWithPixelFormat:(NSString*)format pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height baseAddress: (const void*)baseAddress bytesPerRow:(NSUInteger)rowBytes releaseCallback:(QCPlugInBufferReleaseCallback)callback releaseContext: (void*)context colorSpace:(CGColorSpaceRef)colorSpace shouldColorMatch: (BOOL)colorMatch (copied directly from the documentation link Andy provided) compared to - (id) outputImageProviderFromBufferWithPixelFormat: (NSString*) format pixelsWide: (NSUInteger) width pixelsHigh: (NSUInteger) height baseAddress: (const void*) baseAddress bytesPerRow: (NSUInteger) rowBytes releaseCallback: (QCPlugInBufferReleaseCallback) callback releaseContext: (void*) context colorSpace: (CGColorSpaceRef) colorSpace shouldColorMatch: (BOOL) colorMatch I know that XCode will automatically pretty-print code for us, but I'm talking about Apple's documentation (and code-sharing in this list and elsewhere). It's not like pdfs or html pages kill trees, you know. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: number box class from NSTextField
On 23/06/2009, at 1:02 AM, Stephen Blinkhorn wrote: I need a scrolling number box type object for my GUI. At the moment I am subclassing NSTextField and overriding mouse and scroll wheel events so a user can drag the numeric value up/down. This seems a bit clumsy somehow. Perhaps a better idea would be a custom view that sits invisibly above an NSTextField taking mouse events and passing the numeric value to the text field via setFloatValue messages. Any comments? I'm sure a few people must have made something similar - I'm surprised there isn't a standard Cocoa object like this already. The standard way to handle this is to pair an ordinary text field with a stepper control (and maybe a slider, if you have space). The stepper allows the user to spin the value up or down while the text field allows them to type a value. I doubt that even if you get your field working properly, anyone will expect it to work the way you describe, and it will be very frustrating to have the value changing when they just tried to click and drag to select it. Very unusual UI widgets are not standard usually for very good reasons. --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: Opinion on managed memory and garbage collection
On Jun 22, 2009, at 4:58 PM, Phil Hystad wrote: Being relatively new to Cocoa and Objective-C, what is the consensus on using the new version 2.0 managed memory features (garbage collection). If you were writing a new Cocoa application from scratch, would garbage collection be the preferred method over the reference counting (retain/release) method. Having spent years in Java I would prefer a GC'd approach but I have also seen the great improvement of GC in Java over the years. Therefore, I am also curious on how the new Objective-C design for GC compares. The applications I have in mind are mostly graphic (Quartz 2D) oriented and likely also some OpenGL work. Thanks for your opinions and comments. phil Hi Phil, I've also lived in java-land for a long time, so I understand where you're coming from. I've since come to think that spending some time coding without gc has the great advantage that it forced me to be more attentive and careful in my coding practice. Ultimately, of course, it would be nice not to have to worry about memory management at such fine-grained level, but the lessons I learned by coding without the gc safety net will be with me when that day comes. Also, if you're programming for the iPhone OS, you have no choice at the time being because the iPhone OS does not support gc. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Amount of Arguments per Method
On 23/06/2009, at 1:03 AM, WT wrote: This brings to mind a peeve of mine: Apple's unofficially sanctioned practice, followed by a lot of people, of NOT throwing in some white space in between parts of method names. Programmers spend most of their time *reading* code (their own or other people's), and with method names as verbose as those found in Cocoa, it seems to me that adding some white space ought to be a common practice. Alas... I mean, seriously, how easy is it to read I totally agree with you. On a very similar note, I really dislike the fact that in headers (and source for that matter), the return type of a method is immediately followed by the start of the method name. It makes it very hard to visually separate the two and hence very easy to miss a method relevant to a given problem when hunting through the headers. In my own headers, I put whitespace between the return type and the start of the method name, and also line up the method names on a tab. It makes manually 'parsing' headers far easier, since I'm usually more interested in what the method does than the type it returns, at least on a first pass. e.g: - (BOOL)shouldAutoActivateWithEvent:(NSEvent*) event; - (BOOL)hitLayer:(NSPoint) p; - (DKDrawableObject*) hitTest:(NSPoint) p; - (void)mouseDown:(NSEvent*) event inView:(NSView*) view; - (void)mouseDragged:(NSEvent*) event inView:(NSView*) view; - (void)mouseUp:(NSEvent*) event inView:(NSView*) view; - (void)flagsChanged:(NSEvent*) event; - (NSView*) currentView; - (NSCursor*) cursor; - (NSRect) activeCursorRect; as opposed to: - (BOOL)shouldAutoActivateWithEvent:(NSEvent*)event; - (BOOL)hitLayer:(NSPoint)p; - (DKDrawableObject*)hitTest:(NSPoint)p; - (void)mouseDown:(NSEvent*) event inView:(NSView*)view; - (void)mouseDragged:(NSEvent*)event inView:(NSView*)view; - (void)mouseUp:(NSEvent*) event inView:(NSView*)view; - (void)flagsChanged:(NSEvent*)event; - (NSView*)currentView; - (NSCursor*)cursor; - (NSRect)activeCursorRect; --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: Warnings suggest compiler confusion between 32 and 64 bit code.
On Mon, Jun 22, 2009 at 5:09 AM, Brian Bruinewoudbr...@darknova.com wrote: CGFloat c = 0.0L; The compiler is silent here because it knows that 0.0L is finitely representable as a float (0.0). As for the other two occasions, you would need to compile with data flow analysis (which I believe is triggered by -O2 or higher) for the compiler to perform the constant folding necessary to see that you're storing a finitely-representable value. I would not recommend disabling -Wconversion. It is a great way to highlight places where your code is not 64-bit ready. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
FirstResponder in 10.4
I have a NIB with a NSView that I use to populate a Contextual View in the Main Window. I have tried to set the firstResponder from IB, from init, from awakeFromNib, and from - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor All of these work in 10.5 (+), but only that last works in 10.4. Unfortunately the side effect of the last is that if the user clicks on a different edit field and starts to type, the focus is on the firstResponder instead of the field the user just clicked on. I am sure I can continue to with this, but it seems like there must be a better way. It seems unlikely that 10.4 is this messed up and it will not correctly set the firstResponder. Any hints as to what I am missing? Rich Collyer ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Cocoa and Computational Expense
On Sat, 20 Jun 2009 16:36:58 -0700 (PDT), syntonica synton...@yahoo.com wrote: I am new to Cocoa (about 3 weeks now) and have not done much programming since the halcyon days of 16K RAM. WoW! a whole 16K!!! I remember paying $50 each in 1974 for surplus 1103's, the worlds first 1K dynamic RAM. (Yeah, I just dated myself…) How can I tell how computationally expensive a class or method is? I've never been this far from the metal. Is there a corpus somewhere listing this, or do programmers just know these things from their experience? SHARK (part of the CHUD tool set; search for it at http://developer.apple.com/search ). In the old days, we would cut corners and break rules to get better performance or memory usage. The idea of more meant thousands of dollars more. Now, resources for your average little application seem to be limitless. So, do I just walk the straight and narrow and let the Frameworks worry about these things for me? Yes and no. These days you're at the mercy of the Framework developers as to their performance but you do control your code and how it uses those frameworks. Ultimately what you want to do is (performance) profile your code and see where it's spending it's time. If it's spending it's time in our frameworks then perhaps you can figure out ways to avoid calling our frameworks as often as you are (caching?). If it's time spend in your code then there may be ways (improving your algorithms? Re-factoring?) to make your code run faster. Finally, on a side note and because this is my first OOP, just how big should a class get? Just as a rule of thumb. I have 700 lines and 50 methods in my MyDocument class and it seems positively bloated to me. Is this normal? Or might I possibly have a bad design? Pretty much, welcome to object programming… (IMHO the bad design isn't necessarily yours…) I only see a couple of lines that could be factored into their own method and nothing that could really me moved into its own class. I know these are rather vague questions with amorphous answers, but I am hoping somebody can shine some light or at least show me which door I need to go through. -- Enjoy, George Warner, Schizophrenic Optimization Scientist Apple Developer Technical Support (DTS) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: renaming executable files
On Sun, 21 Jun 2009 06:47:26 -0700 (PDT), Angelo Chen angelochen...@yahoo.com.hk wrote: I need to rename the executable file without renaming the project, how to do that? thanks http://developer.apple.com/qa/qa2008/qa1625.html -- Enjoy, George Warner, Schizophrenic Optimization Scientist Apple Developer Technical Support (DTS) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Approaches for this Matching Problem?
On Jun 22, 2009, at 3:10 AM, Steve Cronin wrote: So I've been pondering and testing... 1) Why would I have to bust up/loop on thePhrase? BUT in my case I don't care where, what word or how often - I just want to know IF a tag occurs in thePhrase!! Then you shouldn't refer to words. If you just care if any of a set of strings appear in a given string, that's a different question. If one of your tags is ham, do you want it to match a phrase containing shame? - (BOOL) containsTag:(NSString *)thePhrase { BOOL tagFound = NO; NSString *tag; NSEnumerator *tagEnum = [tags objectEnumerator]; //tags is an NSSet instance variable built from Core Data while ((tag=[tagEnum nextObject])!=nil) { if ([thePhrase rangeOfString:tag options:NSCaseInsensitiveSearch].location!=NSNotFound) { tagFound = YES; break; } } return tagFound; } If you can target Leopard or later, you can simplify this even more by using for (NSString* tag in tags) It's more efficient, too. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How do I sync Quartz drawing-path coordinates with the physical iPhone UIView coordinates?
Greetings: Here's my (common) problem: I want to be able to use Quartz to draw an open path across an CGImage layout based on the GGImage coordinates. I use the UITouch object/click via Simulator to collect my screen coordinates and hence, to plot a path for Quartz to draw: CGPoint myPoint = [touch locationInView:self]; However, these coordinates aren't the same as the Quartz path coordinates I need to actually draw a path: - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed:@dodgerStadium2.png]; CGFloat idealSize = 300.0f; CGFloat ratio = 1.0f; CGFloat heightRatio = idealSize / image.size.height; CGFloat widthRatio = idealSize / image.size.width; if(heightRatio widthRatio) { ratio = heightRatio; } else { ratio = widthRatio; } // use -10 as the y origin because we are flipping the coordinate system CGRect imageRect = CGRectMake(10.0f, -10.0f, image.size.width * ratio, image.size.height * ratio); CGMutablePathRef path = CGPathCreateMutable(); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextScaleCTM(ctx, 2.0f, -2.0f); // (context, x, y). // move down the height of the image CGContextTranslateCTM(ctx, -50.0f, -(image.size.height * ratio)); CGContextDrawImage(ctx, imageRect, image.CGImage); // --- // --- Prepping the Path parameters for Quartz to draw: CGContextSetLineWidth(ctx, 1.0f); CGContextBeginPath(ctx); // Note: Drawing coordinates (0,260) is upper left corner, (0,-200.0) lower left Corder. // (320.0, 260.0) upper Right Corner CGPathMoveToPoint(path, NULL, 0.00, -200.0f); // Via UITouch: x=0.00, y=459.00 CGPathAddLineToPoint(path, NULL, 159.00, 143.0f); // Via UITouch x=159.00, y=146.00 CGContextAddPath(ctx, path); CGContextDrawPath(ctx, kCGPathStroke); CGContextSetFillColorWithColor(ctx, [UIColor blueColor].CGColor); } Of course, the Quartz/UITouch coordinate sync changes with the scaling. So... How can I chart an accurate plot using the iPhone Simulator/Cursor upon an image for the Quartz drawing engine to follow? Regards, Ric. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: number box class from NSTextField
On 22 Jun 2009, at 09:11, Graham Cox wrote: The standard way to handle this is to pair an ordinary text field with a stepper control (and maybe a slider, if you have space). The stepper allows the user to spin the value up or down while the text field allows them to type a value. I'm using the stepper approach for now but neither me nor my users like it much. The slider idea could be useful but of course GUI space is at a premium which is one of the reasons I'm looking at alternatives. I doubt that even if you get your field working properly, anyone will expect it to work the way you describe, and it will be very frustrating to have the value changing when they just tried to click and drag to select it. Very unusual UI widgets are not standard usually for very good reasons. The click and drag number box is very much a standard in audio applications, for example, Apple's Logic Pro. Stephen ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Approaches for this Matching Problem?
Ken; Thanks as always for a thought-provoking and thorough response! 1) I haven't given up on those Tiger users yet... 2) I don't see how looping on the 'words' in thePhrase would change the 'ham' issue you raise - it would still match either on the word or the phrase. Am I missing something? 3) The actual tags in this particular context are extensive enough that this 'ham-confusion' is pretty unlikely and could be easily remedied by the user's management of the tag list... [e.g. service, management, institute] -- I know there remains the root forms issue but let's not drag that issue in here Steve On Jun 22, 2009, at 12:52 PM, Ken Thomases wrote: On Jun 22, 2009, at 3:10 AM, Steve Cronin wrote: So I've been pondering and testing... 1) Why would I have to bust up/loop on thePhrase? BUT in my case I don't care where, what word or how often - I just want to know IF a tag occurs in thePhrase!! Then you shouldn't refer to words. If you just care if any of a set of strings appear in a given string, that's a different question. If one of your tags is ham, do you want it to match a phrase containing shame? - (BOOL) containsTag:(NSString *)thePhrase { BOOL tagFound = NO; NSString *tag; NSEnumerator *tagEnum = [tags objectEnumerator]; //tags is an NSSet instance variable built from Core Data while ((tag=[tagEnum nextObject])!=nil) { if ([thePhrase rangeOfString:tag options:NSCaseInsensitiveSearch].location!=NSNotFound) { tagFound = YES; break; } } return tagFound; } If you can target Leopard or later, you can simplify this even more by using for (NSString* tag in tags) It's more efficient, too. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Class Factory Methods?
confused (seriously, what else is new?)... correct me if (where) i'm wrong: -=-=-=-=- -(void)myMethod { NSString *foo = [[NSString alloc] initWithFormat:@bar]; NSLog(foo); } -=-=-=-=- new, alloc, initWithFormat (or stringWithFormat) are class factory methods that are declared methods inherited by my custom classes, i guess somewhere in NSObject? so it write a stringWIthFormat class method, i guess to override it for the custome class it's written within: -=-=-=-=- + (NSString *)stringWithFormat { return @newBar; } -=-=-=-=- assuming both these methods are written in the same custom class, does that mean that my first method (void)myMethod will not allocate and initiate a new stringWithFormat of @bar and output it to the console with NSLog(), but will output @newBar to the console? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Class Factory Methods?
On Mon, Jun 22, 2009 at 12:02 PM, Chunk 1978chunk1...@gmail.com wrote: new, alloc, initWithFormat (or stringWithFormat) are class factory methods that are declared methods inherited by my custom classes, i guess somewhere in NSObject? No. +alloc is a class method that creates a new instance. -initWithFormat: is an initializer. +new is a shortcut for saying [[Foo alloc] init]. +stringWithFormat: is a convenience constructor that returns an unowned reference, and is therefore similar to doing [[[NSString alloc] initWithFormat:...] autorelease]. Please review the conceptual documentation, particularly the introduction to Objective-C and the Memory Management Guide. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Class Factory Methods?
You are confused because you are guessing and not verifying. Let's examine: On Jun 22, 2009, at 3:02 PM, Chunk 1978 wrote: new, alloc, initWithFormat (or stringWithFormat) are class factory methods that are declared methods inherited by my custom classes, i guess somewhere in NSObject? Computer programming is not guessing. The documentation tells you precisely where these methods are declared as well as the lineage of the classes (which tells you whether a class inherits these methods). Both -initWithFormat: and +stringWithFormat: are methods (instance and class, respectively) of NSString. The new and alloc methods belong to NSObject. This information is easily verified in the class reference documentation and even discoverable in a few seconds with Google. DO YOUR RESEARCH. DO NOT GUESS. so it write a stringWIthFormat class method, i guess to override it for the custome class it's written within: -=-=-=-=- + (NSString *)stringWithFormat { return @newBar; } -=-=-=-=- Okay, so at this point you have a subclass. Of what? NSObject? NSString? NSRandomObjectWithMysteriousOrigins? This is directly relevant to your question. assuming both these methods are written in the same custom class, does that mean that my first method (void)myMethod will not allocate and initiate a new stringWithFormat of @bar and output it to the console with NSLog(), but will output @newBar to the console? It's difficult to answer your question because things are a bit muddled here. The outcome of your test depends on a few things you haven't defined. First, your -myMethod is calling the *instance* method - initWithFormat: of an allocated instance of NSString. You're specifying that method of that particular class, so that's what gets called. Second (related to the first), why would you expect +stringWithFormat of your subclass (of questionable parentage) if you're not calling that method on that class? -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Warnings suggest compiler confusion between 32 and 64 bit code.
On Jun 22, 2009, at 7:56 AM, Dave Carrigan wrote: On Jun 22, 2009, at 5:09 AM, Brian Bruinewoud wrote: warning: passing argument 1 of 'colorWithDeviceRed:green:blue:alpha:' as 'float' rather than 'double' due to prototype Turn off -Wconversion, which isn't a very useful warning these days that everybody uses ANSI C. More specifically, -Wconversion is telling you that your code *is* correct, but would be incorrect *if* you deleted the method prototype. That warning might have been useful a few decades ago when prototypes were introduced into code written before they existed, but it's useless now. There's nothing you can do to your code to make the warning go away. Either ignore the warning, or turn off -Wconversion. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Approaches for this Matching Problem?
On Jun 22, 2009, at 1:25 PM, Steve Cronin wrote: Thanks as always for a thought-provoking and thorough response! Sure. :) 2) I don't see how looping on the 'words' in thePhrase would change the 'ham' issue you raise - it would still match either on the word or the phrase. Am I missing something? Well, if you want to compare words, you have to separate thePhrase out into words. Otherwise, you're doing string matching not word matching. That's fine if that's what you want, but it's not what you originally asked about. If you do want to match words and not just strings, you wouldn't use - rangeOfString:options:. You'd directly compare words with - compare:options:. 3) The actual tags in this particular context are extensive enough that this 'ham-confusion' is pretty unlikely and could be easily remedied by the user's management of the tag list... [e.g. service, management, institute] -- I know there remains the root forms issue but let's not drag that issue in here OK, fine. You know your requirements; I don't. I asked the question to help you refine your requirements. If you don't have a problem with the case where tags match a substring of thePhrase which isn't actually a word of thePhrase, then that's perfectly legitimate. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Amount of Arguments per Method
On Jun 22, 2009, at 1:03 AM, Roland King wrote: This still the longest one or has Apple outdone themselves since? 11 args, you really wouldn't want much more than this. -(id) initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel : One of the Objective-C runtime's unit tests includes methods with names like @selector(idret) That's 28 unnamed parameters. (The test fills every parameter register with a value, to make sure objc_msgSend() doesn't trample them. Some architectures have a lot of parameter registers.) -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
ABPeoplePickerView Drag Drop
I have an application with an ABPeoplePickerView in it. I notice that drag drop does not work within the ABPeoplePickerView itself (that is, one cannot drag an ABPerson from the Name column into an ABGroup in the Group column, like one can in the Address Book application). Should this work? If not, does anyone have an example of how to make this work? I found threads related to dragging from an ABPeoplePickerView into a completely different view, but the challenges are different completely within the ABPeoplePickerView. Thanks, Bart ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: number box class from NSTextField
On Jun 22, 2009, at 11:19, Stephen Blinkhorn wrote: On 22 Jun 2009, at 09:11, Graham Cox wrote: The standard way to handle this is to pair an ordinary text field with a stepper control (and maybe a slider, if you have space). The stepper allows the user to spin the value up or down while the text field allows them to type a value. I'm using the stepper approach for now but neither me nor my users like it much. The slider idea could be useful but of course GUI space is at a premium which is one of the reasons I'm looking at alternatives. There are two really basic flaws in the scroll-wheel-over-the-text- field approach: (1) It attaches *invisibly* different behavior to a well-known UI object. The fact that there are plenty of examples of this doesn't mean it's not an abuse of users' goodwill, just that it's the least obnoxious abuse that the developer could think of at the time. (2) *Nested* wheel-scrolling behavior can be a frustration for users, because it forces them to stop and think what the effect of using the scroll wheel is going to be. This is just exacerbated when some of the behavior is harmless adjustment of the UI (e.g. scrolling) and some is real change to the data model. That means the price of the users missing the scroll target by a pixel is pretty high. However, since have (at least) a fair justification for wanting to adjust numeric values via the scroll wheel, and you've already committed view real-estate to steppers, I'd suggest you: (a) Attach the scroll-wheel behavior to the stepper, not to the text field. That may involve subclassing the stepper control or the stepper cell. (b) Give the stepper a different visual appearance. The obvious choice would be to replace the up/down arrows with the top and bottom halves of a thumbwheel image, and have the thumbwheel image animate nicely when the value is being changed. That would be doable by subclassing the stepper cell. Chances are, there's already an implementation of something like this out there that you could adapt. FWIW. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
How to customize the context menu appearances.
Thank you for the IB Plugin BWToolkit. http://brandonwalkin.com/bwtoolkit/ I can implement transparent popup buttons in my HUD windows. But the menu, that appears from a transparent popup button, has still the same appearance as the normal menu, ie. white background and black character color. I want to customize the popup menu and context menu appearances suitable to the HUD window. Does anybody know how to customize the context menu appearances? Satoshi ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 customize the context menu appearances.
Please don't repeatedly ask the same question. You asked the list yesterday. For the record, you can't customize the appearance of NSMenu. You can, however, use a borderless NSWindow to achieve the goal you desire, but as it is not a true menu it will not exhibit quite the same behavior as one. Please file a bug at http://bugreport.apple.com asking for native support for HUD-themed controls. Your bug will likely be marked as a duplicate, but that helps show the powers that be at Apple that this really is an issue. From my informal discussions with people at WWDC, people at Apple are indeed aware of the issue, and adding your voice can only help ensure we see official support for HUD controls sooner rather than later. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to customize the context menu appearances.
On 22 Jun 2009, at 21:37:52, 慧 松本 wrote: Thank you for the IB Plugin BWToolkit. http://brandonwalkin.com/bwtoolkit/ I can implement transparent popup buttons in my HUD windows. But the menu, that appears from a transparent popup button, has still the same appearance as the normal menu, ie. white background and black character color. I want to customize the popup menu and context menu appearances suitable to the HUD window. Does anybody know how to customize the context menu appearances? Satoshi You can't. The only way to do this is to write your own classes for the menu. Or better still, use the default appearance. This will be the most consistent with the current Mac way of life.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Cascade Delete won't delete Department in Apple Sample Code
Core Data documentation [1] describes the Cascade Delete Rule as follows: Delete the objects at the destination of the relationship. For example, if you delete a department, fire all the employees in that department at the same time. In order to understand another problem, I tried this on this the inverse relationship in Apple's DepartmentAndEmployees Sample Code project. That is, in the data model, I selected the Employee -- Department to-one relationship by selecting the 'department' relationship in the 'Employee' entity, changed its Delete Rule to Cascade, added some code to log and -processPendingChanges to the MyDocument class [2], built, and run. Running, in a new document, I added an Employee, then deleted it. I expected that the Department would be deleted also, but it was not. Now I understand that deleting the Department might wreak havoc in this particular project, or generate a 'deny' error, but according to the console log [3] it didn't even try. Can anyone suggest why not? Jerry [1] http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html#/ /apple_ref/doc/uid/TP40001857-SW1 [2] In -initWithType:error:, I added this: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mocModelChanged:) name:NSManagedObjectContextObjectsDidChangeNotification object:[self managedObjectContext]] ; And then I added this method: - (void)mocModelChanged:(NSNotification*)notification { NSSet* insertedObjects = [[notification userInfo] objectForKey:NSInsertedObjectsKey] ; NSSet* deletedObjects = [[notification userInfo] objectForKey:NSDeletedObjectsKey] ; NSSet* updatedObjects = [[notification userInfo] objectForKey:NSUpdatedObjectsKey] ; NSLog(@ Model Changed!! *) ; NSManagedObject* object ; for (object in insertedObjects) { NSLog(@ inserted object: %@, object) ; } for (object in deletedObjects) { NSLog(@ deletedObject: %@, object) ; } for (object in updatedObjects) { NSLog(@!!! updatedObject: %@ %p, [[object entity] name], object) ; NSLog(@ !!! changedValues: %@, [object changedValues]) ; } NSLog(@** End of Model Changes **\n) ; /*DB?Line*/ NSLog(@4550: Processing...) ; [[self managedObjectContext] processPendingChanges] ; } [3] Console log output when upon deleting 1 of 1 employee: 2009-06-22 13:47:11.380 DepartmentAndEmployees[82461:10b] Model Changed!! * 2009-06-22 13:47:11.381 DepartmentAndEmployees[82461:10b] deletedObject: Employee: 0x1c54b0 (entity: Employee; id: 0x1b9760 x-coredata:///Employee/tB41AABC2-E997-4739-B199-8EFB3B7987AE6 ; data: { department = nil; directReports = ( ); employeeID = 3; firstName = First; lastName = Last; manager = nil; salary = 0; }) 2009-06-22 13:47:11.382 DepartmentAndEmployees[82461:10b] !!! updatedObject: Department 0x164ef0 2009-06-22 13:47:11.383 DepartmentAndEmployees[82461:10b]!!! changedValues: { } 2009-06-22 13:47:11.383 DepartmentAndEmployees[82461:10b] ** End of Model Changes ** 2009-06-22 13:47:11.384 DepartmentAndEmployees[82461:10b] 4550: Processing... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Approaches for this Matching Problem?
Hi Gerriet, On Mon, Jun 22, 2009 at 10:46 PM, Gerriet M. Denkmanngerr...@mdenkmann.de wrote: Bear in mind that some languages don't really have the concept of words. Could you please elaborate? Maybe some examples? I'm afraid I'm not an expert. I just remember hearing it said at WWDC (so bear in mind, it's second hand). The Wikipedia article regarding words is an interesting read. Kind regards, Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Amount of Arguments per Method
In documentation, stacking the arguments verticaly is of value. In actual code, I _always_ concatenate on to as few lines as necesary (tho' using double indentation for subsequent lines) as I find it makes for much _more_ readable code. Reasoning? - I wrote that code, or I've already read it carefully, so I know - as well as I need to - what kinds of arguments it takes. What I'm much more interested in is the 'shape' of the code, or it's structure. So fitting more on a page is much of more value (but not over-compressing the code as this has exactly the oposite effect). A problem with an individual function call means I concentrate on the line or lines that it occupies, stacking verticaly doesnt help much. If the structure of the code is obfusicated, that will always be a problem and an ongoing one. That's just my view. The point is - do what works best for you, and leave others do what's best for them. Trying to force others to your preference is a great way to stifle creativity, enjoyment and quality. Everybody is different and works differently, and the very best they can do is to do what works best for them. paulm On 23/06/2009, at 3:03 AM, WT wrote: This brings to mind a peeve of mine: Apple's unofficially sanctioned practice, followed by a lot of people, of NOT throwing in some white space in between parts of method names. Programmers spend most of their time *reading* code (their own or other people's), and with method names as verbose as those found in Cocoa, it seems to me that adding some white space ought to be a common practice. Alas... I mean, seriously, how easy is it to read - (id) outputImageProviderFromBufferWithPixelFormat:(NSString*)format pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height baseAddress:(const void*)baseAddress bytesPerRow:(NSUInteger)rowBytes releaseCallback:(QCPlugInBufferReleaseCallback)callback releaseContext:(void*)context colorSpace:(CGColorSpaceRef)colorSpace shouldColorMatch:(BOOL)colorMatch (copied directly from the documentation link Andy provided) compared to - (id) outputImageProviderFromBufferWithPixelFormat: (NSString*) format pixelsWide: (NSUInteger) width pixelsHigh: (NSUInteger) height baseAddress: (const void*) baseAddress bytesPerRow: (NSUInteger) rowBytes releaseCallback: (QCPlugInBufferReleaseCallback) callback releaseContext: (void*) context colorSpace: (CGColorSpaceRef) colorSpace shouldColorMatch: (BOOL) colorMatch I know that XCode will automatically pretty-print code for us, but I'm talking about Apple's documentation (and code-sharing in this list and elsewhere). It's not like pdfs or html pages kill trees, you know. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 Fetching Limitations?
Thanks for your reply. This is a good idea. But in the end, won't my predicate have something like SELF IN thatSetWeDeterminedUsingYourMethod? As I said originally, I will need to combine a bunch of such predicates together to form an aggregate predicate. Much in a way that smart playlists add a bunch of predicates together. (For example: I may want to combine that 'Jo' and 'Volvo' predicate with another 'Dan' and 'Benz' predicate.) This raises the question of SQLite storage's limitation that any given query cannot contain more than one occurrences of IN (same for ANY and ALL). You have any thoughts on this matter? I guess another question to you could be: Have you compared Core Data's performance using SQLite vs. Binary? Both are said to be fast in the Core Data doc. However, rumors claim SQLite wins. On the other hand, Binary will allow me to combine INs. From: cocoa...@mikeabdullah.net To: ulaibee...@hotmail.com Subject: Re: Core Data Fetching Limitations? Date: Mon, 22 Jun 2009 12:53:54 +0100 I guess the trickiest part of your scenario is that the predicate is being applied across 2 relationships, making the process quite intensive. What I'm pretty certain you can do (and in fact in this scenario is probably more efficient) is to fetch all employees whose name starts with 'Jo' and whose assigned car has the name of 'Volvo'. Then, query that the result of that fetch for each employee's department, plonk them into a set, and you will have a unique set of departments matching the query. On 22 Jun 2009, at 02:00, Ulai Beekam wrote: (Sorry, the previous post was not sent with plaintext) Please draw up the following model on a piece of paper: We have three entities: Department, Employee, and EmployeeCar. Each of them has the 'name' attribute. Department has the to-many 'employees' relationship to Employee. Its inverse is, naturally, the to-one 'department' relationship in Employee. Employee has a to-one 'employeeCar' relationship to EmployeeCar. Its inverse is the to-many 'employees' relationship in EmployeeCar. This reflects the reality that a single car can be assigned to more than one employee, but a given employee does only have one car assigned to him. NOW HERE IS THE QUESTION: How can I make Core Data: fetch all departments that have an employee whose name starts with 'Jo' and whose assigned car has the name of 'Volvo' Can Core Data even make such fetches? Can it be done without ALL,ANY? I ask because I might want to combine many such conditions, making it impossible to do with the SQLite storage option. Maybe I can just simply forget the SQLite storage for this? What are the alternatives? Am I doomed to work with the other slower storages? And note that I do indeed have to have it inside a single predicate because I have an NSArrayController of Department objects, and after having made the correct predicate (for which I need your help) I plan to set the array controller's fetch predicate to that predicate. Thanks, U. _ Windows Live™: Keep your life in sync. Check it out! http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: number box class from NSTextField
On 22 Jun 2009, at 14:16, Quincey Morris wrote: (2) *Nested* wheel-scrolling behavior can be a frustration for users, because it forces them to stop and think what the effect of using the scroll wheel is going to be. This is just exacerbated when some of the behavior is harmless adjustment of the UI (e.g. scrolling) and some is real change to the data model. That means the price of the users missing the scroll target by a pixel is pretty high. That's a good point actually. Everything I do in my software happens inside one window with no scroll bars etc. For completeness here is my current number box class :) // header #import Cocoa/Cocoa.h @interface ASNumberBox : NSTextField NSCoding { float curValue; float minValue; float maxValue; float range; float dragSize; float scrollStep; float fineGrain; // floatstart_x; float start_y; float prev_y; BOOLdrag; } -(void)checkBounds; @end // implementation #import ASNumberBox.h @implementation ASNumberBox -(void)initValues { curValue = [super floatValue]; minValue = 0; maxValue = 127; range = maxValue - minValue; scrollStep = range / 256; dragSize = 512; fineGrain = 0.25; drag = NO; } -(id)initWithFrame:(NSRect)rect { if (self = [super initWithFrame:rect]) { [self initValues]; } return self; } -(id)initWithCoder:(NSCoder*)coder { if (self = [super initWithCoder:coder]) { [self initValues]; }; return self; } -(void)encodeWithCoder:(NSCoder*)coder { [super encodeWithCoder:coder]; } -(void)dealloc { [super dealloc]; } -(BOOL)isFlipped { return NO; } -(void)checkBounds { if(curValue minValue) { curValue = minValue; } else if (curValue maxValue) { curValue = maxValue; }; } #pragma mark Events -(void)mouseUp:(NSEvent*)theEvent { if(drag) drag = NO; } -(void)mouseDragged:(NSEvent*)theEvent { if(!drag) { // float start_x = [self convertPoint: [theEvent locationInWindow] fromView: nil].x; start_y = [self convertPoint:[theEvent locationInWindow] fromView: nil].y; prev_y = start_y; drag = YES; }; // key modifier key flags unsigned int flags; flags = [theEvent modifierFlags]; float next_y = [self convertPoint:[theEvent locationInWindow] fromView: nil].y; float deltaY = (next_y - prev_y) / dragSize; prev_y = next_y; if(flags NSAlternateKeyMask) deltaY *= fineGrain; curValue += range * deltaY; [self checkBounds]; [self setIntValue:curValue]; // continuously send the action [self sendAction:(SEL)[self action] to:(id)[self target]]; } -(void)scrollWheel:(NSEvent*)event { // key modifier key flags unsigned int flags; flags = [event modifierFlags]; float wheelY = [event deltaY]; if(flags NSAlternateKeyMask) { curValue += wheelY * scrollStep * fineGrain; } else { curValue += wheelY * scrollStep; }; [self checkBounds]; [self setIntValue:curValue]; // send the action [self sendAction:(SEL)[self action] to:(id)[self target]]; } @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: number box class from NSTextField
That's a good point actually. Everything I do in my software happens inside one window with no scroll bars etc. For completeness here is my current number box class :) designed for non-editable text field naturally. Stephen ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: FirstResponder in 10.4
On 23/06/2009, at 3:06 AM, iseecolors wrote: I have a NIB with a NSView that I use to populate a Contextual View in the Main Window. I have tried to set the firstResponder from IB, from init, from awakeFromNib, and from - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor All of these work in 10.5 (+), but only that last works in 10.4. Unfortunately the side effect of the last is that if the user clicks on a different edit field and starts to type, the focus is on the firstResponder instead of the field the user just clicked on. I am sure I can continue to with this, but it seems like there must be a better way. It seems unlikely that 10.4 is this messed up and it will not correctly set the firstResponder. Any hints as to what I am missing? It's very unclear what you're trying to do. My interpretation is that you have a custom view, and you want to make it first responder? You don't set first responder in most cases. Instead, implement -acceptsFirstResponder and -canBecomeKeyView to return YES, and hook up the window's initialFirstResponder outlet to your view. If there are other candidates for first responder in your window, the user should be allowed to change it, so you may also want to include your view in the key loop (nextKeyView, previousKeyView), or set this to be recalculated automatically, and make it draw a focus ring when it is first responder. To force a specific view to become first responder, you need to use the window's -makeFirstResponder: method, not by calling - becomeFirstResponder on the view itself - but doing this is usually unnecessary as you can set the initialFirstResponder in IB. If this is irrelevant info, then you'll need to be clearer about what you're trying to achieve, and your current code. --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: number box class from NSTextField
On 23/06/2009, at 4:19 AM, Stephen Blinkhorn wrote: The click and drag number box is very much a standard in audio applications, for example, Apple's Logic Pro. Audio apps do seem to plough their own furrow when it come to UI though - it's not necessarily going to generalise. But why not just customise the appearance so it looks sufficiently different from a standard text field? Then at least users won't be so surprised when it behaves differently. You could make it look like a rotary knob for example, with the number shown in the centre. --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
Programmatically Accessing Core Data Localization Strings
Hello, I have a strings file defined for my Core Data model. As such, my Data.xcdatamodel file has a corresponding DataModel.strings file. This seems to work great for auto-generated messages, but now I have a need to access these localized strings programmatically. NSLocalizedString does not seem to find them, and the localizationDictionary property of my NSManagedObjectModel is often nil (the documentation states that this is loaded lazily). How can I go about localizing the names of my properties and entities from code? I could theoretically duplicate all of my DataModel.strings strings into my applications main strings file. However that really doesn't seem ideal. Do I have a better option? Thank you, Sebastian ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Programmatically Accessing Core Data Localization Strings
On Jun 22, 2009, at 7:56 PM, Sebastian Celis wrote: I have a strings file defined for my Core Data model. As such, my Data.xcdatamodel file has a corresponding DataModel.strings file. This seems to work great for auto-generated messages, but now I have a need to access these localized strings programmatically. NSLocalizedString does not seem to find them, and the localizationDictionary property of my NSManagedObjectModel is often nil (the documentation states that this is loaded lazily). How can I go about localizing the names of my properties and entities from code? Use NSLocalizedStringFromTable() with DataModel as the name of the table. 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Card Game (like Spider-Solitaire) in Cocoa -- Conceptual ideas needed
Hi guys! I created an Spider Solitaire branch on github (http://github.com/FloWi/MyGeekGameBoard/tree/master ) Not very clean yet - consider it as an initial hack to get it working ;-) Too bad, that CoreAnimation doesn't run on Tiger... My girlfriend has a MacMini with Tiger and loves to play Solitaire. Perhaps it's a reason to upgrade :P Regards, Florian Am 12.06.2009 um 22:21 schrieb Erik Buck: 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/florian_witteler%40gmx.de This email sent to florian_witte...@gmx.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Beginner Question Re: Memory Management
Hi, I'm looking at some sample iPhone code, and in the app delegate's applicationDidFinishLaunching method, I see // Set up the view controller MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@HelloWorld bundle:[NSBundle mainBundle]]; self.myViewController = aViewController; [aViewController release]; I'm a little confused - I see an allocation, followed by an assignment, followed by a release. I think that the assignment is really a call to a setter - the myViewController field is created automagically using the @property/@synthesize syntax. Since a release was sent to aViewController, what keeps that object from being nuked at the end of the run loop? There must be another retain happening somewhere, right? Second question - is there anyway to see the code that gets generated by @synthesize? I'm nosy and curious. Thanks, Daniel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
IKImageBrowserView setSelectionIndex not selecting
I have been researching extensively on how to set an IKImageBrowserView's initial selection upon load to 0 index. Here is the call I am making: [imageBrowser setSelectionIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; Seems like the IKImageBrowserView is not fully loaded when the call is made, however, I do have an IKImageView which is selecting and loading the first object in the ImageBrowserView's object list correctly mat the same time I am calling the same time. Here is the entire call: - (void)updateDatasource { [images addObjectsFromArray:importedImages]; [importedImages removeAllObjects]; [imageBrowser reloadData]; NSString *firstImagePath = [[images objectAtIndex:0] imageUID]; NSURL *firstImageURL = [NSURL fileURLWithPath:firstImagePath]; [previewImageStatic setImageWithURL:firstImageURL]; [pathTextField setStringValue:firstImagePath]; [imageBrowser setSelectionIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; } I am not sure how I can get this call to select the object at index 0. I even created an IBAction connected to a test button using the following code: - (IBAction)selectImageBrowserFirstObject:(id)sender { [imageBrowser setSelectionIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; } And that works perfectly (since the IKImageBrowserView is already completely loaded. Any ideas on how to work this out? Thank you in advance. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Beginner Question Re: Memory Management
On 23/06/2009, at 6:39 AM, Daniel Torrey wrote: I'm looking at some sample iPhone code, and in the app delegate's applicationDidFinishLaunching method, I see // Set up the view controller MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@HelloWorld bundle:[NSBundle mainBundle]]; self.myViewController = aViewController; [aViewController release]; I'm a little confused - I see an allocation, followed by an assignment, followed by a release. I think that the assignment is really a call to a setter - the myViewController field is created automagically using the @property/@synthesize syntax. Since a release was sent to aViewController, what keeps that object from being nuked at the end of the run loop? There must be another retain happening somewhere, right? Have a look at the definition for the property myViewController - it should include the 'retain' attribute, which tells you that the object is retained when it is assigned. In which case, it won't be nuked. I don't think you can see the code generated by @synthesise, as it probably doesn't exist as Objective-C anywhere - but you can disassemble it. I could be wrong though... --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
stepping in unit test
Hi, I'm using XCode 2.4.1, doing some unit test, is it possible to debug/step in unit test classes? Thanks, Angelo Yahoo!香港提供網上安全攻略,教你如何防範黑客! 請前往 http://hk.promo.yahoo.com/security/ 了解更多! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: IKImageBrowserView setSelectionIndex not selecting
On 23/06/2009, at 10:08 AM, Richard Gutierrez wrote: I have been researching extensively on how to set an IKImageBrowserView's initial selection upon load to 0 index. Here is the call I am making: [imageBrowser setSelectionIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; Seems like the IKImageBrowserView is not fully loaded when the call is made, however, I do have an IKImageView which is selecting and loading the first object in the ImageBrowserView's object list correctly mat the same time I am calling the same time. Here is the entire call: - (void)updateDatasource Where do you call this from? You'll need to call it from -awakeFromNib to ensure the view is loaded. --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: stepping in unit test
try google .. here's one link which describes how to do it. http://chanson.livejournal.com/120740.html Angelo Chen wrote: Hi, I'm using XCode 2.4.1, doing some unit test, is it possible to debug/step in unit test classes? Thanks, Angelo Yahoo!香港提供網上安全攻略,教你如何防範黑客! 請前往 http://hk.promo.yahoo.com/security/ 了解更多! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 with NSValueTransformer, NSTableView and NSAttributedString
On 2009 Jun 21, at 07:37, Donnie Lee wrote: I created NSTableView and bind table column with NSTextFieldCell with custom NSValueTransformer subclass to NSArrayController. My value transformer should return NSAttributedString transformed from NSString. Everything works fine except that the table shows NSString instead of NSAttributedString. It looks like: My text{NSFont = LucidaGrande}. How to make the right behavior for my value transformer? I've never seen an NSTextFieldCell bound to an attributed string. I don't believe that NSTextFieldCell supports attributed strings. If you bind it to a value that provides an attributed string, it probably extracts the string and ignores the attributes, giving the result you see. As far as I know, an NSTextFieldCell must have the same font for its entire string. To set the font, subclass -[NSTableColumn dataCellForRow:] so that you can provide the cell. An instance of NSTextFieldCell will be fine. In that implementation, send that cell a setFont: message before you return it. If you really want to have a different font in different attribute runs, you'll need to subclass that NSTextFieldCell. Well, at least someone will probably notice your message now and correct me if I'm wrong :) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Programmatically Accessing Core Data Localization Strings
Perfect! Thanks! - Sebastian On Mon, Jun 22, 2009 at 9:36 PM, Nick Zitzmannn...@chronosnet.com wrote: On Jun 22, 2009, at 7:56 PM, Sebastian Celis wrote: I have a strings file defined for my Core Data model. As such, my Data.xcdatamodel file has a corresponding DataModel.strings file. This seems to work great for auto-generated messages, but now I have a need to access these localized strings programmatically. NSLocalizedString does not seem to find them, and the localizationDictionary property of my NSManagedObjectModel is often nil (the documentation states that this is loaded lazily). How can I go about localizing the names of my properties and entities from code? Use NSLocalizedStringFromTable() with DataModel as the name of the table. 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Opinion on managed memory and garbage collection
On 22/06/2009, at 22:58 , Phil Hystad wrote: If you were writing a new Cocoa application from scratch, would garbage collection be the preferred method over the reference counting (retain/release) method. Having spent years in Java I would prefer a GC'd approach but I have also seen the great improvement of GC in Java over the years. Therefore, I am also curious on how the new Objective-C design for GC compares. The applications I have in mind are mostly graphic (Quartz 2D) oriented and likely also some OpenGL work. The main issue is performance. GC is usually quoted as having a 10-20% performance hit, but obviously it would depend heavily on what you were doing. If I was writing a new app from scratch that was not likely to be CPU intensive, I would probably use GC. If I was writing Keyboard Maestro from scratch, I would certainly use Garbage Collection. That said, graphic (Quartz 2D) oriented / OpenGL might well fall in to the CPU intensive sphere. Also, if you are going to use GC, for heaves sake go and research the dangling internal pointer issue (see the thread at http://lists.apple.com/archives/objc-language/2009/Mar/msg00037.html ) which scares the daylights out of me because its such a subtle bug which would be horrendous to debug if you were not well versed with the possibilities. Enjoy, Peter. -- Clipboard Switching and Macros with Keyboard Maestro Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac http://www.stairways.com/ http://download.stairways.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Service not working
Hi folks, I'm trying to develop an application that acts as a service, but I cannot make it appear on the Services Menu and I cannot execute it on the applications. I tried to search for similar posts with no success and looked at the documentation at least 4 times with no luck either. See If somebody can help me :) Here Is the portion of the .plist files corresponding to the Service entry keyNSServices/key array dict keyNSMessage/key stringserviceMovieInfo/string keyNSPortName/key stringMovieInfoReport/string keyNSReturnTypes/key array stringNSStringPboardType/string /array keyNSSendTypes/key array stringNSStringPboardType/string /array keyNSMenuItem/key dict keyMenu item title/key stringGet Movie Info/string /dict /dict /array The methods are defined like they are put on the file; After compiling I've put the application with .app and .service in the places to see if it works but no luck either... Anyone has some ideas? Many thanks to all! Guillem ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
CalendarStore and delegated calendars
Hello all, Is it a bug or by design that the CalendarStore will not pick up delegated calendars? I've googled all night without an answer. Thanks in advance! -Steve ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Warnings suggest compiler confusion between 32 and 64 bit code.
On Mon, Jun 22, 2009 at 12:42 PM, Kyle Sluderkyle.slu...@gmail.com wrote: On Mon, Jun 22, 2009 at 5:09 AM, Brian Bruinewoudbr...@darknova.com wrote: CGFloat c = 0.0L; The compiler is silent here because it knows that 0.0L is finitely representable as a float (0.0). As for the other two occasions, you would need to compile with data flow analysis (which I believe is triggered by -O2 or higher) for the compiler to perform the constant folding necessary to see that you're storing a finitely-representable value. I would not recommend disabling -Wconversion. It is a great way to highlight places where your code is not 64-bit ready. I think you mean -Wshorten-64-to-32. -Wconversion warns you every time a function call has the parameter passing altered by the presence of the function's prototype, which is to say that it will warn you every time you call any function (or method) which takes a char, unsigned char, short, unsigned short, or float. Not exactly useful. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Amount of Arguments per Method
On Mon, Jun 22, 2009 at 7:46 PM, Paul Ml...@no-tek.com wrote: In documentation, stacking the arguments verticaly is of value. In actual code, I _always_ concatenate on to as few lines as necesary (tho' using double indentation for subsequent lines) as I find it makes for much _more_ readable code. Reasoning? - I wrote that code, or I've already read it carefully, so I know - as well as I need to - what kinds of arguments it takes. What I'm much more interested in is the 'shape' of the code, or it's structure. So fitting more on a page is much of more value (but not over-compressing the code as this has exactly the oposite effect). A problem with an individual function call means I concentrate on the line or lines that it occupies, stacking verticaly doesnt help much. If the structure of the code is obfusicated, that will always be a problem and an ongoing one. The trouble with this sort of thing is that when you come back to the code in six months' time you will no longer know what kinds of arguments it takes and other such important details. Whether it's better to optimize for the short term or for the long term is of course a difficult decision that you need to make for yourself. I personally like to split long methods onto multiple lines or, better yet, take long methods as a sign of a design flaw and eliminate them altogether. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with NSValueTransformer, NSTableView and NSAttributedString
On Mon, Jun 22, 2009 at 11:15 PM, Jerry Krinockje...@ieee.org wrote: On 2009 Jun 21, at 07:37, Donnie Lee wrote: I created NSTableView and bind table column with NSTextFieldCell with custom NSValueTransformer subclass to NSArrayController. My value transformer should return NSAttributedString transformed from NSString. Everything works fine except that the table shows NSString instead of NSAttributedString. It looks like: My text{NSFont = LucidaGrande}. How to make the right behavior for my value transformer? I've never seen an NSTextFieldCell bound to an attributed string. I don't believe that NSTextFieldCell supports attributed strings. If you bind it to a value that provides an attributed string, it probably extracts the string and ignores the attributes, giving the result you see. As far as I know, an NSTextFieldCell must have the same font for its entire string. To set the font, subclass -[NSTableColumn dataCellForRow:] so that you can provide the cell. An instance of NSTextFieldCell will be fine. In that implementation, send that cell a setFont: message before you return it. If you really want to have a different font in different attribute runs, you'll need to subclass that NSTextFieldCell. Well, at least someone will probably notice your message now and correct me if I'm wrong :) NSTextFieldCell supports attributed strings just fine. That's why it has a -setAttributedStringValue: method. The trouble here is that the table is somehow displaying the attributed string's description rather than the attributed string itself. It will probably not be possible to say why this is happening without seeing Donnie's code. Even then it may be difficult to say. This sort of problem is why I dislike using bindings for complicated situations like table views. If you just set up a simple data source instead, then you can *see* exactly where all the data is coming from and you can see exactly what's going out to the table view, and where to alter it. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with NSValueTransformer, NSTableView and NSAttributedString
On Jun 21, 2009, at 10:37 AM, Donnie Lee wrote: I created NSTableView and bind table column with NSTextFieldCell with custom NSValueTransformer subclass to NSArrayController. My value transformer should return NSAttributedString transformed from NSString. Everything works fine except that the table shows NSString instead of NSAttributedString. It looks like: My text{NSFont = LucidaGrande}. How to make the right behavior for my value transformer? The documentation for the value binding of NSTableView says that NSString and NSNumber are the supported value types. http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSTextFieldCell.html#/ /apple_ref/doc/uid/NSTextFieldCell-DontLinkElementID_657 Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Opinion on managed memory and garbage collection
On Mon, Jun 22, 2009 at 10:58 AM, Phil Hystadphys...@mac.com wrote: Being relatively new to Cocoa and Objective-C, what is the consensus on using the new version 2.0 managed memory features (garbage collection). If you were writing a new Cocoa application from scratch, would garbage collection be the preferred method over the reference counting (retain/release) method. Having spent years in Java I would prefer a GC'd approach but I have also seen the great improvement of GC in Java over the years. Therefore, I am also curious on how the new Objective-C design for GC compares. The applications I have in mind are mostly graphic (Quartz 2D) oriented and likely also some OpenGL work. Thanks for your opinions and comments. IMO there are three major reasons to avoid GC at this point: 1) In 10.5 there are still significant bugs in the GC and, more importantly, the GC support in the system frameworks. The GC bugs are generally obscure and hard to hit, the frameworks are much easier to hit and harder to work around. If you search the list archives you'll probably turn up various posts where Apple people tell developers that you can't use this API under GC, or it has some huge speed hit, or the only way to avoid a crash is to deliberately leak an object, etc. Hopefully 10.6 is better, but as always, the people who know can't say and the people who can say don't know. 2) The GC pauses your threads at nondeterministic intervals and for an unknown amount of time in order to scan its stack. If this pause is significant enough, it could cause occasional visible stutter in your graphics output. I have no idea what the chances are of this causing problems for you, but it's something to watch out for. 3) By its very nature of trying to coexist in a C-based language, the GC doesn't cover everything. This is by design. The GC covers ObjC objects (including bridged CoreFoundation objects allocated in the default zone) and raw memory that you explicitly allocate with the collector. Anything that's allocated with raw malloc/free stays outside the garbage collector. This is a big advantage in that any raw C code that you happen to have (or load) will almost certainly Just Work in a garbage collected environment, which I'm sure is a big part of why the Apple GC guys chose to make it work this way. The downside is that your interactions with the collector often become more manual than you might like if you drop out of the Ideal Pure Objective-C World and into the guts of C. The code you write here will offset your savings from not having to write retain/release code, and worse, this code is usually much more complex and error-prone. I have not done a lot of serious work with GC, although I have a half-completed project and some toy projects that use it. My personal impression is that if you're doing a conventional, straightforward OS X program which never colors outside the lines, you're likely to have a good experience with it. If you're after high performance or are doing anything tricky then you're likely to run afoul of it and perhaps wish that you had gone the other way. Retain/release has a long history, is very well understood, and doesn't really require much mental (or typing) overhead once you know it. With GC you're much more like a test pilot at this stage in the game, especially since there are a lot of frameworks deficiencies under GC which are known to Apple but which they haven't actually put into the documentation. (List archives are your friend here.) GC has more risk and potentially more reward. If you can aim for 10.6+, the risk/reward ratio is probably going to be quite a bit lower, although that's just speculation. Obviously the ultimate choice is yours. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Beginner Question Re: Memory Management
On Jun 23, 2009, at 4:47 AM, Graham Cox wrote: On 23/06/2009, at 6:39 AM, Daniel Torrey wrote: I'm looking at some sample iPhone code, and in the app delegate's applicationDidFinishLaunching method, I see // Set up the view controller MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@HelloWorld bundle:[NSBundle mainBundle]]; self.myViewController = aViewController; [aViewController release]; I'm a little confused - I see an allocation, followed by an assignment, followed by a release. I think that the assignment is really a call to a setter - the myViewController field is created automagically using the @property/@synthesize syntax. Since a release was sent to aViewController, what keeps that object from being nuked at the end of the run loop? There must be another retain happening somewhere, right? Have a look at the definition for the property myViewController - it should include the 'retain' attribute, which tells you that the object is retained when it is assigned. In which case, it won't be nuked. I don't think you can see the code generated by @synthesise, as it probably doesn't exist as Objective-C anywhere - but you can disassemble it. I could be wrong though... --Graham Apropos the question raised by Daniel and Graham's response, and to help other beginners, I'd like to relate a little true story that happened to me just yesterday. In the iPhone app I'm writing, I was doing some text processing on the contents of a text field that the user can edit and in several places I had the same piece of code: [textFieldPreviousContent release]; textFieldPreviousContent = [textField.text retain]; So, I decided to make textFieldPreviousContent a property and dutifully declared @property (readwrite, nonatomic, retain) NSString* textFieldPreviousContent; in the header file and then synthesized it in the source file, like so: @synthesize textFieldPreviousContent; So far so good. I then replaced all the [textFieldPreviousContent release]; textFieldPreviousContent = [textField.text retain]; sections with the much simpler textFieldPreviousContent = textField.text; the motivation being that I would not have to remember every time to release textFieldPreviousContent nor to retain textField.text. Ok, great, so now I built and ran and... my app crashed. Huh? Wait... it was working fine before. Hmm... let me see. Property declared correctly... it's readwrite... check. It's retained... check. Property synthesized correctly... check. What the heck??? So, after I scratched my head silly for several minutes, it suddenly came to me. If I'm going to use a property, I *must* refer to it as object.property rather than simply as property. In the specific example I had, I should not have replaced all those repeated chunks of code with textFieldPreviousContent = textField.text; but with self.textFieldPreviousContent = textField.text; Using textFieldPreviousContent = textField.text; meant that I was bypassing the very memory management I thought I was getting for free by turning textFieldPreviousContent into a property. Of course, my mistake implied that a) I was leaking the string pointed to by textFieldPreviousContent and b) I was not retaining the string returned by textField.text. And since that string is returned to me auto-released, textFieldPreviousContent ended up pointing to a memory location that was no longer valid by the time I used its contents. No wonder my app crashed. So, to all beginners out there, whenever you define a property, remember always to refer to it, in its own class, by self.property - at least when setting its value. It may be ok (depending on what you're doing) to refer to it simply by property when *getting* its value, but if the property is backed by an instance variable that is an object (rather than a scalar type), it's *essential* that you refer to it by prepending self when *setting* its value, or you'll not be doing the memory management that you think you're doing. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Amount of Arguments per Method
On Jun 23, 2009, at 6:03 AM, Michael Ash wrote: On Mon, Jun 22, 2009 at 7:46 PM, Paul Ml...@no-tek.com wrote: In documentation, stacking the arguments verticaly is of value. In actual code, I _always_ concatenate on to as few lines as necesary (tho' using double indentation for subsequent lines) as I find it makes for much _more_ readable code. Reasoning? - I wrote that code, or I've already read it carefully, so I know - as well as I need to - what kinds of arguments it takes. What I'm much more interested in is the 'shape' of the code, or it's structure. So fitting more on a page is much of more value (but not over-compressing the code as this has exactly the oposite effect). A problem with an individual function call means I concentrate on the line or lines that it occupies, stacking verticaly doesnt help much. If the structure of the code is obfusicated, that will always be a problem and an ongoing one. The trouble with this sort of thing is that when you come back to the code in six months' time you will no longer know what kinds of arguments it takes and other such important details. Whether it's better to optimize for the short term or for the long term is of course a difficult decision that you need to make for yourself. I personally like to split long methods onto multiple lines or, better yet, take long methods as a sign of a design flaw and eliminate them altogether. Mike Exactly! Moreover, often times (especially if you're part of a team) one doesn't write code that's read just by oneself. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Warnings suggest compiler confusion between 32 and 64 bit code.
On Jun 22, 2009, at 9:01 PM, Michael Ash wrote: -Wconversion warns you every time a function call has the parameter passing altered by the presence of the function's prototype, which is to say that it will warn you every time you call any function (or method) which takes a char, unsigned char, short, unsigned short, or float. Not exactly useful. At least until Xcode gets gcc 4.3, where -Wconversion has been renamed -Wtraditional-conversion, and -Wconversion gives useful warnings about variables that might have their value changed during the conversion. This page http://developer.apple.com/documentation/Darwin/Conceptual/64bitPorting/building/building.html does seem to suggest that -Wconversion has its place but istm that you will have a lot of difficulty isolating the real problems from all of the error chaff. -- Dave Carrigan d...@rudedog.org Seattle, WA, USA PGP.sig Description: This is a digitally signed message part ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Opinion on managed memory and garbage collection
On Jun 23, 2009, at 6:21 AM, Michael Ash wrote: Retain/release has a long history, is very well understood, and doesn't really require much mental (or typing) overhead once you know it. Even less of a mental/typing overhead if you make use of properties. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Amount of Arguments per Method
Meh. I'd much rather see calls to methods that take many arguments broken up across a number of lines for three reasons (drawing the line at methods that take 4 or more arguments, for me): (0) I can scan any given line of the method invocation sub-expression and know that the aligned colons mean method name fragment on left, argument on right. Reading the method name becomes a simple vertical scan. Reading the arguments becomes scan left o' colon for context, right o' colon for value. (1) If any argument isn't a simple variable or constant, breaking it up by line makes reading the expression easier. (2) Knowing the exact extent of the method invocation expression is as simple as double-clicking the opening or closing bracket. (Or you can ctrl-d then ] on the closing bracket to have the opening bracket highlighted, if so configured). I find the whole cram-the-whole-expression-on-one-line notion to be utterly bizarre and painful to read. Code isn't a novel and we aren't writing paragraphs. Code is a highly structured sequence of expressions and our tools are optimized to navigating, editing and compiling said structured code. 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: Beginner Question Re: Memory Management
On Jun 22, 2009, at 1:39 PM, Daniel Torrey wrote: I'm looking at some sample iPhone code, and in the app delegate's applicationDidFinishLaunching method, I see // Set up the view controller MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@HelloWorld bundle:[NSBundle mainBundle]]; self.myViewController = aViewController; [aViewController release]; I'm a little confused - I see an allocation, followed by an assignment, followed by a release. I think that the assignment is really a call to a setter - the myViewController field is created automagically using the @property/@synthesize syntax. Look at the @property declaration for myViewController in the .h file.The likelihood is that there is a retain declared. That means that when the setter method is invoked via the self.myViewController = aViewController; statement, a retain will be issued on the object during the assignment.That statement is essentially equivalent to writing the old-fashioned way: [self setMyViewController: aViewController]; Since a release was sent to aViewController, what keeps that object from being nuked at the end of the run loop? There must be another retain happening somewhere, right? Yes --- in the setter method, assuming the @property declaration declared it as retain. The code you cite above is a common idiom intended to funnel instance variable accesses through their proper accessor methods as opposed to accessing instance variables directly. Second question - is there anyway to see the code that gets generated by @synthesize? I'm nosy and curious. There's a few hints on how the accessors work (they work just fine, thank you) starting around page 50 of The Objective C 2.0 Programming Language document.In general, assume synthesised accessor methods will Do The Right Thing . . . Cheers, . . . . . . . .Henry ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Warnings suggest compiler confusion between 32 and 64 bit code.
On Mon, Jun 22, 2009 at 9:01 PM, Michael Ashmichael@gmail.com wrote: I think you mean -Wshorten-64-to-32. -Wconversion warns you every time a function call has the parameter passing altered by the presence of the function's prototype, which is to say that it will warn you every time you call any function (or method) which takes a char, unsigned char, short, unsigned short, or float. Not exactly useful. You are indeed correct, I had confused the two. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Beginner Question Re: Memory Management
On Jun 22, 2009, at 3:39 PM, Daniel Torrey wrote: I'm looking at some sample iPhone code, and in the app delegate's applicationDidFinishLaunching method, I see // Set up the view controller MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@HelloWorld bundle:[NSBundle mainBundle]]; self.myViewController = aViewController; [aViewController release]; I'm a little confused - I see an allocation, followed by an assignment, followed by a release. I think that the assignment is really a call to a setter - the myViewController field is created automagically using the @property/@synthesize syntax. The expression self.myViewController is using dot syntax. Objective-C 2.0 dot syntax always resolves to accessor calls. It is not a consequence of using declared properties, synthesized or not. It works even with old-style, manually-written properties and accessors. That said, the property declaration gives you good information about the semantics of how the property behaves -- again, regardless of whether it's synthesized or implemented manually. In this case, it should tell you that the property retains what's assigned to it, which is why the view controller is not deallocated while it's still being used. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Beginner Question Re: Memory Management
On 23/06/2009, at 2:31 PM, WT wrote: [textFieldPreviousContent release]; textFieldPreviousContent = [textField.text retain]; This is not a safe pattern anyway (though it's not the same as the discussion you raised). In isolation, suppose that the previous text and the current text are the same object. If no-one else is retaining it, then the first line will deallocate it, the second will send a message to a now deallocated object, probably crashing. You get away with it in this case because something else *is* retaining the text, so the deallocation doesn't occur. But you shouldn't be relying on this - you'll get fewer bugs if you treat your memory management situations in isolation. so do something like this: NSString* temp = [[textField.text] retain]; [previousText release]; previousText = temp; Even better is to make the setting of the previous text a standalone method, encapsulating this approach (or make it a retained property and synthesise it, as you did). That way the ad-hoc memory management done inline with other code can be removed, and isolated into one, correct, method. --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: Beginner Question Re: Memory Management
On Jun 23, 2009, at 7:15 AM, Graham Cox wrote: On 23/06/2009, at 2:31 PM, WT wrote: [textFieldPreviousContent release]; textFieldPreviousContent = [textField.text retain]; This is not a safe pattern anyway (though it's not the same as the discussion you raised). In isolation, suppose that the previous text and the current text are the same object. If no-one else is retaining it, then the first line will deallocate it, the second will send a message to a now deallocated object, probably crashing. You get away with it in this case because something else *is* retaining the text, so the deallocation doesn't occur. But you shouldn't be relying on this - you'll get fewer bugs if you treat your memory management situations in isolation. Excellent points. so do something like this: NSString* temp = [[textField.text] retain]; [previousText release]; previousText = temp; Or if (oldValue != newValue) { [oldValue release]; oldValue = [newValue retain]; } Even better is to make the setting of the previous text a standalone method, encapsulating this approach (or make it a retained property and synthesise it, as you did). That way the ad-hoc memory management done inline with other code can be removed, and isolated into one, correct, method. Yes, and that's why I'm using properties more and more often. I find it distracting to have to stop my train of thought just to decide on how I should manage memory at a particular section of code. I'd rather make that decision only once, at the time I declare the property. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Beginner Question Re: Memory Management
On Jun 22, 2009, at 21:31, WT wrote: So, to all beginners out there, whenever you define a property, remember always to refer to it, in its own class, by self.property - at least when setting its value. It may be ok (depending on what you're doing) to refer to it simply by property when *getting* its value, but if the property is backed by an instance variable that is an object (rather than a scalar type), it's *essential* that you refer to it by prepending self when *setting* its value, or you'll not be doing the memory management that you think you're doing. I understand what you're trying to say here, but I'd urge you *never* to describe it in these terms. You say, explicitly, that it's a question of use the the correct way (out of a choice of 2 ways) to refer to a property. But that's not so. There's *one* way to refer to a property, and *one* way to refer to an instance variable. The fact that they may have similar names is purely an accident. (Well, not an accident, generally, but a convenience.) I'd say it's really, really, really important for beginners to realize that properties and the instance variables that back them are different, syntactically and semantically. Outside a class implementation, the property is the only thing that's available (or should be, since making instance variables public is usually a Bad Idea), so clients of the class don't have to think about it. Inside a class implementation, however, you need to decide *every time you refer to a value* whether you mean the property value or the instance variable value. You need to decide that even when you *know* that the two values are currently the same, because in a future piece of the implementation you may break the congruence, but you don't want to break the existing code if you can help it. It's not even about memory management. There's often memory management involved when using a property's accessors, but there may also be memory management involved when dealing with an instance variable in other contexts. FWIW. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 with NSValueTransformer, NSTableView and NSAttributedString
On Mon, Jun 22, 2009 at 9:12 PM, Jim Correiajim.corr...@pobox.com wrote: The documentation for the value binding of NSTableView says that NSString and NSNumber are the supported value types. I do not see where you're finding this. The bindings documentation says: The object should be suitable for the passing to setObjectValue. Maybe it's in the conceptual docs? Which is a shame, really. If I were designing this API, I would add a method to NSCell called -setNumberValue:, which takes an NSNumber instance and uses the cell's attached number formatter to convert it into a string, which it then passes to -[self setStringValue:] (lack of an attached number formatter would raise an exception.) Then I'd add an option to the value binding that allowed the user to choose between the binding invoking -setObjectValue:, -setStringValue:, -setAttributedStringValue:, and -setNumberValue:. But I didn't design the API. All I can do is file a radar. Luckily, you can too. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Amount of Arguments per Method
I actually had to use that method once in one of my very first Cocoa apps. My personal rule of thumb for my own code is, when a method I write has more than 3 parameters I start to suspect there's a more OO way of breaking up the problem. Huge argument lists indicate a procedural design, and really feel wrong in the OO mental model. Rob On Jun 22, 2009, at 1:03 AM, Roland King wrote: This still the longest one or has Apple outdone themselves since? 11 args, you really wouldn't want much more than this. - (id )initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel : WT wrote: On Jun 22, 2009, at 8:05 AM, Chunk 1978 wrote: clearly simplicity is important, but i'd like to know if there is a limit for the amount of arguments which a method can handle? I don't know if there's an upper limit, but I don't recall ever writing a method with more than 5 or 6 arguments. When I feel inclined to do otherwise, it typically means that there's a flaw in my design. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Beginner Question Re: Memory Management
Objective-C 2.0 supports not only property getter/setter synthesis, but instance variable synthesis. This means that you do not even have to declare the instance variable. As long as the property is defined correctly, the instance variable (and the getter/setter) will be created for you. I prefer not defining the instance variable at all, that way there's no confusion about the access; you always use the synthesized getter/setter. UNFORTUNATELY, the iPhone Simulator does not support instance variable synthesis (at least it didn't in 2.x, maybe that changed in 3.0). This means that you cannot have code that works on both iPhone and Simulator if you want to take advantage of the instance variable synthesis. - Eric On Jun 23, 2009, at 1:29 AM, Quincey Morris wrote: On Jun 22, 2009, at 21:31, WT wrote: So, to all beginners out there, whenever you define a property, remember always to refer to it, in its own class, by self.property - at least when setting its value. It may be ok (depending on what you're doing) to refer to it simply by property when *getting* its value, but if the property is backed by an instance variable that is an object (rather than a scalar type), it's *essential* that you refer to it by prepending self when *setting* its value, or you'll not be doing the memory management that you think you're doing. I understand what you're trying to say here, but I'd urge you *never* to describe it in these terms. You say, explicitly, that it's a question of use the the correct way (out of a choice of 2 ways) to refer to a property. But that's not so. There's *one* way to refer to a property, and *one* way to refer to an instance variable. The fact that they may have similar names is purely an accident. (Well, not an accident, generally, but a convenience.) I'd say it's really, really, really important for beginners to realize that properties and the instance variables that back them are different, syntactically and semantically. Outside a class implementation, the property is the only thing that's available (or should be, since making instance variables public is usually a Bad Idea), so clients of the class don't have to think about it. Inside a class implementation, however, you need to decide *every time you refer to a value* whether you mean the property value or the instance variable value. You need to decide that even when you *know* that the two values are currently the same, because in a future piece of the implementation you may break the congruence, but you don't want to break the existing code if you can help it. It's not even about memory management. There's often memory management involved when using a property's accessors, but there may also be memory management involved when dealing with an instance variable in other contexts. FWIW. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/zmonster%40mac.com This email sent to zmons...@mac.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
Re: Amount of Arguments per Method
There should be whitespace automatically generated between the necessary bits. If you'd rather see it the other way (and I can see an argument for that), hit up bugreporter or feedback. Devpubs listens, and our delivery team (the folks that take the XML and output it to the various formats) ROCK. On 2009-06-22, at 11:03 AM, WT wrote: I mean, seriously, how easy is it to read - (id) outputImageProviderFromBufferWithPixelFormat:(NSString*) format pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height baseAddress:(const void*)baseAddress bytesPerRow:(NSUInteger) rowBytes releaseCallback:(QCPlugInBufferReleaseCallback)callback releaseContext:(void*)context colorSpace:(CGColorSpaceRef)colorSpace shouldColorMatch:(BOOL)colorMatch (copied directly from the documentation link Andy provided) compared to - (id) outputImageProviderFromBufferWithPixelFormat: (NSString*) format pixelsWide: (NSUInteger) width pixelsHigh: (NSUInteger) height baseAddress: (const void*) baseAddress bytesPerRow: (NSUInteger) rowBytes releaseCallback: (QCPlugInBufferReleaseCallback) callback releaseContext: (void*) context colorSpace: (CGColorSpaceRef) colorSpace shouldColorMatch: (BOOL) colorMatch ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Beginner Question Re: Memory Management
On Jun 23, 2009, at 7:29 AM, Quincey Morris wrote: On Jun 22, 2009, at 21:31, WT wrote: So, to all beginners out there, whenever you define a property, remember always to refer to it, in its own class, by self.property - at least when setting its value. It may be ok (depending on what you're doing) to refer to it simply by property when *getting* its value, but if the property is backed by an instance variable that is an object (rather than a scalar type), it's *essential* that you refer to it by prepending self when *setting* its value, or you'll not be doing the memory management that you think you're doing. I understand what you're trying to say here, but I'd urge you *never* to describe it in these terms. You say, explicitly, that it's a question of use the the correct way (out of a choice of 2 ways) to refer to a property. But that's not so. There's *one* way to refer to a property, and *one* way to refer to an instance variable. The fact that they may have similar names is purely an accident. (Well, not an accident, generally, but a convenience.) I'd say it's really, really, really important for beginners to realize that properties and the instance variables that back them are different, syntactically and semantically. Outside a class implementation, the property is the only thing that's available (or should be, since making instance variables public is usually a Bad Idea), so clients of the class don't have to think about it. Inside a class implementation, however, you need to decide *every time you refer to a value* whether you mean the property value or the instance variable value. You need to decide that even when you *know* that the two values are currently the same, because in a future piece of the implementation you may break the congruence, but you don't want to break the existing code if you can help it. It's not even about memory management. There's often memory management involved when using a property's accessors, but there may also be memory management involved when dealing with an instance variable in other contexts. FWIW. Hi Quincey, You're absolutely correct and I should have been more careful in the way I said what I intended to say. I am myself still getting used to the idea that properties don't have to be backed by instance variables, which clearly shows that they're distinct concepts. I find it oddly difficult to remember that, even though I understand the distinction. Thanks for the correction. Wagner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 with NSValueTransformer, NSTableView and NSAttributedString
Hello, On Mon, Jun 22, 2009 at 9:12 PM, Jim Correiajim.corr...@pobox.com wrote: The documentation for the value binding of NSTableView says that NSString and NSNumber are the supported value types. I do not see where you're finding this. The bindings documentation says: The object should be suitable for the passing to setObjectValue. Maybe it's in the conceptual docs? Unfortunately, he is right. In Value Bindings section we can read about value property: An NSString or NSNumber that is displayed as the content of the NSTextFieldCell. I even tried to subclass NSTextFieldCell and redefine setObjectValue: method -- nothing, the values are already NSCFString, not NSAttriubtedString, so I shall just drop NSArrayController and write DataSource in code. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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