Re: six things I wasn't able to do with Cocoa
On 2010-05-28, at 12:02 PM, cocoa-dev-requ...@lists.apple.com wrote: > i've tried everything -- how do other people get movie posters and/or grab > movie frames? With classic QuickTime if there was no poster frame specifically set in the movie QuickTime would reliably return the first frame. With QuickTimeKit that is ... inconsistent. Safest to just grab the first frame yourself. As for capturing frames, here's the I believe currently recommended way to do it: NSDictionary *imageAttrs = [NSDictionary dictionaryWithObjectsAndKeys: QTMovieFrameImageTypeNSImage, QTMovieFrameImageType, [NSArray arrayWithObject:@"NSBitmapImageRep"], QTMovieFrameImageRepresentationsType, [NSNumber numberWithBool:YES], QTMovieFrameImageDeinterlaceFields, [NSNumber numberWithBool:YES], QTMovieFrameImageHighQuality, [NSNumber numberWithBool:YES], QTMovieFrameImageSingleField, nil ]; QTTime captureTime = [0 .. self.movie.duration]; NSError *captureError = nil; NSImage *captureFullFrame = [self.movie frameImageAtTime:captureTime withAttributes:imageAttrs error:&captureError ]; That allows for a variety of other image types besides QTMovieFrameImageTypeNSImage, but is QuickTime 7.2 dependent. If you need older version compatibility, use - (NSImage *)frameImageAtTime:(QTTime)time; Either way, these should only be called on the main thread. Theoretically you can detach movies and move them around between threads, but you have a good chance of running into issues doing so, particularly if you're working with QTKit captured movies; something about the rendering context I think, although the details are old enough to be kinda fuzzy now. Safer to just call performSelectorOnMainThread: to get each grabbed frame if you've got a background renderer or suchlike, I'd say. -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ "...the variable PI can be given that value [3.141592653589793] with a DATA statement. This simplifies the modifying of the program, should the value of PI ever change." -- SDS Sigma series Fortran manual ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom Fonts in UI Webview
On 15-Sep-09, at 6:57 PM, cocoa-dev-requ...@lists.apple.com wrote: You can do custom fonts on the iPhone, but you cannot use system controls to draw with them. You have to draw yourself each glyph. Sure you can. It's just tricky. http://www.alexcurylo.com/blog/2009/05/29/custom-fonts/ -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ "If you can't annoy somebody, there's little point in writing." -- Kingsley Amis ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Showing more warnings possible in Xcode?
On 30-May-09, at 6:04 PM, Kyle Sluder wrote: You also have the "unused" attribute: http://gcc.gnu.org/onlinedocs/gcc-3.1.1/gcc/Variable-Attributes.html --Kyle Sluder That's out because I commonly have to share code with Windows compilers. ... although much less commonly now that I'm about 80% focused on iPhone work, which makes being so even *more* joyous! -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ "First time I saw a spiral dive was you at Woodside in September. I thought you were friggin' nuts." -- Bruce McGuigan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Showing more warnings possible in Xcode?
On 30-May-09, at 5:31 PM, Eric Hermanson wrote: Thanks for that list. Regarding your choice of GCC_WARN_UNUSED_PARAMETER = YES How do you get around the fact that you often get warnings for delegate methods you are forced to implement where you don't ever use given parameter(s)? Do you use a "#pragma GCC diagnostic ignored ..." to skip that warning for the given file, or do you reference all parameters in some bogus way to avoid the warning, or...? - Eric Reference. Specifically, (void)parameter; That works in every C-based compiler on every platform, and doesn't muck up block quoting/unquoting, which makes it the one true correct way far as I'm concerned. -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ "I suddenly found myself writing, from scratch, an ATM back-end that's used by a growing number of banks... now I get nervous using ATMs." -- Greg Weston ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Showing more warnings possible in Xcode?
On 30-May-09, at 8:14 AM, cocoa-dev-requ...@lists.apple.com wrote: Is there a way to tune xCode so that it warns you of these types of potential problems (and more)? Here's what I've got in my standard base .xcconfig right now. // C Only Warnings TW_GENERAL_OTHER_CFLAGS = -Wdiv-by-zero -Wbad-function-cast -Wnested- externs -Wold-style-definition // C++ Only Warnings TW_GENERAL_OTHER_CPLUSPLUSFLAGS = -Wabi -Wctor-dtor-privacy -Wstrict- null-sentinel -Wsign-promo GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES // General C/C++/ObjC/ObjC++ warnings TW_GENERAL_WARNING_CFLAGS1 = -Wall -Wendif-labels -Winvalid-pch - Wformat=2 -Wmissing-format-attribute -Wwrite-strings -Wstack-protector -Wstrict-aliasing=2 TW_GENERAL_WARNING_CFLAGS2 = -Wpacked -Wmissing-field-initializers TW_GENERAL_WARNING_CFLAGS3 = -Wextra -Wpointer-arith -Wdisabled- optimization -Wfloat-equal TW_GENERAL_WARNING_CFLAGS = $(TW_GENERAL_WARNING_CFLAGS1) $ (TW_GENERAL_WARNING_CFLAGS2) $(TW_GENERAL_WARNING_CFLAGS3) // GCC_WARN_UNINITIALIZED_AUTOS is defined in the release/debug xcconfigs. GCC_WARN_CHECK_SWITCH_STATEMENTS = YES GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES GCC_WARN_ABOUT_MISSING_NEWLINE = YES GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES GCC_WARN_ABOUT_RETURN_TYPE = YES GCC_WARN_MISSING_PARENTHESES = YES GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES GCC_WARN_UNKNOWN_PRAGMAS = YES GCC_WARN_UNUSED_LABEL = YES GCC_WARN_UNUSED_FUNCTION = YES GCC_WARN_UNUSED_VALUE = YES GCC_WARN_UNUSED_VARIABLE = YES GCC_WARN_UNUSED_PARAMETER = YES GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES GCC_WARN_64_TO_32_BIT_CONVERSION = YES GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES GCC_WARN_SHADOW = YES GCC_WARN_SIGN_COMPARE = YES GCC_WARN_PEDANTIC = NO // doesn't even like #import GCC_WARN_PROTOTYPE_CONVERSION = NO // may catch implicit casts, but lots of noise ... like YES and NO for BOOL GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = NO // merge flag/path settings with possible previous configuration file flag settings WARNING_CFLAGS = $(inherited) $(TW_GENERAL_WARNING_CFLAGS) $ (TW_CONFIGURATION_WARNING_CFLAGS) OTHER_CFLAGS = $(inherited) $(TW_GENERAL_OTHER_CFLAGS) $ (TW_CONFIGURATION_OTHER_CFLAGS) // note that OTHER_CPLUSPLUSFLAGS does *not* inherit -- default is $ (OTHER_CFLAGS) and we want these separated OTHER_CPLUSPLUSFLAGS = $(TW_GENERAL_OTHER_CPLUSPLUSFLAGS) $ (TW_CONFIGURATION_OTHER_CPLUSPLUSFLAGS) GCC_PREPROCESSOR_DEFINITIONS = $(inherited) $ (TW_CONFIGURATION_GCC_PREPROCESSOR_DEFINITIONS) OTHER_LDFLAGS = $(inherited) $(TW_CONFIGURATION_OTHER_LDFLAGS) A standard debug .xcconfig adds TW_CONFIGURATION_GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 GCC_OPTIMIZATION_LEVEL = 0 GCC_WARN_UNINITIALIZED_AUTOS = NO and a standard release .xcconfig TW_CONFIGURATION_GCC_PREPROCESSOR_DEFINITIONS = NDEBUG=1 GCC_OPTIMIZATION_LEVEL = s GCC_WARN_UNINITIALIZED_AUTOS = YES GCC_TREAT_WARNINGS_AS_ERRORS = YES // -Wno-unused-parameter needed because of "unused parameter 'value'" garbage from @synthesize in gcc 4.0 // init-self can only be turned on when optimizations are on TW_CONFIGURATION_WARNING_CFLAGS = -Wno-unused-parameter -Winit-self I find that basically nothing ever slips through this level of code hygiene. YMMV. If you wish to be even more OCD about it than this, peruse http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html http://gcc.gnu.org/onlinedocs/gcc/Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html The strategy above is cribbed pretty much directly from the Google Toolbox for Mac .xcconfig stuff, so you may want to grab the latest version of that as well and see if they've made any significant updates since I put this together. -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ You know you've had a good night when you wake up and someone's outlining you in chalk. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSString initWithFormat and stringWith
On 27-May-09, at 8:41 AM, cocoa-dev-requ...@lists.apple.com wrote: Well I am trying to find where is my mistake, since sometimes my application crashes and I am quite (99.9%) sure that I am releasing a object that shouldn't be. Any ideas how to find such a bug? As long as the crashes happen when you're running under the debugger, if you set in Xcode the five global breakpoints I list here http://www.alexcurylo.com/blog/2008/11/13/tip-debugging-exceptions/ you'll catch every fatal occurrence (every likely fatal occurrence, anyways...) at the moment it occurs. Deducing the probable cause is then *much* less challenging. Downright trivial, generally. -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ Programming is like sex... One mistake and you support it the rest of your 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
Re: [iPhone] UITableViewController headache
On 11-May-09, at 6:21 AM, cocoa-dev-requ...@lists.apple.com wrote: UITableViewController is mostly a convenience class that stubs the required protocol for UITableView when you create a new subclass using Xcode. It doesn't really matter what controller class you use if you implement the protocol and set the delegate and data source Oh, there's other stuff that UITableViewController works out for you as well. For starters, Apple will reject your application (at least, it rejected one of mine) if it doesn't disable an existing selection when shown. UITableView sorts that for you instead of having to check yourself. Less trivially, if you want to edit some text in a cell at the bottom of the screen, UITableView will magically make the text field scroll up above the keyboard and put itself away afterwards. Sorting that out yourself to look good manually takes a bit of work. And so forth. So it does behoove you to use it if appropriate. Now, if I could just get it to handle a background image nicely... -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ "When I met you, it was a little like meeting Jubal from _Stranger In A Strange Land_. I *think* that's a compliment..." -- Dominique ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Converting NSString to C++ std::string
On 8-May-09, at 8:55 AM, cocoa-dev-requ...@lists.apple.com wrote: mycppstring = std::string([[myNSTextField stringValue] UTF8String]); But it keeps crashing. What's the recommended way? I have no idea, but it works for me to simply assign it without the constructor. Why, here's an example in the file I'm working on right now, fancy that: - (BOOL)willInterceptURL:(NSURL*)url { // copied from the Carbon version since that works std::string urlstring = [[url resourceSpecifier] UTF8String]; ... } I've done the same thing all sorts of places grafting shiny Cocoa stuff onto old C++ code that works and never noticed any issues. -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ "I guess it's pretty bad when you don't start using a new API until it's been deprecated." -- Nick Nallick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Proper NSOperation isCancelled handling
On 13-Feb-09, at 12:31 AM, Ken Thomases wrote: Why are you overriding it? The -cancel method is not supposed to actively bring the operation to a stop. It's only supposed to set a flag. The operation's work methods (-start, -main, and whatever they call) should be periodically checking the -isCancelled property and, if it's set, gracefully bring their work to an end. Because all -start does is initiate an NSURLConnection. If it's failing to connect or whatever, I want the operation to stop when the user says so, not whenever -didFailWithError gets around to being called. -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ "You definitely have some kind of Zen thing going for you." -- Craig Joseph Huxtable ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Proper NSOperation isCancelled handling
So I'm a bit confused about how my NSOperation subclass should implement the cancel method. The documentation says that "isCancelled" is a KVO-compliant property. So I figured that calling [super cancel] ought to take care of that. But it doesn't. Doesn't appear to do anything, actually, whether I call it or not [self isCancelled] still returns the expected value in my -start method, but no apparent isCancelled KVO notification is generated. So I decided to implement my cancel method as - (void)cancel { // if we have started the operation, cancel it if (self.downloadConnection) [self.downloadConnection cancel]; // this generates isExecuting and isFinished notifications as needed [self sendKVONotifications:nil]; // ok ... what should we do about the isCancelled property? [self willChangeValueForKey:@"isCancelled"]; [super cancel]; [self didChangeValueForKey:@"isCancelled"]; } ... which just doesn't seem quite right. What's the correct thing to do? -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ "I just can't accept that 24 reserves, 3 hospitalizations and one fatality are in any way acceptable for what should be the premier event on the paragliding calendar." -- Mark Hayman ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What is the equivalent of a C++ pure-virtual function in Objective-C?
On 11-Jan-09, at 6:32 PM, cocoa-dev-requ...@lists.apple.com wrote: Still, anyone wants to give me some guidance on protocols and how they should be employed, I'm all ears (eyes). Well, here's one I just employed. Define it like this @protocol PAImageCollection @required - (int)collectionCount; - (UINavigationController *)collectionController; - (NSString *)fileForIndex:(int)collectionIndex; - (BOOL)canRemove; @end and then any class you declare like this @interface FavoritesTableViewCell : UITableViewCell will throw up a compile error if it doesn't match everything under @required in the protocol. And to keep track of a derived instance as a variable/argument, something like id collection; does the trick. That should pretty much cover any sane use of pure virtual functions you have in mind. -- Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/ "I misjudged you Alex; you're a @#$%!!, but you're a consistent, smart $...@%^!!, and the kind of @$^#&$!! I can #...@*&!! respect." -- John G. Spragge ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Static text over an image
On 30-Oct-08, at 8:01 AM, [EMAIL PROTECTED] wrote: which is to just programmatically reverse the order on load. That smoothed development considerably. Pardon my ignorance (still learning Cocoa) but can you point to me what class/method to use for that? The exact details escape me now, but I seem to recall that since the order of -subviews was not completely deterministic depending on what the latest mucking about in the nib had been I resorted to something like NSView** putTheseInFront = { _ibOverlay1, _ibTextField2, ... nil } while (*putTheseInFront) { NSView* itsSuperview = [*putTheseInFront superview]; [[*putTheseInFront retain] removeFromSuperview]; [itsSuperview addSubview:*putTheseInFront)]; putTheseInFront++; } Not exactly scalable, but it sorted the workflow at hand nicely with no apparent runtime delay. -- Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/ "I am so honoured to know you, the first glider off Eagle. That is s cool." -- Martina Lang ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
RE: Re: Static text over an image
On 30-Oct-08, at 5:42 AM, [EMAIL PROTECTED] wrote: I've seen this happen *every* time in IB if the items in question are within an NSView. It was driving me crazy for a while until I figured out (completely by accident) that the order has to be reversed when you're setting up the NIB/XIB file for it to work correctly. It's a real PITA because to see and edit the text which you want, eventually, to appear on top of the image, you constantly have to select the image/text and go the Layout menu and move it back and forward as required, and then remember to move the text back behind the image before you save and rebuild your project. Or you could do what I did when I had a project this was an intense annoyance for what with the several-times-a-day client updates, which is to just programmatically reverse the order on load. That smoothed development considerably. -- Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/ There are two great secrets to success in life. The first is to not tell everything you know. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: alternative to flash
On 16-Jul-08, at 7:33 PM, [EMAIL PROTECTED] wrote: If there's no Flash on the iphone, And we all can daily sing hosannas of praise for that! I'm just looking to go to a URL and an animation fills the screen and is playing, no quicktime control bar or anything and preferably vector graphics rather than video. I tried an animated GIF but that doesn't fill the screen on the iphone, and worse it doesn't play. For animated GIF type stuff except better, the tag is your friend. http://en.wikipedia.org/wiki/Canvas_(HTML_element) ... one alternative would be to write an iphone app which receives vector info and reproduces the animation with quartz or opengl graphics. But that's like writing a whole flash- player type thing and maybe there's something like that already? Indeed there would be! It would be the infinitely superior alternative to Flash that Adobe came up with before they decided that it was easier to buy Macromedia than beat them; and yea, it shalt be called "SVG". http://en.wikipedia.org/wiki/Scalable_Vector_Graphics Don't know if support for SVG made it to the currently shipping Mobile Safari, but you should be able to google up some test pages without any difficulty. If it's not there now, it'll get there sooner or later I don't doubt. In the meantime, should you be impatient, I don't doubt that an SVG -> CoreGraphics translator would be pretty straightforward to write in Cocoa of any flavour. Speaking from near-complete ignorance there, of course. -- Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/ "Dude ... you are the man! I wish the guys writing our PC version could be as efficient as you!" -- Jason Carter, autolycus.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: [Ann] DMG Canvas
On 22-Apr-08, at 12:03 PM, [EMAIL PROTECTED] wrote: Looks nice. Care to comment why a FileStorm user might want to switch? :) Because I keep running into annoying bugs in FileStorm's AppleScript implementation, and the dmgcanvas command line tool might integrate into my workflow better? -- Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/ Optimists see the glass half full. Pessimists see the glass half empty. Engineers see that the glass is twice as big as it needs to be. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Running a "Choose Template" Sheet
On 14-Apr-08, at 2:01 AM, [EMAIL PROTECTED] wrote: I've researched it a bit and found an app that subclasses NSDocumentController and overrides openUntitledDocumentAndDisplay:error: method and runs the sheet there. Is this the correct place to be running the sheet? Thanks! Well, I've got something similar in that my document needs a source movie, and I simply ovverrode -showWindows. - (void)showWindows { [super showWindows]; NSURL* fileURL = [self fileURL]; if (!fileURL) { // first show of a new empty document -- pick a source movie [self pickSourceMovie:nil]; } } However, since I can't even write -dealloc methods using the correct language, as you may have noticed in the ivar thread, one should certainly not take this happening to work for me so far as any kind of proof of correctness. -- Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/ Apparently my purpose in life is to serve as a warning to others. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Stale Objective-C object pointer detection
On 13-Apr-08, at 2:15 PM, Greg Titus wrote: You want to just leave the pointer alone and turn on NSZombiesEnabled when you run your app. Huh. I'd actually stumbled across NSDebug.h before, but the documentation at the top "WARNING: Unsupported API. This module contains material that is only partially supported -- if at all. Do not depend on the existance of any of these symbols in your code in future releases of this software..." sounded to to me an awful lot like "ignore this header". Righty then, now I know better. Thanks again! -- Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/ You know you've had a good night when you wake up and someone's outlining you in chalk. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Stale Objective-C object pointer detection
On 13-Apr-08, at 1:06 PM, Greg Titus wrote: The big difference is that in Objective-C, trying to send a message to nil results in a no-op instead of an access violation, so your defensive C++ practice is actually going to tend to mask those same errors in Objective-C and make them harder to track down. *smacks forehead* Yeah, now that I actually think about it, that would be the effect, wouldn't it. Just hadn't made the connection up 'til now, somehow. Thank you. OK, then, what would an equivalently useful value to set a released Objective-C object pointer/ivar to in order to cause any subsequent access of it to stop the program immediately? 0xDEADBEEF perhaps? -- Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/ Programming is like sex... One mistake and you support it the rest of your 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 [EMAIL PROTECTED]
Re: Cocoa-dev Digest, Vol 5, Issue 600
On 13-Apr-08, at 12:02 PM, [EMAIL PROTECTED] wrote: why is it necessary to set the variable appointments (for instance) to nil in this example? Should we do this for each variable? When have we to do this? IMO, it's totally unnecessary. Seems to be a cargo culting thing more than anything else. No, I can personally assure you that exact practice has led me to finding many dozens -- quite possibly several hundreds by now actually -- of 'calling methods of a deleted object' type bugs in C++ code, particularly game code I port from Windows, which somehow always seems to have been written by semi-literate chimpanzees on crack. And perhaps I am unfair to the chimpanzees here. It does seem that class of problem is much less likely to arise with Objective-C object references (I'm still fairly new to this Cocoa thing) but as long as I still work with any C++ objects or raw pointers, I'm going to consider that "set things up so anything accessing this object's memory after I'm done with it promptly causes an access violation" is a valuable habit -- nay, essential practice -- in properly defensive programming. Autoptrs and the like help, but they're not foolproof. Stands to reason that the retain/[auto]release paradigm isn't completely foolproof either, although it does seem pretty resistant to commonly accepted levels of foolery so far. -- Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/ There are two great secrets to success in life. The first is to not tell everything you know. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]