iPad 5.0 Simulator problem
The content of this link tells it all: http://www.iphonedevsdk.com/forum/iphone-sdk-development/98722-ipad-simulator-its-if-nothing-connected.html Of great importance is my reply which narrows the problem to just running the iPad 5.0 Simulator. All others run fine: iPhone 4.3 and 5.0 Simulators iPad 4.3 Simulator These guys run super, but not the iPad 5.0 John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Atta Boys, 4 bags-full
The purpose of this document is to give thunderous applause to some very patient folk. But, before I crank up the volume, I would like to share with you a small amount of history. I am within a week of finishing my Universal app, "Love Song to America" whose purpose is to support all our military veterans from World War II, Korea, Vietnam and up to and including Iraq and Afghanistan. Every last one of them, living and deceased, are true heroes and deserve all the applause and support we can generate. The on-going process of submitting and re-submitting and re-re-submitting my mobile app to the App Store has been very, very painful and I wanted to share a glimpse of it. I have found that all the rules in the App Guidelines manual are to describe all the official DO's and DO NOT's. The unspoken list of DO's and DON'Ts are what I am concerned about. As a strictly hypothetical example, it is entirely possible that a unspoken rule is to never, ever have need to use the More Nav Controller in a UITabController app. It is clear that no written rule stipulates that, but politically its use may be politically Incorrect. When I submitted the app the first couple of times (without a TabBar Item pertaining to Military Support Agencies), their response essentially stated my app was nothing but a glorified web page. They were almost correct, but I countered that there are books and movie-equivalents of books. "Gone With the Wind", "Ivanhoe", "Sound of Music", and "Secretariat" come to mind. Did I forget "Cinderella" and "Snow White"? They said, in effect, "Nice Try". Their official comment was "Make Love Song more interactive". "Okay, specifically how or what do you recommend?" "Mr Love, just make it more interactive than it is". What's wrong with this picture? I just can't deal with this, so I scoured the web and found similar experiences of many, many other developers. I finally talked with a real human in the App Store and it was like prying wisdom teeth, but I FINALLY extracted his suggestion about the Support Agencies so veterans on the road could find out phone numbers and names to contact in case disaster struck. That idea was really, really awesome so I incorporated it … my mind was literally wrapped up in Protocols and Delegates, I didn't see the forest. But, I had to literally browbeat him to extract the idea. What's wrong with this picture? In addition, I tried and tried to get an App Store rep to tell me how to de-pixelate all my images (one of their complaints leading to rejection). Give me the name of a specific piece of software and I'll try to use it (praying that it wasn't PhotoShop = $$$). Literally, silence. I then called directly the Apple Business section for Developers, talked to some young man who apparently took pity on me and essentially said "go to this web site and beg". The web site was Apple's Dev Support forum. I did that, and the flood gates opened and that is how I met lots of human beings with a heart. Now, that 8-minute phone call to Apple Business, what a God-send … spent hours with the App Store … but just a few minutes with Apple Business and Manna from Heaven. Do I have to ask what's wrong with this picture? Manna in the form of: Sandy McGuffog Bill Kunz pbear Kevin Messina All these guys displayed the patience of a million saints. Of extraordinary note is Kevin who came to the table with 20+ years as a programmer and has his own Digital Video Studio. Kevin taught me so darn much about his-res graphics and even more about Xcode. For example, he talked about png-crush (I'm embarrassed to ask, so I'll look around for its meaning). He taught me about making the project settings independent of a particular directory, in short, not hard-wiring the location. Let's hear a ear-splitting round of applause for these 4 guys … I didn't hear you … oh, come on, you can do better than that! That's better. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
I think I'm ready to throw in the towel - I really need help here
I've got my universal iApp (entitled "Love Song to America") all ready (started in Sept, 2011), except I've got quite a few .png graphics whose x2 version are very, very pixelated. Furthermore, it will never get to the app store because my app has been rejected because of the pixelation I've just mentioned. I do coding and have learned a helluva lot from you over the years (notably Graham Cox). I have next to zero skill using Photoshop, etc. Most of my graphics are from screen shots that are more than ample for my website: http://webpages.charter.net/jolove/usa For my UITabBar icons I have used the free-version of the famous glyph icons and so I'm good for 9 out the total of 12 UITabBar icons. For the png graphics on my many UIView's, however, it is clear to me that these graphics almost need total re-building for my universal app. Yes, my app will be free; however, within reason, I am very willing to pay someone for such efforts. The help I seek comes in 2 varieties: (1) John, use this graphics app, do these 3-or-whatever things on your png graphics and bingo! -- OR -- (2) John, for $___, I will do this magic for you. John Love USAF, Major (Retired: 1961-1981, including Vietnam) 906-249-1120 jol...@charter.net Marquette, Michigan (Upper Peninsula) John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Multiple? Call-back methods for AVPlayer
Using AVPlayer for streamed audio, when I select a audio, I call [mySong addObserver:self forKeyPath:@"status" options:0 context:nil] I then use observeValueForKeyPath: ofObject: change: context: to observe the [ofObject status] for the standard three values: AVPlayerStatusReadyToPlay, AVPlayerStatusUnknown, and AVPlayerStatusFailed and call the button's -setBackgroundImage ("Stop" version) when AVPlayerStatusReadyToPlay. My question is: Do I have to set up a 2nd KVO call-back method to monitor whether the selected audio has ended naturally? I need to know when the audio is finished so I can call the set the button's backgroundImage to the "Play" variety. For example, according to the AV Foundation Programming Guide, I'm supposed to use: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[player currentItem]]; Is there any way of using just one call-back for both PlayerStatus and DidPlayToEnd? Someone else suggested having each method call a 3rd common one … but if I do that, I might as well stay with 2. I sure would like to just use [NSNotificationCenter defaultCenter] addObserver: … and combine in it my [mySong addObserver: method. Thanks bunches. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
playing a streamed audio file
I discovered that I cannot use the AVAudioPlayer methods for playing a streamed audio file because this class only supports embedded audio (file:// links). OK, so I use the UIViewController method: - presentMoviePlayerViewControllerAnimated:myMPMoviePlayerController That works well, except that I have the lyrics showing in my UIView and this method totally hides the lyrics and shows the usual ((Q)) Quicktime logo and the Done button. So, instead I call: [moviePlayerController_ setControlStyle:MPMovieControlStyleNone]; and the lyrics continue to show, with the audio playing in the background as I want, but then I lose total control of audio playback. How do I show the lyrics and retain audio playback control? The docs state that if I used: [moviePlayerController_ setControlStyle:MPMovieControlStyleEmbedded]; that the controls for an embedded view are displayed ... but they are not. Do I mess with myMoviePlayerController.view.frame .. for the macOS, this would translate to a floating window, but for iOS I would like: -- || || || |scrollable | |lyrics here | || || || |-| || |fixed | | controls here | || -- Thanks, John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Checking for Internet Connection in an iApp
I really have been just about everywhere, e.g., stack overflow.com and iphonedevsdk.com and have really learned a lot … unfortunately, what I have learned is that there are opposing opinions on how to best check for an active internet connection with respect to effectiveness and speed. Such comments such as "You're not testing for what you think you are!". Considering my lack of success with Apple's Reachability Code, I have found that the asynchronous call to: NSString *urlString = @"myURL"; NSURL *theURL = [NSURL URLWithString:urlString]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theURL]; NSURLConnection *theConnection = [NSURLConnection connectionWithRequest:theRequest delegate:self]; which does hook up with the delegate method: - (void )connection:(NSURLConnection *)connection didFailWithError:(NSError *)error This magic does indeed work, but I could fry a couple of eggs while I'm waiting and I know that the iApp folks will bounce me for that delay. Maybe my method of "taking my connection" down may be in error -- I am simply pushing off the "standby" button on my cable modem -- I have also just unplugged the modem. With respect to my attempts in using Apple's Reachability code: Here are the two properties: Reachability *itsInternetReachability; BOOL itsInternetActive; This method is called when I start my app: - (void )startObserveInternetConnection { self.itsInternetReachability = [Reachability reachabilityForInternetConnection]; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter addObserver:self selector:@selector(pingInternetConnection:) name:kReachabilityChangedNotification object:internetReachability_]; [internetReachability_ startNotifier]; } - (void )pingInternetConnection:(NSNotification *)sentNotification { if ([[sentNotification object] isKindOfClass:[Reachability class]]) { NetworkStatus internetStatus = [self.itsInternetReachability currentReachabilityStatus]; self.itsInternetActive = (internetStatus != NotReachable); } else { self.itsInternetActive = NO; } } Isn't the function of -startNotifier to enable the callback method to be continuously called within the main RunLoop? Yet the only time I can get this callback method to be called is if I call NSNotificationCenter's -postNotificationName elsewhere in the code?? -[notificationCenter postNotificationName:kReachabilityChangedNotification object:internetReachability_]; Triple thanks … John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
iOS App Ready to Upload ???
Finally, wrapped up my iOS app sand then proceeded to use iTC to upload to App Store for review. Using iTC, I see the status "Waiting for upload". So I start Application Loader and the Loader allows me to select the application. Then, I click "Choose" and my actual app is dimmed in the Finder dialog that comes up. Well, it turns out that an old "gotcha" comes back to haunt me .. I've been avoiding it until now when I can no longer shut my eyes to it. That "gotcha" is that in Xcode 4 at the bottom of the Project Navigator in the "Products" folder, my appName.app appears in RED AND I have never, ever gotten to the bottom of it. To continue … Runs in iPad 4.3 simulator. Runs in iPhone 4.3 simulator. Provisioning Profiles appear to be OK. Connect my real iPad, and select my iPad from the Scheme drop-down and: CodeSign Error: Entitlements file "/Users/.../Love Song to America.entitlements" is missing. ??? Don't understand because I see it in the Project Navigator and in the Finder. ??? Good Grief - just noticed for the very first time that the "Archive" and "Build for Archive" are active, and no longer dimmed. Happened when I connected my iPad for the very first time while in Xcode. Anyway, still CodeSign Error It's crunch time and I really, really am raising a big HELP flag. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Hide Quicktime logo when using MPMoviePlayerController to play audio
Reference my iOS TabController app... Apple docs state that the AVAudioPlayer class does not provide support for streaming audio based on HTTP URL's. AVAudioPlayer plays only music embedded in the iApp. Given that, I do use MPMoviePlayerController to play these web stored audio/mp3 files which it can handle. This definitely works. I start out with a UIView with the lyrics for the song. At the very bottom of this lyrics UIView is a "Play" button. The user taps this button and the audio/mp3 plays; however, the audio/QuickTime (( Q )) graphic comes to the foreground and the lyrics disappear and will stay away until the user taps "Done". What I want to happen is that the audio/mp3 is played, but the lyrics stay in front. BTW, I really don't think I need the "Done" button to be seen because the user can stop the audio by simply selecting another Tab. Obviously this coming to the foreground for the AV Quicktime graphic makes sense because the MPMoviePlayerController object is primarily designed to play video and the video ought to come to the front. Therefore, it is consistent in that the Quicktime graphic also comes to the foreground. BUT, I really do need a way to defeat the audio/QuickTime (( Q )) graphic coming to the front and keep the lyrics there. I did insert code to determine if it was an audio file (mp3), versus a video file (mp4). So far so good ... and then if it was an audio file, within my actual playing segment, I have: if ( NSClassFromString(@"MPMoviePlayerViewController") ) { if (!isAudioFile) { [senderViewController presentMoviePlayerViewControllerAnimated:moviePlayerViewController_]; } } [moviePlayerController_ play]; It actually works, that is, I actually hear the mp3 in the background, with the lyrics staying in front and the audio/QuickTime (( Q )) graphic does not show … **BUT, what does happen is horrible, that is, the "Done" button shows over the lyrics** I talked about with some sort of unknown ??? letters there. The gibberish that appears looks line the "Done" label for the UIButton superimposed on which is the time remaining to finish the song. FWIW, I really don't think I need a "Done" button because as soon as I go to another tab, either new music or a video, the music initially playing stops and the new AV file starts. If I press the Home button, the music stops playing, so I think I can get along without the Done button being around. Any ideas to cover over the Done button ?? ... because right now I don't have a clue what to do. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
iOS programming (who does what to whom?)
Way back when, when XCode was almost! brand new, I printed out reams and reams of paper which described, for example, how a NSDocument-based macOS app happened. For example, I learned to override: -(BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError because this is part of initialization process before -windowControllerDidLoadNib: is called. I learned to override: -(NSString *)windowNibName to return the name of my nib. I learned to override - (void)windowControllerDidLoadNib:(NSWindowController *)aController because for a new document/window, NSDocumentController's -newDocument: calls us. When an existing document is opened, (our overridden) -readFromURL: calls us. If the document is already open, Cocoa activates it. I actually read the tons of Apple docs that explained in detail the chain of messages sent until the NSDocument window appeared. Okay, what's the point? This point is a question: where can I find the details of who calls whom after main.m is run .. in the iOS word, what happens inside UIApplicationMain. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
2 Quick questions about my iOS App and the Apple Developer program
I'm just beginning to learn about Cocoa-Touch programming, so it will be awhile. Eventually, I would like to upload the intermediate stages of my iOS App to my iPad just for testing. I am very familiar with the iOS software simulator, but I would like to use my iPad as a test platform, the real mcCoy, so to speak. I have registered (free version) as a Apple Developer. Do I have to formally be a Apple Developer ($99 per year) to get my pre-release iOS App onto my iPad? Finally, for every year I have my final iOS App in the App Store, do I have to shell out $99. I don't know if this influences the answer to the final question, but I fully intend to offer whatever iApp(s) I develop for free. Thanks in advance, John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Editing nib files in XCode 4 and other stuff
I've just converted my long-standing XCode 3 project to XCode 4. I was very fortunate in that the only change I had to make was because the call to -setDelegate was changed from: - (void )setDelegate:(id)delegate to: - (void )setDelegate:(id < NSToolbarDelegate >)delegate - (void )setDelegate:(id < RunPortDelegate >)delegate for one class's ToolbarCategory and for my RunPortCategory for another Class. (1) For what reason did they make that change to -setDelegate .. just plain ole (id) worked ?? (2) Based on what I've read (and shown) SO FAR is that XCode 3 generated nib's are not editable in XCode 4 and that the only way to get around this is: a. edit them in XCode 3 and do everything else in XCode 4 .. thank heavens I was smart enough to keep XCode 3 around b. re-generate them in XCode 4, basically starting over in XCode 4's integrated environment. I don't know how to do that yet .. have downloaded various PDFs, so I've got a lot of reading to do .. something about creating a file first via the File Menu .. I'll get there eventually John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSTimer access to its -timerFireMethod
This is just out of academic curiosity because I can successfully use: [NSThread detachNewThreadSelector: toTarget: withObject:] to do what I want. Nevertheless, I have been trying to do the same thing in the main Thread with NSTimer and something is wrong that I just cannot figure out. So, here are some snippets: In the .h file I have: NSTimer *itsTimer; In the .m file I have: - (void )startTimer { if (!itsTimer || ![itsTimer isValid]) { NSTimer *theTimer; theTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES]; itsTimer = theTimer; } } - (void )stopTimer { if (itsTimer && [itsTimer isValid]) { [itsTimer invalidate]; itsTimer = nil; } } - (void )timerFireMethod:(NSTimer *)theTimer { NSLog(@"we are here"); // just to keep it simple at first } I call -startTimer and -stopTimer from the main Thread and the NSLog(@"we are here") never shows in the Console. I did try, unsuccessfully: theTimer = [[NSTimer alloc] initWithFireDate:[NSDate date] interval:0.5 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:theTimer forMode:NSDefaultRunLoopMode]; itsTimer = theTimer I think I have found the problem, but I would like confirmation ... the calls are from the main Thread, immediately followed by the display of a sheet. I am trying to intercept errors while the sheet shows. And while the sheet shows, all access to -timerFireMethod is temporarily halted. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
closing a sheet from another controller
I use one of the standard approaches to opening a NSWindowController sheet; that is, my external Controller calls: [NSApp beginSheet:...] each of the IB buttons are connected via IBActions that close the sheet via: [NSApp stopModal]; // sender = NSButton and [sender window] = sheet [NSApp endSheet:[sender window] returnCode:theCode]; // calls didEndSelector: The didEndSelector: looks like: - (void )sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo which calls: [sheet orderOut:self]; Fairly standard stuff, but here's the rub. If a error in my app occurs while this sheet is displayed, I want to be able to dismiss the sheet from a external Controller and display an appropriate status message in the sheet's parent window; for example, the external app document (that my application is chewing on) unexpectedly closes. My sheet knows the external Controller that calls +beginSheet: because this external Controller's identity is passed to the method which calls +beginSheet:. Based on my previous history, there is probably something plainly simple, but I'm just missing it. Thanks in advance, John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
raising NSException between Controllers
I am having inconsistent problems when I call from Controller #1 one of 1's methods which looks like: - (void ) exitBgCalculationThread:(int)withStatus { [controller2 haltBgCalculationThread:withStatus]; } Controller #2's haltBgCalculationThread:withStatus eventually calls: itsException = [NSException exceptionWithName:newErrorName reason:newErrorReason userInfo:nil]; [itsException raise]; // stops here and long jumps to try-catch-finally Handler // within EC's -calculateWorksheetRow: The call to -raise enters the @catch block of a try-catch-finally Handler within Controller #2 (the only such Handler anywhere). The only statement within this @catch block is a call to NSLog. After this, the NSLog call falls thru to the @finally portion which returns the correct error code. Controller #2's calculation for loop immediately exits and through a call-back routine sends a message back to Controller #1 which displays the appropriate error message in the active window. The correct error message is displayed; however, in seemingly random instances, the above NSLog is never seen. Whenever, I call Controller #2's -haltBgCalculationThread: from Controller #2, everything works dandy; the lack of calling NSLog in random instances occurs only when I call Controller #2's -haltBgCalculationThread: from Controller #1. Maybe?? it is because I am bouncing between separate Controllers and am causing mayhem. Any psychic premonitions would be welcomed. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Changing cursors in window's bounds
I do not have a custom view, rather just the window's contentView with its various graphics, buttons, text etc. I wish to simply change the cursor anytime the mouse is inside any part of this contentView. If I did have a custom view, I understand all the machinations pertaining to changing cursors, e.g., NSView's initWithRect:, addTrackingArea:, and cursorUpdate: Thanks to Apple's TrackIt Project, it all seems straightforward. My challenge centers on trying to make this magic happen just in the window's canned contentView without creating a custom NSView within Interface Builder. My sub-classed NSDocument knows about the window via my overridden -windowControllerDidLoadNib:(NSWindowController *)aController because its window = [aController window]. Also, I have one Controller (sub to NSObject) which has knowledge of the NSDocument's NSWindow because I pass this window to it. So, how do I effect cursor tracking just in this window without creating a custom NSView in IB? John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
'Build and Analyze' with XCODE 3.2.2
Here's a sample snippet of my code: - (NSDate *)offsetDate:(NSDate *)fromDate byYears:(int)addYears byMonths:(int)addMonths byDays:(int)addDays { NSDateComponents *offset = [[NSDateComponents alloc] init]; [offset setYear:addYears]; [offset setMonth:addMonths]; [offset setDay:addDays]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; return [gregorian dateByAddingComponents:offset toDate:fromDate options:0]; } Builds and runs just dandy .. but "Build and Analyze" coughs up: // method returns an object with a +1 retain count (owning reference) NSDateComponents *offset = [[NSDateComponents alloc] init]; ... and at the end of the method: // object allocated and stored into 'offset' is no longer referenced after this point // and has a retain count of +1 (object leaked) } It appears that the analysis is saying I should retain offset immediately after it is set with *offset =: NSDate *result = [gregorian dateByAddingComponents:offset toDate:fromDate options:0]; [offset release]; return result; By the way, identical gotchas are picked up by B & A for gregorian. John Love John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
appscript project gives warning with XCODE 3.2.2
Everything worked just dandy for SourceForge's "appscript" with XCODE 3.2.1. But, with updating to 3.2.2, it is giving me some grief: For one project, it's giving a warning: ld: warning: directory '/Users/johnlove/Documents/XCode/Calculate Medical/../../../appscript/Appscript Framework Project/build/Debug' following -F not found Being a warning, app still runs and runs impeccably. I thought that maybe the appscript framework needed to be re-built with XCODE 3.2.2 .. but that attempt generates an error: There is no SDK with the name or path '/Developer/SDKs/MacOSX10.4u.sdk'. I can hardly remember Tiger sdk's being on my hard drive. Building with 3.2.1 gives no error. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Almost! to the end
I tracked down NSException. Appscript posts a "NSRangeException" Exception which applies in my case. So, a simple @try .. @catch pair around each row does the trick. Thanks again and again .. John Love = On Jan 12, 10, at 10:33 AM, John Love wrote: > Thanks to many, many folk, I am at the very end of my project .. calculating > an Excel spreadsheet, cell by cell .. with the calculations done in a > background thread .. using either +detachNewThreadSelector and/or NSPorts > with NSPortMessages, or even a NSOperationQueue. Tried all 3 approaches just > for the sake of learning, and they all work. > > It's definitely been quite an education for me and quite an exercise in > patience for all you folks. > > Oh, one more thing .. I use HAS's appscript application, ASTranslate, to > convert my previous! AppleScript Studio code to Cocoa .. and it really works. > > After completing each row's worth of calculations, I test for the existence > of both Excel and the spreadsheet .. in case the user prematurely quits the > app or closes the spreadsheet .. and it works like a charm .. if quitting or > closing, a message appears in my doc window. > > EXCEPT, if the user quits the app or closes the spreadsheet in the middle of > completing the calculations for each row before I have a chance to do the > appropriate testing. Even if I burden my code by testing before each cell in > the entire row, I still (theoretically) could encounter a quit or a close in > the middle of a cell's calculation. Clearly, getting or setting the value in > a cell of a spreadsheet doc that is closed crashes my app. > > My very initial thoughts focus on NSError, except HAS's ASTranslate app does > not seem to include a built in NSError object, such as is passed to > NSDocument's -readFromURL. > > Any help out there for this worst-case scenario? Thanks in advance. > > John Love > Touch the Future! Teach! > John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Almost! to the end
Thanks to many, many folk, I am at the very end of my project .. calculating an Excel spreadsheet, cell by cell .. with the calculations done in a background thread .. using either +detachNewThreadSelector and/or NSPorts with NSPortMessages, or even a NSOperationQueue. Tried all 3 approaches just for the sake of learning, and they all work. It's definitely been quite an education for me and quite an exercise in patience for all you folks. Oh, one more thing .. I use HAS's appscript application, ASTranslate, to convert my previous! AppleScript Studio code to Cocoa .. and it really works. After completing each row's worth of calculations, I test for the existence of both Excel and the spreadsheet .. in case the user prematurely quits the app or closes the spreadsheet .. and it works like a charm .. if quitting or closing, a message appears in my doc window. EXCEPT, if the user quits the app or closes the spreadsheet in the middle of completing the calculations for each row before I have a chance to do the appropriate testing. Even if I burden my code by testing before each cell in the entire row, I still (theoretically) could encounter a quit or a close in the middle of a cell's calculation. Clearly, getting or setting the value in a cell of a spreadsheet doc that is closed crashes my app. My very initial thoughts focus on NSError, except HAS's ASTranslate app does not seem to include a built in NSError object, such as is passed to NSDocument's -readFromURL. Any help out there for this worst-case scenario? Thanks in advance. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
An Array of structs
In my .h file, I have: typedef struct YearAmt { NSString *year; int amount; } YearAmt; extern NSString *testy; extern YearAmt gTest[]; In the corresponding .m file: NSString *testy = @"testy"; YearAmt gTest[] = {{testy, 10} /*, + others */}; I get "Initializer element is not constant. This pertains to the NSString* because if I directly substitute the following, no compile error happens: YearAmt gTest[] = {{@"testy", 10} What fundamental pertaining to C or C++ am I not getting? John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
cocoabuilder.com
Is http://www.cocoabuilder.com/ dead? John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSInvocationOperations and background Threads
Big thank you's to Ken Thomases, Nick Zitzmann and Quincey Morris (can't seem to find Quincey's email?) Found my stupid mistake .. stupid because you guys individually mentioned it time and time again. Namely, my -startBgThread begins in the main Thread. So when I call -startOperation to add my Operation to the Queue (which starts up the background thread "sometime", and I really don't care when!), I should end -startBgThread. Stop doing further stuff in the main Thread, right then-and-there. Let the background Thread cancel the Operation if need-be, and if so, send a Notification back to the main Thread. Anyway, my bad! John = On Oct 18, 09, at 5:31 PM, Ken Thomases wrote: On Oct 18, 2009, at 7:26 AM, John Love wrote: Thanks for your prompt reply, I really appreciate it. You're welcome. I have revamped my code to have just one NSInvocationOperation whose selector contains the long for-loop. [...] the long for-loop is within -doAllOperations. OK, as far it goes. It's my understanding from the docs and other Cocoa mailing list readers that when -addOperation: is called, a new background Thread is started up. Well, you should stop trying to think about when exactly threads are started up (or how many there are, or how long they run, or exactly which one your operations run on, etc.). All of that is implementation detail about which you shouldn't care. The only important thing is that your (non-concurrent) operations will be run on some background thread that you are not responsible for setting up or managing. (If you implement concurrent operations, you still aren't guaranteed anything about on which thread your -start method is invoked, but you take responsibility for the execution context after that.) If that is true, then my long for-loop should be executing in the background Thread. If I'm still on-track, then I have a problem in that I temporarily placed a NSLog() call within my -doCalculation, but nothing gets printed in my log. So, for the moment I am lost. Well, there's no way for me to provide additional insight without seeing your code. If you suspect your code is blocked, you can sample your process (e.g. using Activity Monitor or the "sample" tool), which can show you where your threads are spending their time. You can also put may more logging statements throughout your code to track its progress. You can break into your program in the debugger and examine the various threads. Etc. Regards, Ken John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSInvocationOperations and background Threads
Ken .. Thanks for your prompt reply, I really appreciate it. I have revamped my code to have just one NSInvocationOperation whose selector contains the long for-loop. A snippet looks like: itsOps = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(doAllOperations) /* data passed to selector */ object:nil]; [itsQueue addOperation:itsOps]; // itsQueue previously set = [[NSOperationQueue alloc] init] and the long for-loop is within -doAllOperations. It's my understanding from the docs and other Cocoa mailing list readers that when -addOperation: is called, a new background Thread is started up. If that is true, then my long for-loop should be executing in the background Thread. If I'm still on-track, then I have a problem in that I temporarily placed a NSLog() call within my -doCalculation, but nothing gets printed in my log. So, for the moment I am lost. By the way, delving into NSOperations is for the moment just an attempt to learn more since I have successfully called - detachNewThreadSelector, as well as delved into NSMachPorts and NSPortMessages with success. So, I'm just trying to learn a little bit more here. Again, thanks. John === On Oct 17, 09, at 10:20 PM, Ken Thomases wrote: On Oct 16, 2009, at 8:01 AM, John Love wrote: In my app, I have a very long for-loop It appears however, that in my app there is no background Thread that begins and the reason for that is because my app's window stays in the background until all NSOperations are complete. Any clues? I suspect your app's window isn't staying in the background until all NSOperations are complete, but rather that it's staying in the background until your long for-loop completes. You can't run a long for-loop on the main thread and expect event handling to proceed. (Well, you can, but only if your for-loop is handling events manually, itself.) It sounds like you're fundamentally misunderstanding how things like the main run loop, event processing, operation queues, your for- loop, etc. interact. 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
__CFServiceControllerBeginPBSLoadForLocalizations timed out error
I *just* noticed the following error in the XCode Debugger Console: __CFServiceControllerBeginPBSLoadForLocalizations timed out while talking to pbs .. and I'm getting it at the very top of -init for my NSDocument?? I have no clue as to when it started .. I kinda think maybe with upgrading to 10.6, but I really do not know?? Good grief!! John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSInvocationOperations and background Threads
NSOperation.pdf states: "For a non-concurrent operation, an operation queue automatically creates a thread and calls the operation object’s start method, the default implementation of which configures the thread environment and calls the operation object’s main method to run your custom code." In my app, I have a very long for-loop, each time thru which, I call NSInvocationOperation's -initWithTarget:selector:object:, followed by a call to add the resulting Operation to the NSOperationQueue. This queue is previously created via itsQueue = [[NSOperationQueue alloc] init], itsQueue being a instance variable. I do not have a custom -start or a -main method, so I count on the default -start and -main methods to handle the creation of a background Thread for me. It appears however, that in my app there is no background Thread that begins and the reason for that is because my app's window stays in the background until all NSOperations are complete. Any clues? By the way, when I alternately use either +detachNewThreadSelector or NSMachPorts, everything works just fine, including the app's window coming to the foreground, which event I force via [NSApp activateIgnoringOtherApps:YES] even before I start the background Thread. One last question .. if a new background Thread is automatically started when I add the new NSInvocationOperation to the NSOperationQueue, is there a NSAutoreleasePool automatically created before the above selector method starts and is this NSAutoreleasePool released after this method finishes? John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Where to send different messages while RunLoop is running
Wow, your response was super prompt and I thank you for that. I have used a thread (and -performSelectorOnMainThread) and this approach definitely works. Having said that, I am in the process of just learning about NSMachPorts and am doing this now. I just wish to use 2 NSMachPorts to communicate back and forth between the main and secondary Threads You said "it seems inappropriate for it(-shouldExit) to do things unrelated to testing whether or not the thread should exit". I will definitely work on that because I think you're correct. I definitely do agree that polling is sporadic or unpredictable -- and taking your clue about +distantFuture to heart, I changed it to +date to indicate now, or immediately -- and it now works even with - shouldExit sending other message IDs. I just need to think where to send these other message IDs per your recommendation. = On Oct 11, 09, at 4:00 PM, Alastair Houghton wrote: On 11 Oct 2009, at 20:40, John Love wrote: Reference: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html#//apple_ref/doc/uid/1057i-CH16-SW29 As noted, Apple's sample code sends a kCheckinMessage back to the main Thread and then monitors the currentRunLoop until -shouldExit returns YES. Within -shouldExit, I wish to monitor error conditions (e.g., a external application's document not open). If such an error exists, send a unique error message ID and then return NO when -shouldExit is finished. Is -shouldExit the appropriate place for sending these other message IDs? Not really, no. Why should a method called -shouldExit do such a thing? It is, obviously, up to you what -shouldExit does (since it's a method defined by MyWorkerClass, which is entirely your business), but it seems inappropriate for it to do things unrelated to testing whether or not the thread should exit. Also, there's no guarantee that the run loop will return regularly, unless you set some other date besides +distantFuture... As an aside, however, polling is *really ugly* and wastes both energy and CPU time, so ideally if you can avoid it then you should; whether this is possible depends on the tests you need to do. FWIW, it seems like quite a complicated design using this Mach port sample as a basis for the kind of thing you're proposing. How are you proposing to do your checks, precisely? Why not just use a thread and -performSelectorOnMainThread:? Kind regards, Alastair. -- http://alastairs-place.net John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Where to send different messages while RunLoop is running
Reference: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html#//apple_ref/doc/uid/1057i-CH16-SW29 As noted, Apple's sample code sends a kCheckinMessage back to the main Thread and then monitors the currentRunLoop until -shouldExit returns YES. Within -shouldExit, I wish to monitor error conditions (e.g., a external application's document not open). If such an error exists, send a unique error message ID and then return NO when -shouldExit is finished. Is -shouldExit the appropriate place for sending these other message IDs? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Retaining a NSURL and retaining its -path
In my controller, one of my instance variables is a NSURL and I retain it because I pass it to a 2nd controller. In my second controller, I extract [myURL path] and look at it in a secondary thread loop and everything works fine. I began to think if I could eliminate that call to [myURL path] every time through that loop I would save "some" time. My first attempt was to pass that NSURL in the same manner and then place the extracted [myURL path] into an instance variable of the 2nd controller. Okay so far .. and then I assumed that if myURL was retained in the 1st controller, then "naturally" its NSString -path was also retained .. but it crashed with "release message sent to a already released object" (or something like that). Only when I extracted the -path *and* retained it before I stored it as an instance variable of the 2nd controller did it work. Basic question: if a parent object is retained, why isn't each sibling component object of that parent retained?? John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Memory Leak, Part I
[part II of my plea for help] (3) - (void) doCalculation { for (row=1; row <= 1; row++) { // many rows, therefore much time if ([self shouldExit]) break; // do calculation for each row } } (4) - (BOOL) shouldExit { [self pingWorkbook]; // calls –setExcelError (NSMutableDictionary, with 2nd key) int NoExcelAppOrNoWorkbookErr = [self itsExcelError]; if (NoExcelAppOrNoWorkbookErr != kNoError) { // kNoError = 0 [self setCalcStatus:NoExcelAppOrNoWorkbookErr]; return YES; } CalcStatus theCalcStatus = [self itsCalcStatus]; // (NSMutableDictionary, 1st key) if (theCalcStatus == kStopped) { return YES; } else { return NO; } } (5) - (void) endBgCalculation/ { CalcStatus theCalcStatus = [self itsCalcStatus]; if (theCalcStatus == kCalculating) { // do stuff } else { // do stuff } } John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Memory Leak, part II
[part II of my plea for help] (3) - (void) doCalculation { for (row=1; row <= 1; row++) { // many rows, therefore much time if ([self shouldExit]) break; [self doCalculationForEachRow]; } } (4) - (BOOL) shouldExit { [self pingWorkbook]; // calls –setExcelError (NSMutableDictionary, with 2nd key) int NoExcelAppOrNoWorkbookErr = [self itsExcelError]; if (NoExcelAppOrNoWorkbookErr != kNoError) { // kNoError = 0 [self setCalcStatus:NoExcelAppOrNoWorkbookErr]; return YES; } CalcStatus theCalcStatus = [self itsCalcStatus]; // (NSMutableDictionary, 1st key) if (theCalcStatus == kStopped) { // = a 2nd int return YES; } else { return NO; } } (5) - (void) endBgCalculation/ { CalcStatus theCalcStatus = [self itsCalcStatus]; // (NSMutableDictionary, 1st key) if (theCalcStatus == kCalculating) { // a 3rd int // do stuff } else { // do stuff } } John Love___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Memory Leak, part I
[this is part I of a two-part plea for help] I I have read Apple's "ManagingMemory.pdf" and am still having difficulty understanding the use of MallocDebug which is detailed in "MemoryMgmt.pdf". I have 5 methods in the generation of a background thread and I cannot figure out where the memory leak is: MallocDebug states that there is zero leakage for each of these methods, but there is a leakage = 480 bytes in 24 nodes for thread_start (1) - (void) startBgCalculation { /* setCalcStatus calls: itsDictionary = [[NSThread currentThread] threadDictionary]; [itsDictionary setValue:[NSNumber numberWithInt:kCalculating] forKey:staticString#1]; */ [self setCalcStatus:kCalculating]; [NSThread detachNewThreadSelector:@selector(bgCalcThread) toTarget:self withObject:nil]; } (2) - (void) bgCalcThread { NSAutoreleasePool *bgCalcThreadPool = [[NSAutoreleasePool alloc] init]; [self doCalculation]; [self performSelectorOnMainThread:@selector(endBgCalculation/ *:*/) withObject:nil waitUntilDone:YES]; [bgCalcThreadPool release]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Configuring a Port-based Input Source -- Part 2
[continuation -- part 2] Here is where my mainCtrl parm comes into play, because instead of Apple's: Within my do { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } while (![mainCtrl shouldExit]); where my – (BOOL) shouldExit is in my main Thread. Am I still on the right track? I definitely am off-base somewhere because there is no evidence that mainCtrl's –shouldExit is even called? Anyway, I'm almost finished, so let me continue. Further, I just use:[self sendCheckInMessage:distantPort]; and within Apple's – (void) sendCheckinMessage :(NSPort*)bgndPort, they have: NSPort* myPort = [NSMachPort port]; Apple states: "Create and configure the worker thread port". Is myPort a local main Port for the worker thread port to send its message back to? And if so, why is this required because doesn't Cocoa know about the main port that it presumably created when it called: NSApplicationMain(argc, (const char **)argv); at the very start within "main.m"? One last basic question -- where exactly should my – doSomeSuperLongCalculation method go? Should it be sandwiched somehow within –shouldExit,? Is it inserted within the main thread's – handlePortMessage, or is it placed within the above do-while loop? John Love Touch the Future! Teach! P.S. Hope I don't get bumped again for excessive length. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Configuring a Port-based Input Source -- Part 1
I have this request for help in two parts, because I've been bumped due to length: Reference: "Configuring a Port-Based Input Source" of http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/chapter_6_section_5.html#/ /apple_ref/doc/uid/1057i-CH16-SW7 My challenge is to try to understand this part of Chapter 5 of Apple's "multithreading.pdf". My single question is "Is my understanding correct?" .. and the best way I can approach this is to go almost line- by-line of the code presented. First and foremost, I understand that a NSMachPort is a two way port: for the main thread, the "remote" port is the background port and for the background Thread, the "remote" port is the main port. In short, the same port is used for two-way communication. I have placed all the methods listed in this section of Ch. 5 are in a separate controller, ThreadController, from here on called "TC". So, when I call any of these methods from the main thread, I use: [iboTC somePortMethod]; My principal variation to Apple's code involves calling –launchThread with a passed parm, i.e.: [iboTC launchThread:self]; Within my TC's – (void) launchThread:(id)theMainCtrl, I assign the passed parm to my TC instance variable = mainCtrl (for use later, as you will see). So, going almost line-by-line: Within Apple's –launchThread, they have: NSPort* myPort = [NSMachPort port]; This appears to be a new background Port. Is it, or is it a new local main Port? I think it is a background Port because Apple continues by calling – detachNewThreadSelector with an object equal to this Port. Within the selector passed to –detachNewThreadSelecctor: +(void)LaunchThreadWithPort:(id)inData (actually, I convert it to an instance method - don't know why Apple uses a class method here ?) the passed inData is immediately converted: NSPort* distantPort = (NSPort*)inData; Where their distantPort, or remote Port, is the remote Port for the main Thread, thus making the passed Port the background Port. Am I good so far and if not, why not? [continued in Part II] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
performSelectorOnMainThread
-performSelectorOnMainThread:withObject:waitUntilDone:, according to Apple docs, is passed a SEL method that "should not have a significant return value". I wish it to return a INT and I figure that that qualifies as in- significant. Given that assumption, my real question is how to implement it. I call: [self performSelectorOnMainThread:@selector:mySimpleSelector withObject:nil waitUntilDone:YES]; (int) mySimpleSelector { if (whatever) return 0; else return 1; } via my call to -performSelectorOnMainThread, just how do I access - mySimpleSelector's returned INT? The simplest answer is to not have a return value at all, but rather store the INTs in a global; but I figure there is no time like the present to learn to solve this problem the right way. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Works in main Thread, but not in background Thread (modified)
This request focuses on an old cocoabuilder thread: http://www.cocoabuilder.com/archive/message/cocoa/2007/3/8/179989 David writes: > But now I find I have a BOOL method that is rarely and randomly returning NO when the only exit to the method is "return YES;" so I have some strange problem somewhere. It turned out that the method didn't need to be BOOL, but the result is checked anyway. > Instead of his BOOL, I have an INT in the form of an ENUMerated constant. However, unlike David, I still have not yet discovered my version of "some strange problem somewhere". Code follows: typedef int myStatus; enum { kNoError, kConstant1, kConstant2, kWhoops }; - (myStatus) myRoutine { if ([self myOtherRoutine] == kNoError) { // calculations here if (something) return kConstant1; else return kConstant2; } else { return kWhoops; } } Here's myOther routine: - (myStatus) myOtherRoutine { NSWorkspace *workSpace = [NSWorkspace sharedWorkspace]; NSArray *runningAppDictionaries = [workSpace launchedApplications]; NSString *keyName, *keyValue; keyName = @"NSApplicationBundleIdentifier"; keyValue = @"com.microsoft.Excel"; NSDictionary *aDictionary; BOOL foundExcel; for (aDictionary in runningAppDictionaries) { foundExcel = [[aDictionary valueForKey:keyName] isEqualToString:keyValue]; if (foundExcel) break; } // if (!foundExcel) NSLog(@"no Excel"); return (foundExcel ? kNoError : kWhoops); } NSLog prints "no Excel" many times and stops (as it should when foundExcel becomes true). So everything is okay so far .. until I forcibly quit Excel "Cmd-Tab-Q". When I do this quit, NSLog should print "no Excel", but it does not! Let me wrap this up by saying when myRoutine is called in my main thread, everything works fine .. but when called by my background thread (via [NSThread detachNewThreadSelector:toTarget:withObject:] it definitely does not work. An interesting side note is that if I insert the following as the very 1st line in myRoutine: return [self myOtherRoutine]; it starts working in the background thread. If this sounds "crazy" you are definitely correct. Once again, "some strange problem somewhere". Thanks for listening. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Works in main Thread, but not in background Thread
This request focuses on an old cocoabuilder thread: http://www.cocoabuilder.com/archive/...007/3/8/179989 David writes: > But now I find I have a BOOL method that is rarely and randomly returning NO when the only exit to the method is "return YES;" so I have some strange problem somewhere. It turned out that the method didn't need to be BOOL, but the result is checked anyway. > Instead of his BOOL, I have an INT in the form of an ENUMerated constant. However, unlike David, I still have not yet discovered my version of "some strange problem somewhere". Code follows: typedef int myStatus; enum { kNoError, kConstant1, kConstant2, kWhoops }; - (myStatus) myRoutine { if ([self myOtherRoutine] == kNoError) { // calculations here if (something) return kConstant1; else return kConstant2; } else { return kWhoops; } } Here's myOther routine: - (myStatus) myOtherRoutine { NSWorkspace *workSpace = [NSWorkspace sharedWorkspace]; NSArray *runningAppDictionaries = [workSpace launchedApplications]; NSString *keyName, *keyValue; keyName = @"NSApplicationBundleIdentifier"; keyValue = @"com.microsoft.Excel"; NSDictionary *aDictionary; BOOL foundExcel; for (aDictionary in runningAppDictionaries) { foundExcel = [[aDictionary valueForKey:keyName] isEqualToString:keyValue]; if (foundExcel) break; } // if (!foundExcel) NSLog(@"no Excel"); return (foundExcel ? kNoError : kWhoops); } NSLog prints "no Excel" many times and stops (as it should when foundExcel becomes true). So everything is okay so far .. until I forcibly quit Excel "Cmd-Tab-Q". When I do this quit, NSLog should print "no Excel", but it does not! Let me wrap this up by saying when myRoutine is called in my main thread, everything works fine .. but when called by my background thread (via [NSThread detachNewThreadSelector:toTarget:withObject:] it definitely does not work. An interesting side note is that if I insert the following as the very 1st line in myRoutine: return [self myOtherRoutine]; it starts working in the background thread. If this sounds "crazy" you are definitely correct. Once again, "some strange problem somewhere". Thanks for listening. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: alloc init thread safe?
This request focuses on an old cocoabuilder thread: http://www.cocoabuilder.com/archive/message/cocoa/2007/3/8/179989 David writes: >>> But now I find I have a BOOL method that is rarely and randomly returning NO when the only exit to the method is "return YES;" so I have some strange problem somewhere. It turned out that the method didn't need to be BOOL, but the result is checked anyway. >>> I do have an INT in the form of an ENUMerated constant, instead of his BOOL. And for sure, I have not yet discovered my version of "some strange problem somewhere". typedef int myStatus; enum { kNoError, kConstant1, kConstant2, kWhoops }; - (myStatus) myRoutine { if ([self myOtherRoutine] == kNoError) { // calculations here if (something) return kConstant1; else return kConstant2; } else { return kWhoops; } } Even when [self myOtherRoutine] does *not* return kNoError, myRoutine says it does. Let me wrap this up by saying when myRoutine is called in my main thread, everything works fine .. but when called by a second thread (via [NSThread detachNewThreadSelector:toTarget:withObject:] it definitely does not work. An interesting side note is that if I insert the following as the very 1st line in myRoutine: return [self myOtherRoutine]; it works in the second thread. If this sounds "crazy" you are definitely correct. Once again, "some strange problem somewhere". Thanks for listening. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Merry Christmas
A very Merry and Blessed! Christmas to all of you and your families and friends John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Using NSWorkspace's launchedApplication to detect running App
On Dec 13, 08, at 12:21 PM, Jean-Daniel Dupas wrote: Because operator overriding does not exists in Obj-C and so, == is a pointer comparaison and not a string comparaison. use the isEqual: method to compare two object. Thanks to everyone who chimed in .. and here are my changes: BOOL ExcelActive = NO; NSWorkspace *workSpace; NSArray *runningAppDictionaries; NSDictionary *aDictionary; workSpace = [NSWorkspace sharedWorkspace]; runningAppDictionaries = [workSpace launchedApplications]; for (aDictionary in runningAppDictionaries) { if ([[aDictionary valueForKey:@"NSApplicationName"] isEqualToString:@"Microsoft Excel"]) { ExcelActive = YES; break; } } return ExcelActive; Same NO return value. I then tried this variation, with the same NO return value: NSArray *applArray; applArray = NSWorkspace sharedWorkspace] launchedApplications] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat: @"%K contains %@", @"NSApplicationName", @"Microsoft Excel"]] valueForKey:@"NSApplicationName"]; if ([applArray count] > 0) return YES; else return NO; One footnote .. there are problems with Microsoft Excel as reported by HAS of appscript. He points out difficulties with Excel, in particular, with respect to Excel documents. Don't know about the app- level. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Using NSWorkspace's launchedApplication to detect running App
I do not understand why this code completes with the specified application not being active .. when it really is? I really need your help. BOOL AppActive = NO; NSWorkspace *workSpace; NSArray *runningAppDictionaries; NSDictionary *aDictionary; workSpace = [NSWorkspace sharedWorkspace]; runningAppDictionaries = [workSpace launchedApplications]; for (aDictionary in runningAppDictionaries) { if ([aDictionary valueForKey:@"NSApplicationName"] == @"My Application") { AppActive = YES; break; } } return AppActive; Thanks ... John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Multithreading and Mach ports
Reference: http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/chapter_6_section_5.html#/ /apple_ref/doc/uid/1057i-CH16-SW7 While I'm trying to piece your replies together, I have a quick question .. reference Listing 5-15 and, in particular, the comment: // Create and configure the worker thread port. It appears that the passed (NSPort*)outPort is also the worker, or background, thread port. If true, then are we sending from a background port to another background port??? Thanks for this in-between request. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
Multithreading and Mach ports
Reference: http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/chapter_6_section_5.html#/ /apple_ref/doc/uid/1057i-CH16-SW7 I've got several questions since I'm just starting to investigate Mach Ports. 1) Why is +LaunchThreadWithPort: so designated, ie, a class method. It seems to me that as far as the specific code listings presented, a class method is not required? For example, [workerObj sendCheckinMessage:distantPort] could be replaced with [self sendCheckinMessage:distantPort] if LaunchThreadWithPort would be changed to an instance method. 2) Maybe the real question #1 is: What exactly is the object in the background thread, named workerObj ?? 3) I've saved my most general question to last, at least for this trip: currently when I enter my method to start up my background thread or threads, I simply call (several times if I have multiple threads: [NSThread detachNewThreadSelector:@selector(bgCalcThread:) toTarget:self withObject:nil] If I have multiple background threads, I can use a NSMutableDictionary with multiple keys for inter-thread communication So, what do Mach Ports give me that the above doesn't? John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
Main Thread stoppin Background Thread
Reference page 43 of Apple's MultiThreading.pdf. I conclude from this page that the preferred, if not only, way to have the main thread stop the background thread is through KVC. Before I continue to inflict more pain on myself, why can't I simply toggle the value of an instance variable of the class' interface from the main thread and have the backgroundThreadRoutine look at the same variable and break out of the background thread if its a certain value? I have been totally unsuccessful in this simpler-to-understand approach; therefore, I am beginning to study KVC and its use on page 43 of Apple's doc. Should I conclude that this class variable is in the main thread and is not accessible by the background thread? If KVC is the only approach for inter-thread communication, I'll press on. A short amount of guidance is definitely needed. Thanks, John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
main thread communicating with background thread and vice-versa
From the main Thread, I call: [NSThread detachNewThreadSelector:@selector(bgThread:) toTarget:self withObject:nil]; - (void) bgThread:(NSConnection*)connection { NSAutoreleasePool *pool; pool = [[NSAutoreleasePool alloc] init]; [self doCalculation]; [self performSelectorOnMainThread:@selector(endBgCalculation:) withObject:nil waitUntilDone:NO]; [pool release]; } - (void) endBgCalculation:(id)obj { // stuff } I believe this is fairly standard way to institute a background thread … The problem centers on letting the background Thread look at a parm set in the main Thread and break out of the background Thread when the background Thread sees a certain value. Specifically, my –doCalculation is just one great time-consuming for- loop that looks at mainThreadParm and breaks depending on the value of mainThreadParm. I change mainThreadParm in the main Thread and I expect the background Thread to break when the background Thread sees a certain value of mainThreadParm. The background thread sees the initial value of mainThreadParm, but does not break when the main Thread changes it. This sounds so basic and fundamental that I really feel lacking on this subject. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
Strange Build Error = [EMAIL PROTECTED]@_cls_refs
Can anyone tell me what the following means and what is the cause? I understand that it is a link error. Elsewhere, Graham Cox in replying to a similar problem by another poster stated "This is a link error. Add the QuartzCore framework to your project". I did exactly that to no avail. ".objc_class_name_SEApplication", referenced from [EMAIL PROTECTED]@[EMAIL PROTECTED] in ScriptController.o symbol(s) not found FYI, ScriptController.h imports SEGlue.h from a linked Framework; and that's where SEApplication comes from. John Love John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: new build phase and other framework topics
If you're not seeing the header files in the framework, my guess is that your headers are marked Private. Select the Copy Headers build phase, choose Detail from the View menu, and look at the Role column. Headers marked "Public" will be copied; headers marked "Project" or "Private" will not be. Bingo .. changed from "Project" to "Public" .. then Build .. there they are. Where in the world was that printed anywhere. Good grief! Many, many thanks. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
build phase and other issues of a framework
** 2nd message after editing by John Love ** I know that my knowledge of Frameworks is dismal; however, I desperately need help. I have read "Apple's Framework Programming Guide" and several posted web sites which are based on the old XCODE 2, that is to say, the old dialog presented with CMD-I, rather than the XCODE 3 expanded CMD-I dialog. Within my Groups and Files, the "Targets" shows "Copy Headers (20)" and "Compile Sources (19)" as set up when I created the Cocoa Framework from scratch ... and everything is there as it should be. However, the built "Products/myframework.framework" shows nothing when clicking the triangle and when double-clicked displays only Listing 1 (p. 14) of "Apple's Framework Programming Guide", rather than Listing 3 (pg. 15). I have CTRL-clicked on myframework.framework and added new Build Phase = Copy files .. but the "Copy Files" following "Link Binary with Libraries" shows empty .. and I cannot figure out how to add files to it. Thanks in advance because I really need some help here. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
new build phase and other framework topics
I know that my knowledge of Frameworks is dismal; however, I desperately need help. I have read Apple's Framework Programming Guide and several posted web sites which are based on the old XCODE 2, that is to say, the old dialog presented with CMD-I, rather than the XCODE 3 expanded CMD-I dialog. Within my Groups and Files, the "Targets" shows "Copy Headers (20)" and "Compile Sources (19)" as set up when I created the Cocoa Framework from scratch ... and everything is there as it should be. However, the built "Products/myframework.framework" shows nothing when clicking the triangle and when double-clicked displays only Listing 1 (p. 14) of Apple's Framework Programming Guide", rather than Listing 3 (pg. 15). I have CTRL-clicked on appscript.framework and added new Build Phase = Copy files .. but the "Copy Files" following "Link Binary with Libraries" in the clip shows empty .. and I cannot figure out how to add files to it. I really need some help here. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
problems with installing appscript as a substitute for NSAppleScript
I've got a almost complete Cocoa document-based app done. The "almost" centers just on my need for Thread-friendly AppleScript, which NSAppleScript is not .. so, enter appscript. Dug around and found ASTranslate which handily generates appscript code based on my input AppleScript code. Then in http://appscript.sourceforge.net/objc-appscript/install.html I found: svn checkout http://appscript.svn.sourceforge.net/svnroot/appscript/objc-appscript objc-appscript svn checkout http://appscript.svn.sourceforge.net/svnroot/appscript/py-appscript/trunk py-appscript svn checkout http://appscript.svn.sourceforge.net/svnroot/appscript/py-osaterminology/trunk py-osaterminology Downloaded each folder and the above automatically placed them at the top-level of my /users/myname folder. So far, so good, but this is where it ends .. Found the unix executible file = osaglue buried in each of the above folders .. double-clicked on osaglue and Terminal returned: === Sorry, py-appscript 0.18.1 or later is required to use osaglue. Please see the following page for more information: http://appscript.sourceforge.net/py-appscript/install.html Please install py-appscript and run this command again. === In http://appscript.sourceforge.net/py-appscript/install.html I found: sudo easy_install appscript where the web page states "To download and install py-appscript via setuptools, run the following command in Terminal:" But in Terminal, I got such warnings as: In file included from Modules/CarbonX/_OSAmodule.c:33: Modules/CarbonX/GetASFormatting.c: In function ‘ParseStyle’: Modules/CarbonX/GetASFormatting.c:33: warning: ‘FMGetFontFamilyName’ is deprecated (declared at /System/Library/Frameworks/ ApplicationServices.framework/Frameworks/QD.framework/Headers/Fonts.h: 832) .. and way down at the very end: zip_safe flag not set; analyzing archive contents... No eggs found in /tmp/easy_install-f-y69D/appscript-0.18.1/egg-dist- tmp--JzIjp (setup script problem?) I then copied osaglue to my usr/local/bin/, double-clicked on the copied osaglue and got: === Sorry, py-appscript 0.19.0+ and py-osaterminology 0.12.0+ are required to use osaglue. Please see the following page for more information: http://appscript.sourceforge.net/objc-appscript/install.html Please install these modules and run this command again. === Of course, this is due to easy_install not working! What am I missing or doing wrong? John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
appscript installation
I've downloaded appscript. I do not know if the appscript folder must be placed in a precise spot, so I just placed it where I wanted to. Maybe it should be in the Developer folder?? Since objc-appscript is based on py-appscript, I have typed sudo easy_install appscript in Terminal and the usual long output resulted. But no where can I find the osaglue tool so I can then go to Terminal (?) and type such things as: osaglue -o TEGlue TE /Applications/TextEdit.app Terminal does not understand the osaglue command. My elevator is definitely not up on this one. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: defaultCenter's addObserver
On Oct 7, 08, at 5:58 PM, j o a r wrote: On Oct 7, 2008, at 12:03 PM, John Love wrote: 2008-10-07 14:36:14.149 Calculate Medical[265:10b] *** -[NSCFSet calcStatusChanged:]: unrecognized selector sent to instance 0xe41f250 John, This type of error message indicates that your notification observer has been deallocated. This would probably be because you forgot that you have to remove notification observers before they are deallocated. In many cases you would put your unsubscribe statement in your dealloc method. Worse than that .. when I passed an observed object = nil for - addObserver, I passed an observed object = non-nil to -removeObserver. It could also indicate any other type of memory management error. NSZobieEnabled is the general facility for troubleshooting that type of problem, but in this case you could probably do with simple code inspection. Thanks for introducing me to NSZobieEnabled -- love the name! Thanks bunches, joar John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
defaultCenter's addObserver
From MyDocument's windowControllerDidLoadNib I call a method in MyController, which in turn calls: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aSelector:) name:aName object:anotherControllerObject]; The docs state that this passed object is the object that is encapsulated [NSNotification object] in the NSNotification* passed to the selector. This selector has a footprint = - (void) aSelector:(NSNotification*)sentNotification; I pass another Controller, iboAnotherCtrl, as this object: Later on I call within AnotherController: [[NSNotificationCenter defaultCenter] postNotificationName:aName object:self]; .. and everything works. Now here's the sticky .. the docs state that if this encapsulated [NSNotification object] = nil, the observer is notified when *any* encapsulated object is sent to the selector. So just for whatever, I pass object:nil to addObserver:selector:name:object:. Then, within my selector I test for the type of passed encapsulated object and something(?) doesn't work. My selector gets called for my first new MyDocument. But when I open up a second new MyDocument, the Debugger complains about an invalid aSelector. I don't understand what's going on, so I'm looking for help. Again, everything works just great when I pass a non-nil object to defaultCenter's addObserver:selector:name:object: Thanks in advance, John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSNotificationCenter
Graham Cox, Andy Lee, et. al: This violates the spirit and purpose of notifications. Your receiver shouldn't also be forcing the "transmitter" to transmit, as you are doing here. Instead, the transmitter object should always send a "status changed" message whenever its status changes. Then the fact that it has changed can be observed by the receiver *and also any other object that might be interested*. What you're doing here is absurd - if you already know the transmitter's status has changed, then you can act on that directly - you don't need to pretend to send a notification to yourself. Somewhere, you should have some code that is part of the 'sentNotifyObject' class that looks like this: - (void) postStatusChanged { [[NSNotificationCenter defaultCenter] postNotificationName:kStatusChangedNotification object:self]; } In almost all cases, whenever you call the -postNotificationName: method of NSNotificationCenter, the object you pass is 'self'. If it's any other, chances are you've done something weird. So, short answer: your design is a bit whiffy. ;) I love that word "whiffy" .. so bloody English, so Rex Harrison. I moved all -postNotificationName:object: to the receiver and so that's done; not only that, it makes sense. I am the observer, so it's the receiver that is responsible for posting or sending changes to the defaultCenter. In addition, maybe Andy is also correct when he said: I wonder if you're confusing notifications with KVO or bindings. Notifications have to be explicitly posted in order for observers to respond to them. I said originally: Shouldn't my call to -addObserver automatically monitor "StatusChanged" rather than my having to -postNotificationName?? It does, but only when the receiver posts. Having said that, let me restate it, perhaps a little more accurately: I would like to some how "bind" the observer to the receiver so that every time the receiver changes a parameter, it automatically "posts" that a change has occurred, without having to explicitly post. I believe that "KVO" stands for key-value-order .. so obviously I've got a lot of digging to do, starting with Chapter #1, where ever that is. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
NSNotificationCenter
Within MyController, I call: notifyCenter = [NSNotificationCenter defaultCenter]; [notifyCenter addObserver:self selector:@selector(mySelector:) name:@"StatusChanged" object:sentNotifyObject]; // We will be the observer and sentNotifyObject will equal the // object encapsulated in the NSNotification passed to the selector. // When this encapsulated [NSNotification object] = nil, the observer // is notified when *any* encapsulated object is sent to the selector. and mySelector looks like: - (void) mySelector:(NSNotification*)sentNotification { MyController *theNotifyObject; theNotifyObject = [sentNotification object]; if (theNotifyObject == myOtherController) { } } = Note that the sent notifyObject encapsulated in the NSNotification is a different controller than the observer, myController. Now, the questions. It appears that everytime I see a need to check the Status, I need to call: - (void) postCalculationStatusChanged:(id)sentNotifyObject { [notifyCenter postNotificationName:StatusChanged object:sentNotifyObject]; } Shouldn't my call to -addObserver automatically monitor "StatusChanged" rather than my having to -postNotificationName?? John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOperationQueue
has wrote: Getting back to the main discussion of the OP's threading/ NSOperationQueue problems, perhaps it would help if he backs up a bit and explains in general terms what he's trying to achieve, rather than focus on individual details of how he's currently trying to do it? That way, folks might be able to suggest a better overall solution, rather than getting bogged down in the details of the current, potentially misconceived, approach. Before I write a short answer to this good question .. Mike, I'm am no longer crashing into the debugger and am down to trying to get my - startCalculation into a separate thread. Also, I ditched - waitUntilAllOperationsAreFinished in order to implement what you stated, namely: = I would expect you to queue an NSOperation in the loop and if you really need to wait until all of them are done executing then you could wait after the loop. Note though, that you would still be blocking the main thread. But at least you would be taking advantage of NSOperationQueue's ability to schedule multiple operations in parallel depending on available system resources. = Back to has' big picture question ... has, I have a rather lengthy series of calculations to do, hopefully in a separate thread. In my "main.m", I init my NSOperationQueue as a global, but do not add any NSInvocationOperation's to it. In my main thread, I call -startCalculation to do exactly that. The very first statement in -startCalculation is a for-loop with a row-counter, and for each iteration of this counter I add one Operation to the queue. As my sidebar to Mike stated, I ditched - waitUntilAllOperationsAreFinished for each row in the for-loop for Mike's reason above. That's it, John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOperationQueue
No sooner do I say "Solved" that I determine "Not Solved". I am no longer crashing in part due to the fact that I've removed NSApplescript from the thread; however, the evidence is still insurmountable that the calculation is not running in a background Thread, but in the main thread. Because it's in the foreground, I lose control of my application until the Thread finishes. If you have already answered my problem, I apologize in advance for the noise. Some of this repeats what I've already posted, but I am going big-time overboard in an attempt to be complete: By way of background: 1) a IBOutlet of MyDocument = MyDocController 2) a IBOutlet of MyDocController = MyCalculationController To continue: 3) In MyDocument's windowControllerDidLoadNib I call MyDocController's MakeNewFile to which I pass the (NSURL*)theFile which is the file I just double-clicked on Cocoa's built-in open dialog. (If theFile = nil) then I open up a blank document) If theFile is not nil, then I call MyDocController's startCalculation. 4) MyDocController's startCalculation calls MyCalculationController's startCalculation. Now, the threading "fun" begins all within MyCalculationController: 6) Its Interface looks like: @interface MyCalculationController:NSObject { NSOperationQueue *itsQueue; NSInvocationOperation *itsOp; int itsCalcStatus; } 7) Its -init looks like: - (id) init { if (self = [super init]) { itsCalcStatus = kNoError; // an enumerated constant itsQueue = [[NSOperationQueue alloc] init]; itsOp = nil; } return self; } 8) Its -dealloc looks like: - (void) dealloc { [itsQueue release]; // [itsOp release]; // each Operation released after it is finished [super dealloc]; } 9) Its -startCalculation looks like: - (void) startCalculation { int row; // itsCalcStatus = kNoError; // set by -init for (row=1; row < 1; row++) { if (itsCalcStatus == kSpreadsheetStopped) break; if (itsCalcStatus != kNoError) break; itsCalcStatus = kSpreadsheetCalculating; [self startOperation]; // start new thread // if running in background, this will have no effect: [itsQueue waitUntilAllOperationsAreFinished]; } // After the for-loop completes, itsCalcStatus = // kSpreadsheetCalculating, kSpreadsheetStopped, kNoExcelApp, or kNoWorkbook // So ... if (itsCalcStatus == kSpreadsheetCalculating) { // no errors [self finishCalculation]; } else { // either stopped or an un-recoverable error = kNoExcelApp, kNoWorkbook [self stopOperation]; // this MyDocument is done and the only user option is to close this doc // and open a new doc, beginning with a fresh Queue. [itsQueue release]; } } 10) The methods called within -startCalculation look like: - (void) startOperation { itsOp = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(calculateWorksheetRow:) object:nil]; [itsQueue addOperation:itsOp]; } - (void) finishOperation { [itsOp release]; // -calculateWorksheetRow completely finished } - (void) stopOperation { [itsOp cancel]; [itsOp release]; } 11) ultimately called from MyDocument's -(IBAction) stopDocument: (id)sender: - (void) stopCalculation { itsCalcStatus = kSpreadsheetStopped; // -startCalculation breaks from its for-loop } 12) Finally, my -calculateWorksheetRow looks like: - (void) calculateWorksheetRow { // column after column after column ... [self finishOperation]; } Again, if this is too wordy, I really apoligize for all the noise. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: async NSOperation and NSOperationQueue
Michael Ash wrote: >>>>> Has it occurred to you that waiting for the operation to finish is rather at odds with the idea of trying to run it asynchronously to keep your program responsive? >>>>> Absolutely, but if the Thread is running in the background, it really shouldn't matter to the main Thread of the app. While calculations of a document are buzzing away in the background, I could be doing other things, e.g., opening other docs to get their calculations going. But, I cannot get back control until after the first document's calculations are done. By the way, -[ScriptController ExecAppleScript:] is outside my for- loop where all the Queue and Ops stuff is being manipulated. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: async NSOperation and NSOperationQueue
+ Michael Ash wrote: When your application becomes unresponsive, pause it in the debugger and look at the backtraces of all the threads. (You can do this in a single step by typing "t a a bt" at the debugger console. This is a shortcut for "thread apply all backtrace".) This should quickly tell you where it's stuck, and thus hopefully why it's stuck. + t a a bt looks like it could be a powerful tool, but, Michael, I do not understand most of the following .. I see some familar stuff, such as MPWaitOnQueue and most of the listing at the very bottom .. but how is this trace tell me where the hang is? I do see "Cannot access memory at address 0x0" with Thread3. Apparently, I've leaked memory or something rotten?? By the way, I init the Queue within the -init of the app controller. Then, in another method I go through a 100-count big for-loop, at each iteration of which I init a new NSInvocationOperation via: theOp = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(calculateWorksheetRow:) object:nil]; followed by [theQueue addOperation:theOp]; and then, [theQueue waitUntilAllOperationsAreFinished]; When each Operation completes, I start over by allocating and init-ing theOp as above. Anyway, here's the debugger listing: 2008-09-16 12:27:42.885 Calculate Medical[485:10b] okay, so far [Session started at 2008-09-16 12:27:46 -0400.] Loading program into debugger… GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33 UTC 2008) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-apple-darwin".Program loaded. sharedlibrary apply-load-rules all Attaching to program: `/Users/johnlove/Documents/XCode/Calculate Medical - ScriptCtrl - queue/build/Release/Calculate Medical.app/ Contents/MacOS/Calculate Medical', process 485. (gdb) t a a bt Thread 14 (process 485 thread 0xa00b): #0 0x001ef506 in semaphore_timedwait_signal_trap () #1 0x0022184f in _pthread_cond_wait () #2 0x002230d3 in pthread_cond_timedwait_relative_np () #3 0x03f351ba in TSWaitOnConditionTimedRelative () #4 0x03f55ecc in MPWaitOnQueue () #5 0x02152f40 in TFolderSizeTask::FolderSizeTaskProc () #6 0x03f54463 in PrivateMPEntryPoint () #7 0x002206f5 in _pthread_start () #8 0x002205b2 in thread_start () Thread 13 (process 485 thread 0xa51f): #0 0x001ef506 in semaphore_timedwait_signal_trap () #1 0x0022184f in _pthread_cond_wait () #2 0x002230d3 in pthread_cond_timedwait_relative_np () #3 0x03f351ba in TSWaitOnConditionTimedRelative () #4 0x03f55ecc in MPWaitOnQueue () #5 0x02152f40 in TFolderSizeTask::FolderSizeTaskProc () #6 0x03f54463 in PrivateMPEntryPoint () #7 0x002206f5 in _pthread_start () #8 0x002205b2 in thread_start () Thread 12 (process 485 thread 0xa213): #0 0x001ef506 in semaphore_timedwait_signal_trap () #1 0x0022184f in _pthread_cond_wait () #2 0x002230d3 in pthread_cond_timedwait_relative_np () #3 0x03f351ba in TSWaitOnConditionTimedRelative () #4 0x03f55ecc in MPWaitOnQueue () #5 0x02152f40 in TFolderSizeTask::FolderSizeTaskProc () #6 0x03f54463 in PrivateMPEntryPoint () #7 0x002206f5 in _pthread_start () #8 0x002205b2 in thread_start () Thread 11 (process 485 thread 0x943b): #0 0x0023f5e2 in select$DARWIN_EXTSN () #1 0x005aa50f in __CFSocketManager () #2 0x002206f5 in _pthread_start () #3 0x002205b2 in thread_start () Thread 10 (process 485 thread 0x8e03): #0 0x0021ff66 in kevent () #1 0x0057449f in __monitor_file_descriptor__ () #2 0x002206f5 in _pthread_start () #3 0x002205b2 in thread_start () Thread 9 (process 485 thread 0x7e23): #0 0x001ef506 in semaphore_timedwait_signal_trap () #1 0x0022184f in _pthread_cond_wait () #2 0x002230d3 in pthread_cond_timedwait_relative_np () #3 0x03f351ba in TSWaitOnConditionTimedRelative () #4 0x03f55ecc in MPWaitOnQueue () #5 0x0215891d in TPropertyTask::PropertyTaskProc () #6 0x03f54463 in PrivateMPEntryPoint () #7 0x002206f5 in _pthread_start () #8 0x002205b2 in thread_start () Thread 8 (process 485 thread 0x7957): #0 0x001f668e in __semwait_signal () #1 0x00221986 in _pthread_cond_wait () #2 0x0022136d in pthread_cond_wait$UNIX2003 () #3 0x03f5624f in TSWaitOnCondition () #4 0x03f3518e in TSWaitOnConditionTimedRelative () #5 0x03f55ecc in MPWaitOnQueue () #6 0x02150ff6 in TNodeSyncTask::SyncTaskProc () #7 0x03f54463 in PrivateMPEntryPoint () #8 0x002206f5 in _pthread_start () #9 0x002205b2 in thread_start () Thread 7 (process 485 thread 0x6b03): #0 0x001ef4a6 in mach_msg_trap () #1 0x001f6c9c in mach_msg () #2 0x0059f0ce in CFRunLoopRunSpecific () #3 0x0059fd54 in CFRunLoopRun () #4 0x02146038 in TFSEventsNotificationTask::FSEventsNotificationT
Re: async NSOperation and NSOperationQueue
Couple of things... you don't wanna create a queue every time. You should pretty much have just one queue that you add NSOperation objects to. You probably want to re-write this to be a singleton object that you get from your app controller or some other relevant place. Queue initialization now done via my appController's -init and released via -dealloc. Also, you most definitely do not want to autorelease your queue. It will end up going away on you when you least want it to or expect it to. Create your queue somewhere (hopefully in your app controller or somewhere like that) and then release it when you're absolutely sure that all your operations have run and you don't want to ever add any more. [ ... autorelease] gone with the queue explicitly released via appController's -dealloc. You /should/, however, autorelease your NSOperation since your queue will retain it when you add it and release it when it completes. Not done yet ... are saying that as soon as my Operation is complete, or the @selector method has finished, the Operation is automatically released? In spite of all the good news, my app still "appears" to be held captive by the queue and its added operations. I say "appears" deliberately because it may be due to other causes. Specifically, for example, while the queue is doing its calculation, I cannot press CMD-N to create a new document window. To continue with this specific example, CMD-N does do its thing, but only after the queue operation's calculations are finished. Ditto for CMD-Q or quitting. Let's name the controller doing these calculations CalcController which is a connected IB Outlet for another controller called OutsideController. OutsideController calls [iboCalcController startCalculation] The method/routine within OutsideController does *not* continue to its next instruction until iboCalcController's startCalculation finishes. I've begun to get a little smart on NSNotificationCenter and incorporating one of these objects within OutsideController -- but I am definitely not even remotely sure if this is the way to go. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: async NSOperation and NSOperationQueue
Ken Thomases wrote: [quote] Note that if you don't make your operation "concurrent" in this sense, but you queue it in an NSOperationQueue, that queue will still run it asynchronously, in its own thread, concurrently with other operations. It's just that, for non-"concurrent" operations, NSOperationQueue knows it has to manage the execution context itself (by spinning off a thread) [end quote] I must be doing something terribly wrong, because when I start up the NSOperationQueue that does some time consuming calculations, I do not get back control of my application until after the lengthy calculation is complete. Here are the relevant code snippets: - (void) calculateWorksheetRow:(id)data { // takes a long time here } - (void) startQueue { theQueue = [[[NSOperationQueue alloc] init] autorelease]; theOp = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(calculateWorksheetRow:) object:nil]; [theQueue addOperation:theOp]; } - (void) stopQueue { [theQueue cancelAllOperations]; // [theQueue release]; // [ ... autorelease] [theOp release]; } - (void) startCalculation { int row; for (row=1; row < 100; row++) { // stuff here [self startQueue]; // start new thread // [theQueue waitUntilAllOperationsAreFinished]; } // more stuff } John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOperationQueue
>>>>> FROM : Quincey Morris Your code is crashing because you're doing it wrong: On Sep 13, 2008, at 05:05, John Love wrote: > - (void) calculateWorksheet:(id)data { >int row; >for (row=1; row < 500; row++) { >// long calculation here >} > } > > - (void) startQueue { >NSLog(@"start queue"); // I see this in the debugger >opData = @"not used data"; >theQueue = [[NSOperationQueue alloc] init]; >theOp = [[NSInvocationOperation alloc] initWithTarget:self > > selector:@selector(calculateWorksheet:) > object:opData]; >[theQueue addOperation:theOp]; > } > > - (void) stopQueue { >NSLog(@"stop queue"); // .. but I do not see this >[theQueue cancelAllOperations]; > // [theQueue release]; // done by [theOp release] >[opData release]; >[theOp release]; > } Cancelling a NSOperation (including a NSInvocationOperation) doesn't stop it. The operation itself must detect that it was cancelled, then clean up and exit. So what this code effectively does is to release 'theOp' while it's still running. It's not surprising you're getting a crash as a result. Also, it's not clear why you think '[theOp release]' releases 'theQueue' too. Normally, you'd expect the queue to persist for the life of your application, while the operations are created, added to the queue and destroyed as needed. There's nothing absolutely wrong with creating a new queue for every operation, I guess, but you are going to have to release the queue when the operation using it is finished. >>>>> Bingo! ... thank you everyone. First, in my method -startQueue, I used: theQueue = [[[NSOperationQueue alloc] init] autorelease]; Otherwise, Quincy is accurate ... I would have to call [theQueue release] in -stopQueue. But, I still have to call [opData release]. Whoopee!! The app does not crash. You see, I somehow "assumed" that [theQueue cancelAllOperations] would release not only theQueue, but also opData. It seems "logical" that it would, but I have "almost" proven that cancelAllOperations does not .. because re-inserting the 2 releases makes the app work, well actually using autorelease on the initialization of theQueue, coupled with [theOp release]. At this point, I still have some "challenges"; namely, (1) while my queue/op is percolating, I *still* don't get back control in my app until the thread is finished; specifically, for example, I cannot press CMD-N to get a new empty window until after the thread is finished. Isn't that the purpose of multi-threading? I've got a nasty feeling that somehow I have missed something big-time significant? (2) I do all the window set-up stuff within MyDocument's - windowControllerDidLoadNib within which I call my unique -MakeNewFile and it is within -MakeNewFile that I then start the queue stuff. ... but the new window with the opened file's title does not appear until after the thread is finished ... this is probably directly related to (1) ... or maybe I'm just not calling -MakeNewFile where it should be called, namely, somewhere other than - windowControllerDidLoadNib. I think I'm almost there, but I still need some help to get to the finish line. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOperationQueue
I found the source of my mess .. should have just passed nil to my selector = calculateWorksheet: John Love = On Sep 13, 08, at 11:46 AM, Shawn Erickson wrote: On Sep 13, 2008, at 8:34 AM, John Love wrote: > For clarification: It crashes after you call stopCalculation? Does it > crash if you let the entire calculation complete? It crashes in the process of letting the entire calculation complete. Sounds like something is wrong in your calculation loop. Here is the entire Debugger log: Use GDB to understand what happened and/or run the application in Xcode under the debugger and debug the problem graphically. Try at least typing "bt" in GDB when the application gets trapped by it. Is the contents of the loop objective-c code (aka sending messages between objects) or just plain old C code? If the former are you dealing with auto released objects and correctly managing memory in the loop? -Shawn John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOperationQueue
> For clarification: It crashes after you call stopCalculation? Does it > crash if you let the entire calculation complete? It crashes in the process of letting the entire calculation complete. If I place NSLog(@"start queue") at the beginning of -startQueue, the Debugger shows "start queue". If I place NSLog(@"exit for-loop" at the very end of my -calculateWorksheet:(id)data, the Debugger does not show the "exit for-loop". During all this, I do nothing to call - stopQueue, I just let it run. Here is the entire Debugger log: [Session started at 2008-09-13 11:30:54 -0400.] 2008-09-13 11:30:58.419 Calculate Medical[358:10b] start queue [Session started at 2008-09-13 11:30:58 -0400.] Loading program into debugger… GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33 UTC 2008) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-apple-darwin".Program loaded. sharedlibrary apply-load-rules all Attaching to program: `/Users/johnlove/Documents/XCode/Calculate Medical - ScriptCtrl - queue/build/Release/Calculate Medical.app/ Contents/MacOS/Calculate Medical', process 358. [Switching to process 358 thread 0xab0f] [Switching to process 358 thread 0xab0f] [Switching to process 358 thread 0x10b] [Switching to process 358 thread 0x10b] [Switching to process 358 thread 0x10b] (gdb) John Love John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSOperationQueue
I have tried to create a Queue in which I have placed a rather lengthy calculation. Without the Queue, my app is essentially “frozen” until the calculation is completed. I have attempted to put this long calculation in a Queue, but when I try, my app literally crashes. So, here are some code snippets where I obviously need your help: @interface MyCalcController:NSObject { NSString *opData; NSOperationQueue *theQueue; NSInvocationOperation *theOp; } - (void) startQueue; - (void) stopQueue; - (void) calculateWorksheet:(id)data; - (void) startCalculation; - (void) stopCalculation; @end - (void) calculateWorksheet:(id)data { int row; for (row=1; row < 500; row++) { // very long calculation here } } - (void) startQueue { NSLog(@"start queue"); // I see this in the debugger opData = @"not used data"; theQueue = [[NSOperationQueue alloc] init]; theOp = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(calculateWorksheet:) object:opData]; [theQueue addOperation:theOp]; } - (void) stopQueue { NSLog(@"stop queue"); // .. but I do not see this [theQueue cancelAllOperations]; // [theQueue release]; // done by [theOp release]; [opData release]; [theOp release]; } - (void) startCalculation { [self startQueue]; } // I also call this method from another Controller - (void) stopCalculation { [self stopQueue]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSOperationQueue
I have tried to create a Queue in which I place a long calculation. Without the Queue, my app is “frozen” until the calculation is complete. However, my app literally crashes. So, here are some snippets where I obviously need your help: @interface MyCalcController:NSObject { NSString *opData; NSOperationQueue *theQueue; NSInvocationOperation *theOp; } - (void) startQueue; - (void) stopQueue; - (void) calculateWorksheet:(id)data; - (void) startCalculation; - (void) stopCalculation; @end - (void) calculateWorksheet:(id)data { int row; for (row=1; row < 500; row++) { // long calculation here } } - (void) startQueue { NSLog(@"start queue"); // I see this in the debugger opData = @"not used data"; theQueue = [[NSOperationQueue alloc] init]; theOp = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(calculateWorksheet:) object:opData]; [theQueue addOperation:theOp]; } - (void) stopQueue { NSLog(@"stop queue"); // .. but I do not see this [theQueue cancelAllOperations]; // [theQueue release]; // done by [theOp release] [opData release]; [theOp release]; } - (void) startCalculation { [self startQueue]; } // I also call this method from another Controller - (void) stopCalculation { [self stopQueue]; } John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
Objective-C and AppleScript
I am trying to convert as much as I can of my former Studio code over to Obj-C and thanks to this Mailing List I have been successful so far .. but here's a stumper or two: Here are 2 AppleScript statements that work in Studio: -- #1 works in Obj-C, so my question is = isn't there a more *direct* Obj-C call to do the same thing, -- rather than call NSAppleScript's executeAndReturnError method? It just seems that a one or two -- system calls should effect the same result? 1) tell application "System Events" to return (name of every application process contains "Microsoft Excel") -- see ExcelAppActive below = -- If I hard-code the actual name of the file stringByAppendingString:@"some title" (see theWorkbookActive method below), -- everything works dandy. -- -- But ... this name is actually a instance parameter, NSString* itsFileName, defined in my .h file, and dynamically set in my .m file. -- So, I type stringByAppendingString:itsFileName -- but then my app crashes. 2) tell application "Microsoft Excel" to return (name of every window contains "some title") Here is the standard (I believe) method to execute the passed Script: - (NSAppleEventDescriptor*) ExecAppleScript:(NSString*)theScript { NSAppleScript *scriptObject; NSDictionary *errorInfo; NSAppleEventDescriptor *execResult; scriptObject = [[NSAppleScript alloc] initWithSource:theScript]; errorInfo = [[NSDictionary alloc] init]; execResult = [scriptObject executeAndReturnError:&errorInfo]; return execResult; // success = (execResult != nil) } - (BOOL) ExcelAppActive { BOOL ExcelActive = FALSE; NSAppleEventDescriptor *execResult; NSArray *ExcelActiveScriptArray = [NSArray arrayWithObjects: @"tell application \"System Events\"", @"return (name of every application process contains \"Microsoft Excel\")", @"end tell", nil]; NSString *ExcelActiveScriptString = [ExcelActiveScriptArray componentsJoinedByString:@"\n"]; /* tell application "System Events" return (name of every application process contains "Microsoft Excel") end tell */ execResult = [self ExecAppleScript:ExcelActiveScriptString]; if (execResult != nil) { // success ExcelActive = [execResult booleanValue]; } if (!ExcelActive) { // do something here } return ExcelActive; } - (BOOL) theWorkbookActive { BOOL wbActive = FALSE; NSAppleEventDescriptor *execResult; if ([self ExcelAppActive]) { NSString *WorkbookActiveScript = @"tell application \"Microsoft Excel\" to return (name of every window contains \""; WorkbookActiveScript = [WorkbookActiveScript stringByAppendingString:itsFileName]; WorkbookActiveScript = [WorkbookActiveScript stringByAppendingString:@"\")"]; /* tell application "Microsoft Excel" to return (name of every window contains "some title") */ NSLog(WorkbookActiveScript); execResult = [self ExecAppleScript:WorkbookActiveScript]; if (execResult != nil) { // success wbActive = [execResult booleanValue]; } if (!wbActive) { // do something here } } else { // [self ExcelAppActive] sets and displays Error } return wbActive; } John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: I know this is a Studio question .. but I really need some help
Please check out this link that I just this second found: http://lists.apple.com/archives/applescript-studio/2008/Aug/msg2.html .. and I just confirmed what this link stipulates .. nothing to do with length: end script on -- crash after the space following "on" John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
I know this is a Studio question .. but I really need some help
The problem is XCode 3.1 and AppleScript Studio, in particular the Studio's Editor. None of the following occurs with XCode 3.0, only 3.1. I did momentarily regress to 3.0; however, this messes up all my Cocoa Obj-C code because some of the libraries have changed. 1) XCode 3.1 crashes when the .applescript file is super long 2) XCode 3.1 editor has problems displaying spaces following keywords such as "property xyz", with the display showing "propertyxyz" until I re-size the editor window. I have posted this item on bbs.macscripter.net and some have stated that they had to do a complete restore of their HD; however, my iMac G5 is very brand new. What I did do was install 3.0, followed by updating to 3.1 and still no luck with Studio. Thanks in advance for any insight on this major issue. John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Opening an external file in a external application
workSpace = [NSWorkspace sharedWorkspace]; success = [workSpace openURL:absoluteURL]; activates Excel .. what do I need to add to re-activate my Cocoa app .. "activate me" was terribly easy with AppleScript. NSApplication has methods to active your application. found it ... thanks! [NSApp activateIgnoringOtherApps:YES]; ... now back to (1,2,3) above John Love Touch the Future! Teach! Whoops ... almost ... activateIgnoringOtherApps momentarily activates my cocoa app. However, the application, Excel, keeps activating itself until it is the front application. So, I guess what I really need is a technique to determine when the app, Excel, is completely finished coming to the front and then calling activateIgnoringOtherApps. I really don't know how to do this because this "smells" of having to interrupt Cocoa's main event loop and that is a definite no-no. Maybe its a matter of asking Excel to notify "me" when it completes its startup. NSNotification?? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Opening an external file in a external application
On Aug 13, 08, at 12:09 PM, Shawn Erickson wrote: On Aug 13, 2008, at 8:17 AM, John Love wrote: On 12 Aug 2008, has wrote: Really though, what's best/practical/possible all depends on what you're trying to do, so if you want more advice then you'll need to provide more information. Very short info list is as follows (stuff I need to do from within my Cocoa app): 1) be able to save the Excel spreadsheet 2) be able to stop any calculation in progress 3) be able to detect if the user closed the spreadsheet "behind the back" of my Cocoa app, upon which my Cocoa app would raise a NSAlert. Before I forget again, one question *not* related to the above, namely, the call within my overridden readFromURL: workSpace = [NSWorkspace sharedWorkspace]; success = [workSpace openURL:absoluteURL]; activates Excel .. what do I need to add to re-activate my Cocoa app .. "activate me" was terribly easy with AppleScript. NSApplication has methods to active your application. found it ... thanks! [NSApp activateIgnoringOtherApps:YES]; ... now back to (1,2,3) above John Love Touch the Future! Teach! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Opening an external file in a external application
On 12 Aug 2008, has wrote: Really though, what's best/practical/possible all depends on what you're trying to do, so if you want more advice then you'll need to provide more information. Very short info list is as follows (stuff I need to do from within my Cocoa app): 1) be able to save the Excel spreadsheet 2) be able to stop any calculation in progress 3) be able to detect if the user closed the spreadsheet "behind the back" of my Cocoa app, upon which my Cocoa app would raise a NSAlert. Before I forget again, one question *not* related to the above, namely, the call within my overridden readFromURL: workSpace = [NSWorkspace sharedWorkspace]; success = [workSpace openURL:absoluteURL]; activates Excel .. what do I need to add to re-activate my Cocoa app .. "activate me" was terribly easy with AppleScript. John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Opening an external file in a external application
On Aug 11, 08, at 2:28 PM, John Love wrote: I have a multiple document Cocoa app where I (try to) open an external file in whatever application the file belongs to -- in my case, an Excel spreadsheet in Excel. The new Cocoa document window shown keeps track of the calculation progress in Excel via a NSProgressIndicator and a NSTextField. So, instead of opening a text file and showing it directly in the NSWindow of MyDocument, I just want to startup Excel by selecting the appropriate file in Cocoa's open dialog. I have 'XLS8' in my "info.plist" file. The Excel spreadsheet opens up and the NSProgressIndicator starts spinning and the appropriate text is placed in the NSTextField. I believe I want to do this opening within my override of - readFromURL. Am I on the right track here? John Love Found the answer -- I do need to override -readFromURL in the following manner: - (BOOL) readFromURL:(NSURL*)absoluteURL ofType:(NSString*)typeName error:(NSError**)outError { NSWorkspace *workSpace; BOOL success; workSpace = [NSWorkspace sharedWorkspace]; success = [workSpace openURL:absoluteURL]; if (success) { // do stuff here } else { // other things here } } I still need to figure out if it is possible for Excel to communicate back to my app via some sort of NSNotification. I don't have much hope of that .. so what I probably need to focus on is how to display the Excel spreadsheet in my document window. Any ideas will definitely be very appreciated. John Love P.S. -- sorry about the initial double post ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
Opening an external file in a external application
I have a multiple document Cocoa app where I (try to) open an external file in whatever application the file belongs to -- in my case, an Excel spreadsheet in Excel. The new Cocoa document window shown keeps track of the calculation progress in Excel via a NSProgressIndicator and a NSTextField. So, instead of opening a text file and showing it directly in the NSWindow of MyDocument, I just want to startup Excel by selecting the appropriate file in Cocoa's open dialog. I have 'XLS8' in my "info.plist" file. The Excel spreadsheet opens up and the NSProgressIndicator starts spinning and the appropriate text is placed in the NSTextField. I believe I want to do this opening within my override of - readFromURL. Am I on the right track here? John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
Opening an external file in a external application
I have a multiple document Cocoa app where I (try to) open an external file in whatever application the file belongs to -- in my case, an Excel spreadsheet in Excel. The new Cocoa document window shown keeps track of the calculation progress in Excel via a NSProgressIndicator and a NSTextField. So, instead of opening a text file and showing it directly in the NSWindow of MyDocument, I just want to startup Excel by selecting the appropriate file in Cocoa's open dialog. I have 'XLS8' in my "info.plist" file. The Excel spreadsheet opens up and the NSProgressIndicator starts spinning and the appropriate text is placed in the NSTextField. I believe I want to do this opening within my override of - readFromURL. Am I on the right track here? John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
readFromURL for the current document window, versus a new document window
The challenge is what to override in MyDocument such that when I select "Open..." I can load a file into the currently active window *if* there is an active window; *and* if no active document window, then do the standard Cocoa stuff, that is, [super readFromURL ...] and load the file into the newly created window. I have poured over the Cocoa docs about document based apps and have overridden readFromURL: ... but a new window always appears with the file, even if there previously was a window active. It appears, based on my skimpy knowledge, that NSDocumentController's call to openDocument: leads to addDocument:, i.e, a new document window. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSDocumentController, NSDocument and toolbars
> > Well, what do you want the tool bar item to actually *do*? Whatever it is, > and whatever object is responsible for handling it is your action and > target, respectively. Just like a menu item. > I want it to call NSDocumentController's openDocument: which is the action of the "Open ..." File menu item. I use my override of NSDocument's readFromURL: to do my unique stuff after NSApp's runModal dialog is dismissed. > > openDocument: is a method of NSDocumentController, not NSDocument ... >> *unless* I place this action method within my MedDocument ... and such a >> place is clearly wrong >> > > So maybe set the target to the document controller, not self? > Absolutely . So in my sub-class of NSDocument, I call my own customized Toolbar routine(s) within my override of -windowControllerDidLoadNib. Just how do I pass an instance of NSDocumentController to these Toolbar routine(s)? Only the NSWindowController is passed to the windowControllerDidLoadNib method, not the NSDocumentController? If I can somehow get an instance of NSDocumentController, then I could call: [MyNSDocumentController URLsFromRunningOpenPanel]; which apparently is the 1st thing done within openDocument: Which begs the question .. do I also wish to create a sub-class of NSDocumentController within my mainNib file also and do the Toolbar stuff within there .. don't see how right now, but I have done very little thinking about this possibility. If I seem like I'm grasping at a windmill, that is very accurate. John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
NSDocumentController, NSDocument and toolbars
I sub-class NSDocument and call it MedDocument. My code is similar to Apple's SimpleToolbar .. the biggest difference is that I create a Category = MedDocument+ToolbarDelegateCategory in order to compartmentalize the code, i.e., keep the toolbar stuff in a separate file. And it works .. except for one item; that is, within the delegate methods: - (NSToolbarItem*) toolbar:(NSToolbar*)toolbar itemForItemIdentifier:(NSString*)itemIdent willBeInsertedIntoToolbar:(BOOL)willBeInserted; and - (void) toolbarWillAddItem:(NSNotification*)notif; I call: [toolbarItem setTarget:self]; [toolbarItem setAction:@selector(openDocument:)]; as Apple specifies. But openDocument: is a method of NSDocumentController, not NSDocument ... *unless* I place this action method within my MedDocument ... and such a place is clearly wrong .. besides in Apple's sample it is not there. What I *do* want to override within MedDocument is: - (BOOL) readFromURL:(NSURL*)absoluteURL ofType:(NSString*)typeName error:(NSError**)outError; as one of the few methods which Apple specifies should be overridden. What is going on here? John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSDocument's isDocumentEdited
In the following, I have expanded on what I believe I have learned Grayson's response. (Any errors are mine, not Grayson's) Apple's comments within their "NSDocument.h" state that with: - (void)updateChangeCount:(NSDocumentChangeType)change "Record the fact that a change affecting the value returned by isDocumentEdited has occurred. ... Your application only needs to invoke this method explicitly if it is not taking advantage of NSDocument's built-in undo support. The default implementation of this method also sends all of the document's window controllers setDocumentEdited: messages when appropriate." I have deleted my override of NSDocument's –isDocumentEdited within MyDocument.m and recorded the fact that MyDocument may have been edited via calling my own setFileEdited whenever I see a possibility of editing MyDocument. - (void) setFileEdited { BOOL isEdited; if (whateverParm1 || whateverParm2) isEdited = TRUE else isEdited = FALSE; if (isEdited) [self updateChangeCount:NSChangeDone]; else [self updateChangeCount:NSChangeCleared]; } Apple states that NSChangeDone is the value to pass to updateChangeCount: to indicate that a single change has been done .. NSChangeCleared is the value to pass to indicate that the document has been synchronized with its file or file package. Based on Apple's comments at the top of this entry and in other sources, NSDocument's isDocumentEdited is called when updateChangeCount: records a change. Window's "dirty" flag is automatically set/cleared by Cocoa following its call to –isDocumentEdited. So, I do not have to override –isDocumentEdited for this purpose; rather I just have to call updateChangeCount when appropriate, and Cocoa takes care of the rest. For those who have a separate Controller which needs to address setFileEdited issues, use standard a delegate call, coupled with a informal protocol. When MyDocument initially calls MyController, MyDocument passes self as the delegate and within MyController, self is stored in MyController's mDocDelegate which is typed as a generic id pointer. setFileEdited: would now be in MyController.m, and its setFileEdited: would have: if (isEdited) [mDocDelegate updateChangeCount:NSChangeDone]; else [mDocDelegate updateChangeCount:NSChangeCleared]; An informal protocol is added to the mix because mDocDelegate, as just stated, is typed as a generic id pointer and the real identity (a pointer to MyDocument) is finally resolved only at run-time. So, add the following to MyController.h: @interface NSObject (MyController) - (void) updateChangeCount:(NSDocumentChangeType)change; @end In summary, I have outlined two scenarios .. test for document editing within your MyDocument or within a separate Controller. In either case, you just need to call updateChangeCount, rather than mess with overriding NSDocument's –isDocumentEdited. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
NSDocument's isDocumentEdited
Within MyDocument's isDocumentEdited I have code to determine whether MyDocument is edited and return the BOOLean flag accordingly. I then discovered that the only way to set the window's "dirty" flag was to *explicitly* call [window setDocumentEdited:editedFlag] within other methods by duplicating the same code I have in MyDocument's isDocumentEdited method, followed by setDocumentEdited on the window. My "off the wall" guess *was* that Cocoa's main event loop called isDocumentEdited and then set the window to "dirty" if needed. This guess is wrong, or otherwise I would not have had to set the window to "dirty" elsewhere. Anyone have a clue here? Cheers, John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Toolbar code in separate Controller?
... and the lights went on ... and I hear fireworks! Andy said "I think of each of those bunches as categories of methods." YES!, not a category of an object, but a logically separate category of methods belonging to the object. So, @interface MyDocument (NSToolbarItemValidation) adds the methods of NSToolbarItemValidation to MyDocument. Now ... to delegate stuff ... I've reached a conclusion based on ADC's "Cocoa and Objective-C" and on good-ole MW (haven't gotten "Design Patterns" yet) that: (1) the sheet is the delegate of FC because the FC is asking the sheet what to do and the FC implements the sheet's decision (2) (here is when the lights went on) the FC is the delegate of the NSWindow because the window is asking the FC what to do and the window implements the FC's returned decision. OF COURSE the FC is the delegate of the NSWindow because that is the way IB has this relationship hooked up. (3) because the delegate "chain" is a chain, I have to go back up the chain and ask "Who is the original delegate?" .. and the answer, my friends, is the FC which is the delegate of NSWindow. the window asks the FC, which then asks the sheet .. the original delegate = FC, so that's what we always call the FC. Again, life is good! John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Toolbar code in separate Controller?
> Well, what are you asking? Does the code work or not? If not, what are the > symptoms? > Yes, it works without a shred of doubt .. I'm just trying to get my hands around "Category" .. there is no doubt whatsoever that unless I use "Category", no one will know what I'm talking about .. it just would be nice if Cocoa's "Category" would meld with Merriam Webster's definition of "category" .. probably too much to ask. Programmers are rarely accused of using "plain English" all the time, anyway. Cheers, John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Toolbar code in separate Controller?
dateMenuItem: message is sent to the File's Owner = MyDocument, which is the "root" that has been added to .. and it is the File's Owner that is the target of the menu actions. The "category" is not a new, separate class, just an addition to the alrady-existing class. It would be very tempting here to call the "category" a sub-class, except the latter can store not only unique methods, but also its own instance variables which a "category" cannot have in its interface. These added instance variables must be at the "root" of the "category". My current challenge addresses the enabling, or disabling, of my several ToolbarItems via Apple's validateToolbarItem: method ... the subject adds "extensions" to the mix. I have within "MyDocument+ToolbarCategory.h": @interface MyDocument (ToolbarCategory) // for example (void) setupToolbar:(NSWindow*)theWindow; @end and have added toolbar-unique instance variables to MyDocument(the "root"), such as: IBOutlet NSToolbarItem *saveSpreadsheetItem; So the new "category" is complete … but what about: (BOOL) validateToolbarItem:(NSToolbarItem*)theItem; which Apple states "is sent to validators for each visible NSToolbarItem with a valid target/action pair.". Apple continues: "NSToolbarItemValidation *extends*(emphasis added) the standard validation idea by introducing this new method which is sent to validators for each visible standard NSToolbarItem with a valid target/action pair. "Standard items validate themselves by sending the validateToolbarItem: validate message to the current validator. Since items with custom views don't always have meaningful target/actions, they do nothing. So for your custom items it may be useful to override this method and invent your own validation." So, here, we make MyDocument the current validator – on "first blush", this syntax appears to say that NSToolbarValidation is a *new* "category" of, or "addition" to MyDocument: @interface MyDocument (NSToolbarItemValidation) - (BOOL) validateToolbarItem:(NSToolbarItem*)toolbarItem; @end Within "MyDocument+ToolbarCategory.m" we add: // Here, we make MyDocument the current validator. // Our MyDocument has a new category = NSToolbarItemValidation (??): @implementation MyDocument (NSToolbarItemValidation) - (BOOL) validateToolbarItem:(NSToolbarItem*)toolbarItem { BOOL enable = NO; // NSLog(@"validateToolbarItem"); // success! if ([[toolbarItem itemIdentifier] isEqual:OpenDocToolbarItemIdentifier]) { if ([iboFileCtrl fileFinishedCalculation]) enable = YES; } else if ([[toolbarItem itemIdentifier] isEqual:SaveDocToolbarItemIdentifier]) { // iboFileCtrl is my single IBOutlet for MyDocument // Thanks! Graham for the lesson on naming conventions. if (![iboFileCtrl fileSaved]) enable = YES; } else if ([[toolbarItem itemIdentifier] isEqual:StopDocToolbarItemIdentifier]) { if (![iboFileCtrl fileFinishedCalculation]) enable = YES; } return enable; } @end To tell you the truth, I *really* prefer calling a category an extension because "extension" just sounds more meaningful to me. Or, maybe just plain, ole, generic "addition". "Category" just sounds like "type of" or a sub-class, but it's not that at all. Yes, we're discussing words, but words are important .. Look up "category" in a dictionary where it talks about classification. To me, classification means sub-class. An antelope is a type of animal. Way at the beginning of all this, I am adding to or extending MyDocument to include menu stuff. Menu stuff is not a "type of" MyDocument. Back to NSToolbarItemValidation .. it is not a "type of" MyDocument. So, based on the above, I should not call it a "category" of MyDocument. So what do I call it? Is it an "extension" of MyDocument? Apple states " NSToolbarItemValidation extends the standard validation idea ..". In Apple's Objective-C pdf, Apple sttates "Class extensions are like 'anonymous' categories ..". I've reached a road block here .. Apple says "extends the standard validation idea", yet: @interface MyDocument (NSToolbarItemValidation) implies that NSToolbarItemValidation extends MyDocument. I stand at a road block .. would appreciate some help here! Cheers, John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Toolbar code in separate Controller?
Uli - To enable/disable the toolbar items, Cocoa uses the NSUserInterfaceValidation protocol, and asks each responder in the responder chain, beginning at the first responder. Have you inserted your toolbar controller in the responder chain so it actually gets asked whether these methods should be enabled? Initially, my ToolbarController was sub to NSObject as was the case for Apple's SimpleToolbar, so I changed the super class of my ToolbarController to NSControl. Since NSControl is a NSView, shouldn't the toolbar automatically be in the Responder chain, just as any NSView in the window? I read somewhere that NSView calls [self setRefusesFirstResponder:FALSE] ? John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
Toolbar code in separate Controller?
Apple's SimpleToolbar code *is all* their MyDocument.m. My app would like to place the toolbar-specific code *in a separate Controller*, say "ToolbarController". This transfer does work to a limited extent, that is, the toolbar does in fact appear at the top of the window, as it should. However, *what does not work* is the enabling/disabling based on the specified target .. all toolbar items are disabled. Details are as follows: *Within MyDocument.h*: @interface MedicalDocument:NSDocument { IBOutlet ToolbarController *iboToolbarCtrl; IBOutlet FileController*iboFileCtrl; // etc. } *Within MyDocument.m*: - (void) windowControllerDidLoadNib:(NSWindowController*)aController { [super windowControllerDidLoadNib:aController]; // etc [iboToolbarCtrl retainOutlets]; [iboToolbarCtrl setupToolbar]; // etc } *Within ToolbarController.h* – all of which is taken from SimpleToolbar (except being in a separate Controller, versus all in MyDocument.m) #import #import "FileController.h" @interface ToolbarController:NSObject { IBOutlet NSToolbarItem *openSpreadsheetItem, *saveSpreadsheetItem, *stopCalculationItem; IBOutlet NSObject *openItemOutlet, *saveItemOutlet, *stopItemOutlet; IBOutlet FileController *iboFileCtrl; IBOutlet NSWindow *iboDocWindow; } - (void) dealloc; - (void) retainOutlets; - (void) setupToolbar; - (NSToolbarItem*) toolbar:(NSToolbar*)toolbar itemForItemIdentifier:(NSString*)itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted; - (NSArray*) toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar; - (NSArray*) toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar; - (void) toolbarWillAddItem:(NSNotification*)notif; - (void) toolbarDidRemoveItem:(NSNotification*)notif; - (BOOL) validateToolbarItem:(NSToolbarItem*)toolbarItem; - (BOOL) validateMenuItem:(NSMenuItem*)item; @end As stated at the start, the toolbar does in fact appear where it's supposed to .. *it's just that all the items are disabled??* Within *ToolbarController.m*, my setupToolbar method is identical to Apple's, namely: - (void) setupToolbar { NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier:MyDocToolbarIdentifier] autorelease]; [toolbar setAllowsUserCustomization:YES]; [toolbar setAutosavesConfiguration:YES]; [toolbar setDisplayMode:NSToolbarDisplayModeIconOnly]; [toolbar setDelegate:self]; [iboDocWindow setToolbar:toolbar]; } My: *-** (NSToolbarItem*) toolbar:(NSToolbar*)toolbar itemForItemIdentifier:(NSString*)itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted;* *except, I have such things as*: [toolbarItem setTarget:iboFileCtrl]; [toolbarItem setAction:@selector(saveSpreadsheet:)]; My: *- (void) toolbarWillAddItem:(NSNotification*)notif;* *except, I have such things as*: [openSpreadsheetItem setTarget:iboFileCtrl]; [openSpreadsheetItem setAction:@selector(openSpreadsheet:)]; since FileController.m contains the method openSpreadsheet Further on: *-** (BOOL) validateToolbarItem:(NSToolbarItem*)toolbarItem* { BOOL enable = NO; if ([[toolbarItem itemIdentifier] isEqual:OpenDocToolbarItemIdentifier]) { enable = YES; } else if ([[toolbarItem itemIdentifier] isEqual:SaveDocToolbarItemIdentifier]) { if (![iboFileCtrl fileSaved]) enable = YES; } else if ([[toolbarItem itemIdentifier] isEqual:StopDocToolbarItemIdentifier]) { if (![iboFileCtrl fileFinishedCalculation]) enable = YES; } return enable; } And even later: *- (void) toolbaritemclicked:(NSToolbarItem*)toolbarItem* { if ([[toolbarItem itemIdentifier] isEqual:OpenDocToolbarItemIdentifier]) { [iboFileCtrl openSpreadsheet]; } else if ([[toolbarItem itemIdentifier] isEqual:SaveDocToolbarItemIdentifier]) { [iboFileCtrl saveSpreadsheet]; } else if ([[toolbarItem itemIdentifier] isEqual:StopDocToolbarItemIdentifier]) { [iboFileCtrl stopCalculation]; } } Thanks to the patience of Graham Cox and others, I have learned a great deal about targets and delegates .. so, I pray that my error does not involve these concepts .. so I can at least say that my ignorance is on new ground. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Prevent Asynchronous operation of beginSheetModalForWindow
> (1) warning: no doSheetSelection:contextInfo method found which, I think, >> is >> due to the fact that the external class of mFileSheetDelegate = >> FileController, yet when referenced in SaveSheetController, it's = id, a >> general pointer. But, I thought all anonymous pointers were resolved at >> runtime ... am I just going to force myself to ignore this Build Warning, >> knowing that it will all go away at runtime??? >> > > > The reason for this is because the sheet controller is not aware of your > File Controller's methods. Nor should it be. So how to resolve it? The > answer is to declare the callback method as an informal protocol *within > SheetController.h* Thus: > > I figured this out while I was mowing the lawn yesterday (before reading this reply) (really!) -- do not have a clue what sort of Freudian psychology this demonstrates -- cutting off the heads of delegates and informal protocols, maybe? Regardless of the deviant psychology, I remember thinking (while pushing the mower) "so that's what informal protocols are good for .. delaying the presentation of Build Errors until runtime when all unresolved references are - duh - resolved!!!" > > (2)I still get "unrecognized selector" .. but, >> > > That's because you're targeting the wrong object. Here: > no psychology here, just plain brain-dead on my part > > You have got to get these relationships straight in your mind. It's not > that hard. I've goaded and prompted you and written your code for you piece > by piece - that's great, it solves your problem. But has it increased your > understanding? I fear it hasn't, and it still all seems like voodoo. I'm not > sure what I can do about that. > Amen to that .. no excuses here .. trying to do too many things at once .. get re-acquainted with C, trying to use the same logic as my application's AppleScript Studio Project counterpart .. Cocoa delegates .. who does what to whom behind the scenes. Anyway, it finally sunk in to keep all UI objects(buttons) local to the individual sheet controllers and have the file controller worry only about return codes. I also figured out (quirky psychology as noted above) informal protocols .. my file controller imports "WhateverSheetController.h" and to do away with informal protocols would necessitate "WhateverSheetController.h" to import "FileController.h", aka a perfect circle, aka failure to compile. BTW, the reason for my originally passing (NSWindow*)sheet to "doSheetSelection" within FileController.m was so this method could call [sheet closeOut:self] .. not required now that I call the latter within the sheet's didEndSelector. I'll guarantee you one thing .. no one could ask for a more patient teacher that you .. trust me, I mean that, every syllable. You remind me of an old Physics prof I had many, many, many years ago who made physics sound so darn simple (once it sunk in, which it did with minimal effort since I was so young at the time). Anyway, got some more things to understand (Menus and Toolbars) and probably more questions to ask later, so ... John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Prevent Asynchronous operation of beginSheetModalForWindow
Graham, Yup, Nathan the double indirection of id * 1st, just the key snippet from FileController.m: @implementation FileController id mFileSheetDelegate; = Here's the complete interface and implementation files for just one SheetController, which has 2 buttons in its sheet window: // SaveSheetController.h #import @interface SaveSheetController:NSWindowController { IBOutlet NSTextField *iboSaveDescription; } - (void) showSheetOnParentWindow:(NSWindow*)parentWindow withDescription:(NSString*)theDescription delegate:(id)theTarget contextInfo:(void*)contextInfo; - (void) sheetDidEnd:(NSWindow*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo; - (IBAction) saveIt:(id)sender; - (IBAction) dontSaveIt:(id)sender; - (void) closeSheet:(id)sender withCode:(int)theCode; @end === // SaveSheetController.m #import "SaveSheetController.h" enum { kJustSave, /* 0, 1 */ kJustNotSave }; @implementation SaveSheetController extern id mFileSheetDelegate; - (void) showSheetOnParentWindow:(NSWindow*)parentWindow withDescription:(NSString*)theDescription delegate:(id)theTarget contextInfo:(void*)contextInfo { mFileSheetDelegate = theTarget; if (theDescription) { // do magic } [NSApp beginSheet:[self window] modalForWindow:parentWindow modalDelegate:theTarget didEndSelector:@selector (sheetDidEnd:returnCode:contextInfo:) contextInfo:contextInfo]; } // 2 buttons of saveSheet - (IBAction) saveIt:(id)sender { [self closeSheet:sender withCode:kJustSave]; } - (IBAction) dontSaveIt:(id)sender { [self closeSheet:sender withCode:kJustNotSave]; } - (void) closeSheet:(id)sender withCode:(int)theCode { NSWindow* theSheet; theSheet = [sender window]; [NSApp endSheet:theSheet returnCode:theCode]; // calls didEndSelector } - (void) sheetDidEnd:(NSWindow*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo { [mFileSheetDelegate doSheetSelection:returnCode contextInfo:contextInfo]; [sheet orderOut:self]; } @end Finally, a snippet or two from [doSheetSelection:contextInfo]: - (void) doSheetSelection:(int)returnCode contextInfo:(void*)contextInfo { /* If we had different sheets returning the same code, then we would select between the different sheet IDs. But, for our case, all returned IDs are unique. if ([(NSString*)contextInfo isEqualToString:sCalculateSheetID]) { } if ([(NSString*)contextInfo isEqualToString:sSaveSheetID]) { } if ([(NSString*)contextInfo isEqualToString:sErrorSheetID]) { } */ switch (returnCode) { case kJustSave: [self saveSpreadsheet]; gShouldCloseDoc = TRUE; break; case kJustNotSave: [self setStatus:sFileNotSavedMsg]; gShouldCloseDoc = TRUE; break; } Okay ... all the snippets are done ... now, the questions: (1) warning: no doSheetSelection:contextInfo method found which, I think, is due to the fact that the external class of mFileSheetDelegate = FileController, yet when referenced in SaveSheetController, it's = id, a general pointer. But, I thought all anonymous pointers were resolved at runtime ... am I just going to force myself to ignore this Build Warning, knowing that it will all go away at runtime??? (2)I still get "unrecognized selector" .. but, didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) is within the sheet.m .. good grief! John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Prevent Asynchronous operation of beginSheetModalForWindow
Graham, Still pouring over your thesis .. in process, so let me ask just one thing at a time, rather than chew here on the whole thing. (1) learning about anonymous type = (id) .. I make this call within FC: [iboCalculateSheetCtrl showSheetOnParentWindow:itsWindow withDescription:nil delegate:self contextInfo:sCalculateSheetID]; The delegate here is FileController*, where the delegate received within SC's showSheetOnParentWindow looks like: - (void) showSheetOnParentWindow:(NSWindow*)parentWindow withDescription:(NSString*)theDescription delegate:(id)theTarget contextInfo:(void*)contextInfo { mFileSheetDelegate = theTarget; // etc. } and at the very top: @implementation CalculateSheetController id *mFileSheetDelegate; Within the implementation of showSheetOnParentWindow, I get "assignment from incompatible pointer type" with: mFileSheetDelegate = theTarget; and later on within this SC's implementation: - (void) sheetDidEnd:(NSWindow*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo { [mFileSheetDelegate doSheetSelection:sheet returnCode:returnCode contextInfo:contextInfo]; } I get: "warning:invalid receiver type 'id'" and "no matching doSheetSelection:returnCode:contextInfo". Based on the "invalid .." warning, I understand "no matching ..". By the way my FC has the formal doSheetSelection:returnCode:contextInfo selector or method .. one final thing on this item, I do not really understand "informal protocols", so I have not yet tried to implement such. John ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Prevent Asynchronous operation of beginSheetModalForWindow
Completed the housekeeping I needed to do .. so I began moving all the sheet code over to SheetController. Within FileController, I have 3 IBOutlets which are the 3 different sheet NSWindow's *and* the same 3 sheet NSWindow outlets for SheetController. I need to pass the specific sheet to my showSheet method within FileController and the showSheet method within SheetController needs to differentiate between the 3 different ones in order to place the "withDescription" NSString in the appropriate NSTextField of each sheet. All buttons for each sheet are connected to various IBAction's in FileController. The resulting calls from FileController to SheetController look like this: [theSheet showSheet:saveSheet forWindow:itsWindow withDescription:nil onCompletion:nil]; *and* ** please note that for now, I always pass nil for the completion selector because I haven't *yet* figured out what to do within that selector (probably just a long switch statement based on enumerated constants - I did *not* know that Objective C is based on C, not C++ - I got "case identifier needs constant integer", so placed constants inside an enum). Anyway, I keep getting "unrecognized selector sent to instance ..." (see footprint at the very bottom of this message). In the meantime, I call within FileController: shouldClose = ([theSheet getReturnCode] == doCloseDoc); // should I close the mainWindow or not? once I get a handle on that "unrecognized selector" error, I can get rid of any calls from FileController to SheetController's getReturnCode. ** an example of an IBAction method within FileController (that is connected within IB to one of the sheet buttons): - (IBAction) keeponCalculating:(id)sender { [theSheet closeSheetWithCode:notCloseDoc]; // or, doCloseDoc, integers 0 or 1, depending on method [self doSomethingHere]; } The showSheet, getReturnCode and closeSheetWithCode methods within SheetController looks like: - (void) showSheet:(NSWindow*)whichSheet forWindow:(NSWindow*)theWindow withDescription:(NSString*)theDescription onCompletion:(SEL)doThis { if (theDescription) { if (whichSheet == calculateSheet) { if (calculateDescription) // if connected in IB [calculateDescription setStringValue:theDescription]; } else if (whichSheet == saveSheet) { // etc } else if (whichSheet == errorSheet) { // etc. } [NSApp beginSheet:whichSheet modalForWindow:theWindow modalDelegate:nil // right now, I pass nil as doThis, but if I pass @selector(sheetDidEnd:returnCode:contextInfo:) // I get "unrecognized selector sent to instance ..." didEndSelector:doThis contextInfo:nil]; itsReturnCode = [NSApp runModalForWindow:whichSheet]; [NSApp endSheet:whichSheet]; [whichSheet orderOut:self]; } /* -- doThis defined in FileController.m - (void) sheetDidEnd:(NSWindow*)whichSheet returnCode:(int)returnCode contextInfo:(void*)contextInfo { } */ - (int) getReturnCode { return itsReturnCode; } - (void) closeSheetWithCode:(int)theCode { [NSApp stopModalWithCode:theCode]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Prevent Asynchronous operation of beginSheetModalForWindow
I have your previous message typed out and I really have read it ... and I will re-read it and re-read until it clicks. You know how I feel about compartmentalization. I really don't want to abandon it because compartmentalization does work for me for the NSProgressIndicator that I have, as well as my Toolbar. The only saving grace is that I've got sheets down to a science when I meld my sheet code into FileController ... and you have no idea how happy that makes me. Right now, I'm cleaning up the code ... renaming outlets and some instance variables so they sound like "plain English". When I am finished with this housekeeping, I fully intend to return to sheet compartmentalization ... I have not given up ... I just wanted to get sheets to work. I will give you all the feedback when the elevator reaches the top. With regards, John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Prevent Asynchronous operation of beginSheetModalForWindow
Hello, Graham ... Because I have multiple calls to show a sheet, from various parts of my FileController, and because I wanted to make my sheet calls as general as possible, I really .. really .. wanted to have a distinct SheetController. As a result, I made calls from FileController to look like:[theSheet showSheet:itsWindow], where theSheet was an outlet of FileController. I could get away with that since all my sheets had just one button .. except one, which had 3 buttons .. and for that exception, the asynchronous nature of sheets got in the away. I have not given up on a separate SheetController .. however .. I finally reduced my showSheet routine to something very, very short and placed it in FileController .. - (void) showSheet: (NSWindow*)theSheet forWindow:(NSWindow*)theWindow withDescription:(NSString*)theDescription { if (theDescription) { if (theSheet == calculateSheet) { if (calculateDescription) // NSTextField outlets of FileController, 1 per sheet [calculateDescription setStringValue:theDescription]; } else if (theSheet == saveSheet) { if (saveDescription) [saveDescription setStringValue:theDescription]; } else if (theSheet == errorSheet) { if (saveDescription) [saveDescription setStringValue:theDescription]; } } [NSApp beginSheet:theSheet modalForWindow:theWindow modalDelegate:nil didEndSelector:nil // @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:nil]; itsReturnCode = [NSApp runModalForWindow:theSheet]; // (int) itsReturnCode in FileController.h [NSApp endSheet:theSheet]; [theSheet orderOut:self]; } When I called showSheet, it looked like: [self showSheet:calculateSheet forWindow:itsWindow withDescription:nil]where calculateSheet, showSheet and errorSheet were 3 IBOutlets of FileController, all of class = NSWindow. Every button of each sheet was connected to a specific IBAction of FileController, e.g., - (IBAction) dontSaveIt:(id)sender { [self closeSheetWithCode:doCloseDoc]; } with that last message looking like: - (void) closeSheetWithCode:(int)theCode { [NSApp stopModalWithCode:theCode]; } As the docs explain, when you do that, the message [NSApp runModalForWindow:] returns that identical integer, which can be any integer of your choosing. In my case, the integer choices trigger a decision whether to close the mainWindow after the sheet is closed, or whether to keep mainWindow open after the sheet is closed. I did not even have to mess with sheetDidEnd selectors because closeSheetWithCode returned gave the needed flag I could use to quantify the itsReturnCode instance variable of FileController. Anyway, I have sheets, not the relatively antequated separate dialogs. I have no intention of giving up on a separate SheetController .. but, in the meantime, I have something that works. Best regards, John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
Prevent Asynchronous operation of beginSheetModalForWindow
Before I begin, I want to assure you that I have researched entries here on sheets, as well as those in MacTech.com. It's reasonably probable that I have missed some entries and so that is why I am asking for help. I also realize that this description is very long and I *really* did try to shorten it. My app is a Cocoa Document based app. I have chosen the title "Prevent Asynchronous operation of beginSheetModalForWindow" because I use various calls to beginSheetModalForWindow in many parts of my app code and in one case I need the calls to didEndSelector to be completed *before* the code that follows beginSheetModalForWindow is executed (see MyDocument.m below). With Asynchronous operation, the sheet will show for a very brief moment and continue as the Apple docs stipulate .. I want the sheet to stay down UNTIL I click one of the buttons in the sheet. "MacTech" names calls to beginSheetModalForWindow "DocModalNew". What have I tried to do, but without success: *1)* After the call to [calculateSheet beginSheetModalForWindow:docWindow .. etc]; within showCalculateSheet, I have used: while (itsReturnCode == -1) // the initialized value before the call to beginSheetModalForWindow What happens is a never-ending loop from which I need to force-quit. *2)* Within shouldCloseFile I have called: while ((theReturnCode = [theSheet getReturnCode]) == -1); // same never-ending loop results The app's File's Owner is MyDocument // inside my nib file I have a NSObject named "FileController" and "SheetController" // in MyDocument.h #import #import "FileController.h" @interface MyDocument:NSDocument { IBOutlet FileController*theFile; IBOutlet NSWindow *documentWindow; // passed to methods in FileController.m } // signatures of various methods here @end // in MyDocument.m if ([theFile shouldCloseFile]) { // stuff that canNOT be executed until shouldCloseFile finishes } == // in FileController.h #import #import "SheetController.h" @interface FileController:NSObject { IBOutlet SheetController *theSheet; NSWindow *itsWindow; } - (BOOL) shouldCloseFile; // plus other signatures @end == // in FileController.m // itsWindow is quantified elsewhere in this .m listing by anoter call within MyDocument.m - (BOOL) shouldCloseFile { int theReturnCode; BOOL shouldClose = TRUE; if (!itsFinishedCalculation) { [theSheet showCalculateSheet:itsWindow]; // tried this, but had to force-quit // while ((theReturnCode = [theSheet getReturnCode]) == -1); theReturnCode = [theSheet getReturnCode]; if (theReturnCode == NSAlertFirstButtonReturn) { // "Continue" shouldClose = FALSE; } else if (theReturnCode == NSAlertSecondButtonReturn) { // "Stop and save" [self saveFile]; NSLog(@"NSAlertSecondButtonReturn"); } } return shouldClose; } == // SheetController.h #import @interface SheetController:NSObject { NSWindow *itsWindow; // passed to "show" methods int itsReturnCode; } - (int) getReturnCode; - (void) showCalculateSheet:(NSWindow*)docWindow; - (void) endCalculateSheet:(NSAlert*)theSheet returnCode:(int)returnCode contextInfo:(void*)contextInfo; @end == // SheetController.m #import "SheetController.h" @implementation SheetController - (id) init { if (self = [super init]) { itsReturnCode = -1; } return self; } - (int) getReturnCode { return itsReturnCode; } - (void) showCalculateSheet:(NSWindow*)docWindow { NSButton *cButton, *sButton, *dButton; itsWindow = docWindow; // set instance variable NSAlert *calculateSheet = [[[NSAlert alloc] init] autorelease]; [itsWindow setDelegate:calculateSheet]; cButton = [calculateSheet addButtonWithTitle:@"Continue"]; // [cButton setKeyEquivalent:@"\r"]; // automatic for default button sButton = [calculateSheet addButtonWithTitle:@"Stop and save"]; [sButton setKeyEquivalent:@"s"]; dButton = [calculateSheet addButtonWithTitle:@"Stop and don't save"]; [dButton setKeyEquivalent:@"d"]; [calculateSheet setMessageText:@"You have not finished calculating your Spreadsheet.\n" "Do you wish to continue calculating?"]; [calculateSheet setAlertStyle:NSWarningAlertStyle]; itsReturnCode = 1; [calculateSheet beginSheetModalForWindow:docWindow modalDelegate:self didEndSelector:@selector (endCalculateSheet:returnCode:contextInfo:) contextInfo:docWindow]; // while (itsReturnCode == -1); // tried this, but had to force-quit } - (void) endCalculateSheet:(NSAlert*)theSheet returnCode:(int)returnCode contextInfo:(void*)contextInfo { if (returnCode == NSAlertFirstButtonReturn)// "Continue" {
Re: NSWindow does not support utility styleMask 0x10 ???
Keary Suska wrote: === Here's a clue: http://lists.apple.com/archives/Cocoa-dev/2007/Nov/msg02233.html === Yes, I do see this input. Since way back when I did create this NSWindow with IB 2.x, I went to the trouble of starting over with a new NSWindow and I still get the same set utility mask error in my NSLog window. Also, what's really wierd when within IB I change my NSWindow to a NSPanel, this utility mask checkbox is not checked, so I set the class back to NSWindow and the identical log entry.. I have looked over the archives and I do not see anything else that illuminates the problem ... but, because I am very human, I could have missed something. I would be indebted to anyone who could find something else that obviously I have missed. As an aside, this "nswindow does not support utility stylemask 0x10" log entry appears twice ?? Best of regards, John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
NSWindow does not support utility styleMask 0x10 ???
This error appears when a window shows in my document-based app via MyDocument's -windowDidLoadNib method. any clues about this mystery ??? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Alert Sheets hard wired in Interface Builder
Thank you everyone ... I went back to Apple Docs on Sheets and found everything you stated ... I apologize for not being a careful reader. John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Alert Sheets hard wired in Interface Builder
1) I found the culprit on the sheet appearing as a separate window, and not a sheet .. you were right cause somehow the passed docWindow was apparently nil .. anyway, called my sheet routine from a different part of MyDocument.m .. and now the sheet appears as a sheet. 2) the problem remaining centers on accessing the various buttons on the alert sheet === Here is the log result: [Session started at 2008-06-01 14:05:16 -0400.] 2008-06-01 14:05:18.088 Calculate Medical[2267:10b] NSWindow does not support utility styleMask 0x10 2008-06-01 14:05:18.097 Calculate Medical[2267:10b] NSWindow does not support utility styleMask 0x10 2008-06-01 14:05:22.738 Calculate Medical[2267:10b] *** -[NSAlert close]: unrecognized selector sent to instance 0x1b5520 2008-06-01 14:05:22.769 Calculate Medical[2267:10b] *** -[NSAlert close]: unrecognized selector sent to instance 0x1b5520 The Debugger has exited with status 0. === Do not understand that utility styleMask stuff .. and .. the NSAlert is type-cast as a NSWindow when passed to my dlgEndSelector, so that "unrecognized selector" is mystifying. Anyway, onto the code .. I call this method from MyDocument.m and pass the *documentWindow IBOutlet from MyDocument.h - (void) showCalculateSheet:(NSWindow*)docWindow { NSAlert *calculateSheet = [[[NSAlert alloc] init] autorelease]; [calculateSheet addButtonWithTitle:@"Continue"]; [calculateSheet addButtonWithTitle:@"Stop and save"]; [calculateSheet addButtonWithTitle:@"Stop and don't save"]; [calculateSheet setMessageText:@"You have not finished calculating your Spreadsheet.\n" "Do you wish to continue calculating?"]; [calculateSheet setAlertStyle:NSWarningAlertStyle]; [calculateSheet beginSheetModalForWindow:docWindow modalDelegate:self didEndSelector:@selector(endCalculateSheet:code:info:) contextInfo:docWindow]; } - (void) endCalculateSheet:(NSWindow*)theSheet code:(int)returnCode info:(void*)contextInfo { if (returnCode == NSAlertDefaultReturn) // "Continue" { NSLog(@"Default Calculate Button clicked"); } else if (returnCode == NSAlertOtherReturn) // "Stop and save" { NSLog(@"Other Calculate Button clicked"); } else if (returnCode == NSAlertAlternateReturn) // "Stop and don't save" { NSLog(@"Third Calculate Button clicked"); } [theSheet close]; // have also tried ... [theSheet orderOut:self]; } Someone a long time ago warned that the learning curve slope for XCODE is rather steep .. it's not like I wasn't told. Anyway, thanks bunches as usual John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Alert Sheets hard wired in Interface Builder
More NSLog data: 2008-05-31 12:33:51.001 Calculate Medical[1926:10b] NSWindow does not support utility styleMask 0x10 2008-05-31 12:33:51.023 Calculate Medical[1926:10b] NSWindow does not support utility styleMask 0x10 2008-05-31 12:33:55.434 Calculate Medical[1926:10b] *** -[NSAlert endErrorSheet:code:info:]: unrecognized selector sent to instance 0x16ed20 2008-05-31 12:33:55.438 Calculate Medical[1926:10b] *** -[NSAlert endErrorSheet:code:info:]: unrecognized selector sent to instance 0x16ed20 I put back: didEndSelector:@selector(endCalculateSheet:code:info:) into: [calculateSheet beginSheetModalForWindow:docWindow modalDelegate:nil didEndSelector:@selector(endCalculateSheet:code:info:) contextInfo:docWindow]; and here's the selector method: - (void) endCalculateSheet:(NSWindow*)theSheet code:(int)returnCode info:(void*)contextInfo { if (returnCode == NSAlertDefaultReturn) { // "Good Bye!" NSLog(@"Default Button clicked"); // does not log this entry } [theSheet close]; } John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Alert Sheets hard wired in Interface Builder
On Fri, May 30, 2008 at 3:33 PM, John Love <[EMAIL PROTECTED]<[EMAIL PROTECTED]>> wrote: > Here's some code snippets that I'm having problems with .. the code is > sorta working in that an alert *window* appears, but not as a drop-down > sheet as I think the following calls for: (and even when erroneously a > window, it is behind the main document window) > > Two controllers .. FileController and SheetController .. > > 1) FileController.h contains >IBOutlet SheetController *theSheet; .. and .. NSWindow > *itsWindow; (FileController's itsWindow gets set within MyDocument.m which > passes its IBOutlet NSWindow *documentWindow to a method of > FileController) As a result, MyDocument's documentWindow becomes > FileController's itsWindow > > 2) FileController.m contains >[theSheet showCalculateSheet:itsWindow]; > > 3) SheetController.h contains >- (void) showCalculateSheet:(NSWindow*)docWindow; > > 4) SheetController.m contains > > - (void) showCalculateSheet:(NSWindow*)docWindow { > NSAlert *calculateSheet = [[[NSAlert alloc] init] autorelease]; > > [calculateSheet addButtonWithTitle:@"Continue"]; > [calculateSheet addButtonWithTitle:@"Stop and save"]; > [calculateSheet addButtonWithTitle:@"Stop and don't save"]; > [calculateSheet setMessageText:@"You have not finished calculating > your Spreadsheet.\n" > "Do you wish to continue > calculating?"]; > [calculateSheet setAlertStyle:NSWarningAlertStyle]; > > [calculateSheet beginSheetModalForWindow:docWindow modalDelegate:nil > didEndSelector:nil // > @selector(endCalculateSheet:code:info:) > contextInfo:nil]; > } > > // *if* I use a real selector method, and not nil, I cannot dismiss the > alert > > - (void) endCalculateSheet:(NSWindow*)theSheet code:(int)returnCode > info:(void*)contextInfo { > > if (returnCode == NSAlertDefaultReturn) { // "Continue" > > } else if (returnCode == NSAlertOtherReturn) { // "Stop and save" > > } else if (returnCode == NSAlertAlternateReturn) { // "Stop and don't > save" > > } > > [theSheet orderOut:self]; > > } > > Thanks for everything in advance .. > > John Love > > > Jens wrote: My guess is that docWindow is nil. Set a breakpoint and check. But follow-ups should go to the list. John wrote back if (docWindow != nil) NSLog(@"passed window is not nil"); produced the log string. Touch the Future! Teach!! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
Alert Sheets hard wired in Interface Builder
Instead of calling NSAlertSheet with sender, defaultButton etc., is there a way to call a window sheet whose GUI is hard wired in Interface Builder. I know that in Applescript Studio, all you have to do is provide a name for the sheet you wish to call and it appears. Can the same implementation scheme exist in Cocoa/XCODE? Thanks in advance, John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
NSProgressIndicator -- delete the first message with same title
I have successfully been able to create a small Cocoa multiple document project whose GUI consists of a NSProgressIndicator, or wheel, and a Button, titled "Spin". In the .nib window, the "Controller" is ctrl-dragged to the wheel, specifying an outlet "wheel" and the Button is ctrl-dragged to the Controller, specifying an action :spin:". Within the Controller.h file, I have: @interface Controller:NSObject { IBOutlet NSProgressIndicator *spinner; BOOL start; } - (IBAction) spin:(id)sender; Within the Controller.m file, I have: @implementation Controller - (id) init { if (self = [super init]) { spinner = [[[NSProgressIndicator alloc] init] autorelease]; start = TRUE; } return self; } - (void) awakeFromNib { [spinner setUsesThreadedAnimation:YES]; } - (IBAction) spin:(id)sender { if (start) [spinner startAnimation:nil]; else[spinner stopAnimation:nil]; start = !start; } @end == Works like a champ .. pressing the Button starts, stops the spinning like it should. NOW .. another "speed bump" .. how to control the spinning from other objects, i.e., no IBAction .. so, remove the Button. Changing the spin method to look like: - (void) spinIt:(BOOL)begin { if (begin) [spinner startAnimation:nil]; else[spinner stopAnimation:nil]; } Here is what I've tried, with no success: Within MyDocument.h @interface MyDocument:NSDocument { IBOutlet Controller *theControl; } @end Within MyDocument.m - (id) init { if (self = [super init]) { theControl = [[Controller alloc] init]; } return self; } - (void) awakeFromNib { [theControl spinIt:TRUE]; } As I said above, it does not work; that is, I am not presented with a spinning wheel when the new window shows. Now, I have read about Notifications, Delegates in the Apple docs. Clearly, I do not understand YET all of the info, but I'm getting there. If I need to factor in Notifications and Delegates, I sure would appreciate a few snippets of guidance and in the process be able to more completely understand these beasts. Thanks in advance, John Love ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]
NSProgressIndicator
I have successfully been able to create a small project whose GUI consists of a NSProgressIndicator, or wheel, and a Button, titled "Spin". In the .nib window, the "Controller" is ctrl-dragged to the wheel, specifying an outlet "wheel" and the Button is ctrl-dragged to the Controller, specifying an action :spin:". Within the Controller.h file, I have: @interface Controller:NSObject { IBOutlet NSProgressIndicator *spinner; BOOL start; } - (IBAction) spin:(id)sender; Within the Controller.m file, I have: @implementation Controller - (id) init { if (self = [super init]) { spinner = [[[NSProgressIndicator alloc] init] autorelease]; start = TRUE; } return self; } - (void) awakeFromNib { // [theIndicator setStyle:NSProgressIndicatorSpinningStyle]; // already there [spinner setUsesThreadedAnimation:YES]; } - (IBAction) spin:(id)sender { if (start) [spinner startAnimation:nil]; else[spinner stopAnimation:nil]; start = !start; } @end == Works like a champ .. pressing the Button starts, stops the spinning like it should. NOW .. another "speed bump" .. how to control the spinning from other objects, i.e., no IBAction .. so, remove the Button. Changing the spin method to look like: - (void) spinIt:(BOOL)begin { if (begin) [spinner startAnimation:nil]; else[spinner stopAnimation:nil]; } Here is what I've tried, to no success: ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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]