Re: Delegate & Notification

2011-05-16 Thread Bing Li
Dear Michael, Chase, Seth and all, I appreciate so much for your help! After changing the WorkingApp as follows, the notification works. One of the reasons I made such a mistake is that I could not get sufficient materials to learn the techniques although I have got more than 10 books about Cocoa.

Re: Delegate & Notification

2011-05-16 Thread Bing Li
Dear all, Sorry to send the email again! I forget mentioning that Monitor was also changed. The notification is registered to defaultCenter instead of NSWorkspace notificationCenter. Could you help me what's wrong with the asynchronous notification? Thanks so much! Bing On Mon, May 16, 2011 a

Re: Why are properties access through NSURLProtocol class method rather than NSURLRequest instance method?

2011-05-16 Thread Mike Abdullah
On 16 May 2011, at 03:57, Larry Campbell wrote: > Seems odd to me that setting and getting properties of an NSURLRequest > involve an NSURLProtocol class method: > >+[NSURLProtocol setProperty:forKey:inRequest:] > > rather than what seems to me the much more straightforward: > >-[NSMu

Re: NSPostWhenIdle not doing its job?

2011-05-16 Thread Jonathan Taylor
Thanks very much for your reply Ken, very helpful indeed. >> The problem can be summarised as: in spite of having a backlog of >> notifications building up on the main thread, NSPostWhenIdle-qualified >> notifications do seem to be making it through. This is causing me problems >> because this

Re: Delegate & Notification

2011-05-16 Thread Michael Babin
On May 16, 2011, at 3:49 AM, Bing Li wrote: > - (void) Print > { > NSLog(@"I am doing a tough job!"); > // [[[NSNotificationQueue alloc] > initWithNotificationCenter:[NSNotificationCenter defaultCenter]] > enqueueNotification: [NSNotification notificationWithName:@"Done" >

Core Animation animations stop prematurely at random

2011-05-16 Thread Bill Cheeseman
My Mac OS X application has an borderless transparent overlay window with a layer-hosting view. The view's layers add a bunch of animations in response to a hot key. It all works correctly -- sometimes. When I quit and relaunch the application, the animations sometimes don't run for the full sp

Re: Delegate & Notification

2011-05-16 Thread Bing Li
Dear Michael, You are right. There is no RunLoop in the code. Actually, although I have got to know the term, RunLoop, when starting to learn Cocoa for two months, until now I have not seen a sample code about RunLoop in any resources. So I don't know how to program with it. I have one question.

Re: No more .ibplugins in Xcode 4, so now what...?

2011-05-16 Thread Alexander Zvyagin
> Thanks for the clarification. But the developer still had to transition > _his code_ from non-GC to either 1) GC-only and drop 32 bit (likely not > desirable) or 2) dual mode. > I think most developers would have accepted a loss of _binary_ > compatibility of their ibplugins, after all the targ

Re: No more .ibplugins in Xcode 4, so now what...?

2011-05-16 Thread Roland King
On 16-May-2011, at 9:50 PM, Alexander Zvyagin wrote: >> Thanks for the clarification. But the developer still had to transition >> _his code_ from non-GC to either 1) GC-only and drop 32 bit (likely not >> desirable) or 2) dual mode. > >> I think most developers would have accepted a loss of _b

Re: Delegate & Notification

2011-05-16 Thread Michael Babin
On May 16, 2011, at 8:31 AM, Bing Li wrote: > You are right. There is no RunLoop in the code. Actually, although I have got > to know the term, RunLoop, when starting to learn Cocoa for two months, until > now I have not seen a sample code about RunLoop in any resources. So I don't > know how t

Question regarding GameKit

2011-05-16 Thread Eric E. Dolecki
I have 2 iOS devices and I would like one of them to send data to the other (1-way really). When I put the same app on the two iOS devices & used GameKit, things worked great. Recently I made a second app in the hopes to have it send data to the 1st iOS device. I used the exact same GK code and

Why RunLoop?

2011-05-16 Thread Bing Li
Dear all, I am a new programmer of Cocoa. When learning RunLoop, I felt a little bit weird. Why should Cocoa provide such a technique? When programming on other environments, a while-true loop and wait/pulse lock can be used to achieve the same goal of RunLoop, right? I notice that Cocoa threadin

Re: Why RunLoop?

2011-05-16 Thread Nick Zitzmann
On May 16, 2011, at 9:07 AM, Bing Li wrote: > Dear all, > > I am a new programmer of Cocoa. When learning RunLoop, I felt a little bit > weird. Why should Cocoa provide such a technique? When programming on other > environments, a while-true loop and wait/pulse lock can be used to achieve > the

Re: NSPostWhenIdle not doing its job?

2011-05-16 Thread Ken Thomases
On May 16, 2011, at 4:50 AM, Jonathan Taylor wrote: > Thanks very much for your reply Ken, very helpful indeed. You're welcome. >> Still, that won't help if Function B is not being called as often as you >> expect because NSPostASAP doesn't work like you thought. I suspect that it >> is only

Re: Why RunLoop?

2011-05-16 Thread Ken Thomases
On May 16, 2011, at 10:25 AM, Nick Zitzmann wrote: > On May 16, 2011, at 9:07 AM, Bing Li wrote: > >> I am a new programmer of Cocoa. When learning RunLoop, I felt a little bit >> weird. Why should Cocoa provide such a technique? When programming on other >> environments, a while-true loop and wa

Re: NSPostWhenIdle not doing its job?

2011-05-16 Thread Jonathan Taylor
Thanks again for your replies. I tried your various suggestions and they did not directly solve the problem, but trying them out gave me a lot more clues to help understand what was going wrong. It was in fact your mention of setNeedsDisplay that prompted me to look at the actual low-priority dr

Re: Why RunLoop?

2011-05-16 Thread Kyle Sluder
On Mon, May 16, 2011 at 8:07 AM, Bing Li wrote: > Dear all, > > I am a new programmer of Cocoa. When learning RunLoop, I felt a little bit > weird. Why should Cocoa provide such a technique? When programming on other > environments, a while-true loop and wait/pulse lock can be used to achieve > th

Re: NSLayoutManager didCompleteLayout callback & NSFormFeedCharacter

2011-05-16 Thread Ross Carter
In my opinion, using layoutManager:didCompleteLayoutForTextContainer:atEnd is fraught with danger and should be avoided. Most of the time, it does not not provide truly useful information and you cannot rely on layout being complete even if the flag is YES. If you open a new page-wrapped docume

Re: No more .ibplugins in Xcode 4, so now what...?

2011-05-16 Thread Scott Ribe
On May 16, 2011, at 8:04 AM, Roland King wrote: > ...instead of having to drag on a generic class and then copy/paste > boilerplate code to make it work. That is much more like most "code generator" style interface editors, and thus greatly reduces the unique advantage of the IB style of interf

Re: Core Animation animations stop prematurely at random

2011-05-16 Thread Matt Neuburg
On Mon, 16 May 2011 08:11:36 -0400, Bill Cheeseman said: >My Mac OS X application has an borderless transparent overlay window with a >layer-hosting view. The view's layers add a bunch of animations in response to >a hot key. It all works correctly -- sometimes. > >What could account for sublaye

Re: Delegate & Notification

2011-05-16 Thread Matt Neuburg
On Mon, 16 May 2011 21:31:18 +0800, Bing Li said: > > although I have >got to know the term, RunLoop, when starting to learn Cocoa for two months, >until now I have not seen a sample code about RunLoop in any resources. So I >don't know how to program with it. > When I search on NSRunLoop in Xcod

Re: Delegate & Notification

2011-05-16 Thread Alex Kac
To be fair, a new Cocoa developer doesn't need to worry about runloops. Cocoa handles all that for you in most cases. Its good to understand when you understand all the rest of the basics, but its like learning how to drive a car and asking about the specifics of drivetrain operation. On May 16

RunLoop Tutorials

2011-05-16 Thread Bing Li
Dear Alex and Matt, Since I need to implement a peer-to-peer TCP model, I think the system level programming is required. Unfortunately, I have got any books giving enough explanations to RunLoop. Most books even never talk about it. Apple provides a document. However, the sample code is not com

Re: RunLoop Tutorials

2011-05-16 Thread Alex Kac
There are tons of docs on runloops. Check out NSRunLoop and CFRunLoop. But still, if you use a good framework, you really don't need to deal with them directly much. For example, GCDAsyncSocket is a great network class (there are many others) that handle a lot of this for you. Most of the tutori

Re: RunLoop Tutorials

2011-05-16 Thread Bing Li
In fact, I have rich experiences in Java and .NET. I use them to program a lot of low level distributed systems. However, I noticed that a lot of my past experiences could not be reused when programming with Cocoa. On Tue, May 17, 2011 at 4:13 AM, Alex Kac wrote: > There are tons of docs on run

Re: RunLoop Tutorials

2011-05-16 Thread Gary L. Wade
Read this and use the examples referenced at the bottom of each method description: On 05/16/2011 1:07 PM, "Bing Li" wrote: >Dear Alex and Matt, > >Since I need to imp

Asynchronous Notification Failed

2011-05-16 Thread Bing Li
Dear all, I am learning how to program an asynchronous notification system. But it only works as a synchronous one. I was told I should implement a RunLoop in the code. How to do that? I am not familiar with RunLoop. The sample code is listed as follows. Could you please help me how to solve the p

Re: Why RunLoop?

2011-05-16 Thread Bill Bumgarner
In short, do **not** poll. Not ever. If you are doing something like this: while (stillDontGotIt) { sleepForAMomentAndHopeWeGetIt(); } (or the obvious spin-and-try-lock variant). Then you are doing it wrong. It eats CPU, makes your app less responsive, eats batte

Re: Asynchronous Notification Failed

2011-05-16 Thread Wim Lewis
On 16 May 2011, at 2:19 PM, Bing Li wrote: > An application, AppController, which is interested in the asynchronous > notification, is as follows. I put sleep(5) deliberately to test if the > asynchronous notification works. As far as the run loop is concerned, when you are in sleep(5) you are bu

how to create a NSMenuItem without memory leaks

2011-05-16 Thread Martin Batholdy
Hi, I create an NSMenu by myself; menu = [[NSMenu allocWithZone:menuZone] init]; And depending on some data NSMenuItems get created. Now these menuItems get deleted and redrawn depending on some actions of the user with [menu removeItemAtIndex: x]; I create the menu items like this: newIt

Re: how to create a NSMenuItem without memory leaks

2011-05-16 Thread Nick Zitzmann
On May 16, 2011, at 5:04 PM, Martin Batholdy wrote: > Hi, > > I create an NSMenu by myself; > > menu = [[NSMenu allocWithZone:menuZone] init]; > > And depending on some data NSMenuItems get created. > > > Now these menuItems get deleted and redrawn depending on some actions of the > user wi

log file in apple system log

2011-05-16 Thread Rainer Standke
Hello, I am trying to have my Mac app log info in such a way that a log file will be visible in the Console app, and the logfile is managed by syslogd. I am playing with asl_log and friends, and I can make things appear in the system log. How do I cause the creation of a distinct log file for t

Re: selectionIndexesForProposedSelection on mouse Up or mouse Down

2011-05-16 Thread Corbin Dunn
On May 13, 2011, at 10:56 AM, Quincey Morris wrote: > On May 13, 2011, at 10:36, Corbin Dunn wrote: > >> On May 12, 2011, at 1:42 PM, Brad Stone wrote: >> >>> I put in NSLog calls to show me when "proposed" and "didChange" get called. >>> NSTableView's delegate gets called on mouseDown while

Re: how to create a NSMenuItem without memory leaks

2011-05-16 Thread Martin Batholdy
> Also, you are double-initializing the object, and under no circumstances > should you ever do that. Ok, thanks for pointing that out ... I still overlook these things ... Ok ... now I tried to reread the official documents ... Is this how you would do it properly: newItem = [[NSMenuItem al

Re: how to create a NSMenuItem without memory leaks

2011-05-16 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 5/16/11 4:04 PM, Martin Batholdy wrote: > Hi, > > I create an NSMenu by myself; > > menu = [[NSMenu allocWithZone:menuZone] init]; What Nick said. Plus, you almost never want to use -allocWithZone:. Zones are a particularly arcane subject and e

Re: how to create a NSMenuItem without memory leaks

2011-05-16 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 5/16/11 4:44 PM, Martin Batholdy wrote: > Is this how you would do it properly: > > newItem = [[NSMenuItem alloc] initWithTitle:aTitle action:@selector(show:) > keyEquivalent:@""]; > > [menu addItem:newItem]; > // with the addItem command newIt

Re: Asynchronous Notification Failed

2011-05-16 Thread Graham Cox
On 17/05/2011, at 7:19 AM, Bing Li wrote: > I was told I should implement a RunLoop in > the code. How to do that? you call [NSApp run]; Which requires that you have initialised NSApplication, which a default Xcode Cocoa project does for you (and where the above method is also called for you

Re: Asynchronous Notification Failed

2011-05-16 Thread Graham Cox
On 17/05/2011, at 10:43 AM, Graham Cox wrote: > > On 17/05/2011, at 7:19 AM, Bing Li wrote: > >> I was told I should implement a RunLoop in >> the code. How to do that? > > > you call [NSApp run]; Actually, correction - you don't. You just call NSApplicationMain(...), which creates the app

Re: how to create a NSMenuItem without memory leaks

2011-05-16 Thread Nick Zitzmann
On May 16, 2011, at 5:49 PM, Conrad Shultz wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 5/16/11 4:04 PM, Martin Batholdy wrote: >> Hi, >> >> I create an NSMenu by myself; >> >> menu = [[NSMenu allocWithZone:menuZone] init]; > > What Nick said. > > Plus, you almost never wa

Re: how to create a NSMenuItem without memory leaks

2011-05-16 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 5/16/11 6:16 PM, Nick Zitzmann wrote: >> Plus, you almost never want to use -allocWithZone:. Zones are a >> particularly arcane subject and explicit determination of a zone is >> best avoided. > > That's not true with NSMenu; the OP actually had

Re: how to create a NSMenuItem without memory leaks

2011-05-16 Thread Greg Parker
On May 16, 2011, at 6:16 PM, Nick Zitzmann wrote: > On May 16, 2011, at 5:49 PM, Conrad Shultz wrote: >> >> On 5/16/11 4:04 PM, Martin Batholdy wrote: >>> Hi, >>> >>> I create an NSMenu by myself; >>> >>> menu = [[NSMenu allocWithZone:menuZone] init]; >> >> What Nick said. >> >> Plus, you almo

Re: how to create a NSMenuItem without memory leaks

2011-05-16 Thread Nick Zitzmann
On May 16, 2011, at 8:05 PM, Greg Parker wrote: >> That's not true with NSMenu; the OP actually had it right: >> > > Don't bo

Re: how to create a NSMenuItem without memory leaks

2011-05-16 Thread Greg Parker
On May 16, 2011, at 7:15 PM, Nick Zitzmann wrote: > On May 16, 2011, at 8:05 PM, Greg Parker wrote: >> >> Don't bother. The menu zone is gone as of Snow Leopard. -setMenuZone: does >> nothing, and -menuZone always returns the default malloc zone. > > Really? Good to know. I filed bug #9450065 on

Scrolling to a point in WebView

2011-05-16 Thread Venkat
Hi, I have a webview in my application. I have a requirement to search for a word in the WebView and then dynamically scroll to the found text. I am able to find the text in the WebView using the - (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOO

Re: log file in apple system log

2011-05-16 Thread Ben Gollmer
On May 16, 2011, at 7:23 PM, Rainer Standke wrote: > Hello, > > I am trying to have my Mac app log info in such a way that a log file will be > visible in the Console app, and the logfile is managed by syslogd. > > I am playing with asl_log and friends, and I can make things appear in the > sy