Re: How to test if object is KVO observer?
On Wed, Apr 15, 2009 at 10:09 PM, I. Savant idiotsavant2...@gmail.comwrote: On Wed, Apr 15, 2009 at 3:51 PM, Andreas Eriksson aeriks...@gmail.com wrote: Is there a way to test if an object is a KVO observer of a different object? Something like -[a isObserving:b forKeyPath:@akeypath]? The easy answer: Look up NSKeyValueObserving protocol's -observationInfo and check against that. Thanks, I'll do that. The not-so-easy answer: it depends on what you're trying to accomplish. Why are you interested in this information? This is one of those questions that make me think there may be a better approach to what you're trying to do. I may be wrong. :-) Only for unit testing. I had a case where I failed to remove an observer and I want to add a test for it. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Combing Bindings with Target-Action
On Apr 15, 2009, at 12:04, Jeff Hutchison wrote: I am relying on the binding messages to complete before the target-action message - is this an OK idea? If you look at the diagram in: http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/MessageFlow.html#/ /apple_ref/doc/uid/TP40002149-186285 it's clear that either the model *must* be updated via the binding before the action is sent to the target *unless* the action is sent between step 5 and step 6. (The final value of the UI object is not settled until step 5.) If *that* was going to happen, it'd be hard to believe that it wouldn't always happen, and as you've already seen, it doesn't. So I'd say your assumption is safe for Tiger and Leopard. Given how intimately the model validation (and hence the binding) is tied to setting the object's own value, I can't imagine the relative order getting switched in the future either. FWIW ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Table with all Key-Value Pairs
On 15 Apr 2009, at 19:44, Volker in Lists wrote: You may want to download an example from Apple ;-) : http://developer.apple.com/samplecode/DictionaryController/index.html Thanks for this link. It did help me a lot. One problem though: If I bind the content of my dictionary controller to selectedObjects of my array controller, then I get an exeption: Cannot create NSDictionary from object () of class NSCFArray. Makes sense: the content of the array controller is bound to some instance variable which is initially nil. The workaround (also used in samplecode/DictionaryController): observe the array controller forKeyPath: @selectionIndexes and set some instance variable (like currentlySelectedDictionary) from selectedObjects whenever the selection changes. Then bind the content of my dictionary controller to currentlySelectedDictionary. Looks kind of clumsy, but works. Is there some more elegant way? Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Best way to pass large objects between tasks?
Thanks, Marcel and Graham. It answers my question. I will now look for ways to optimize data transmission between processes, and I think I have already found one. On Thu, Apr 16, 2009 at 3:10 AM, Marcel Weiher marcel.wei...@gmail.com wrote: On Apr 12, 2009, at 23:26 , Oleg Krupnov wrote: I haven't tried either of the methods I mentioned so far (because I'm lazy, sorry:), but what I have tried is I created NSData from the large object by using NSKeyedArchiver. It has taken forever, so that I had to force-quit the process. Yes, NSKeyedArchiver is not really suitable for large data-sets. That's why I am asking if the same thing is going to happen with piples and DO? Or maybe I'm doing something wrong? Well, the two questions are really orthogonal: both DO and pipes will require serialization if you actually want to move the object across. By large I mean about 10-100 MB. I don't think I am going to hit the boundary of VM anyway. Can you tell us a bit more about the object in question? Is it really one object with 10-100MB of associated data? What's the data and how is it encoded? Or is it an object graph with lots of objects involved? Why do you want to move the object/data across to another task? Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
sending emails using URLRequest and php
dear all The issue has now been solved so here is the solution for all those that are interested: You need to make your URL request pointing to your php script: and through my frustration I had forgotten to add the call to get URL request sent out with URLConnection so here it is in full The script sendInfo.php: ?php $message = $_REQUEST['message'] ; mail( t...@qu-s.eu, Test Message, $message ); ? and here is the code section in my cocoa app: -( IBAction ) sendMail:( id )sender { NSString *post = @message=testing; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@%d, [postData length]]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:@http://www.qu-s.eu/ sendInfo.php]]; [request setHTTPMethod:@POST]; [request setValue:postLength forHTTPHeaderField:@Content-Length]; [request setValue:@application/x-www-form-urlencoded forHTTPHeaderField:@Content-Type]; [request setHTTPBody:postData]; [ NSURLConnection connectionWithRequest:request delegate:self ]; } Thanks again to all and may I again refer interested people to this blog which has more information http://deusty.blogspot.com/search/label/NSURLRequest Reza ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: sending emails using URLRequest and php
On Apr 16, 2009, at 5:26 AM, Reza Farhad wrote: The script sendInfo.php: ?php $message = $_REQUEST['message'] ; mail( t...@qu-s.eu, Test Message, $message ); ? This is a discussion for another list, but have you thought of the security implications of hosting such a script on a public-facing server? This is the kind of wide-open thing spammers love to find ... -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Best way to pass large objects between tasks?
I don't know about other OS X technologies, but IIRC CFMessagePort is optimized to exchange large amount of data between processes. http://developer.apple.com/documentation/CoreFoundation/Reference/CFMessagePortRef/Reference/reference.html Le 16 avr. 09 à 10:44, Oleg Krupnov a écrit : Thanks, Marcel and Graham. It answers my question. I will now look for ways to optimize data transmission between processes, and I think I have already found one. On Thu, Apr 16, 2009 at 3:10 AM, Marcel Weiher marcel.wei...@gmail.com wrote: On Apr 12, 2009, at 23:26 , Oleg Krupnov wrote: I haven't tried either of the methods I mentioned so far (because I'm lazy, sorry:), but what I have tried is I created NSData from the large object by using NSKeyedArchiver. It has taken forever, so that I had to force-quit the process. Yes, NSKeyedArchiver is not really suitable for large data-sets. That's why I am asking if the same thing is going to happen with piples and DO? Or maybe I'm doing something wrong? Well, the two questions are really orthogonal: both DO and pipes will require serialization if you actually want to move the object across. By large I mean about 10-100 MB. I don't think I am going to hit the boundary of VM anyway. Can you tell us a bit more about the object in question? Is it really one object with 10-100MB of associated data? What's the data and how is it encoded? Or is it an object graph with lots of objects involved? Why do you want to move the object/data across to another task? Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org This email sent to devli...@shadowlab.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Setting up an auxiliary task for use with Distributed Objects
I'm looking for the right way of setting up the auxiliary NSTask from within the main task. The aux task vends some Distributed Objects, and the main task uses them. The auxiliary task does this: NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MyVendedObject* vendedObj = [[[MyVendedObject alloc] init] autorelease]; NSConnection* connection = [NSConnection defaultConnection]; [connection setRootObject:vendedObj]; if ([connection registerName:@MyAuxTask]) { [[NSRunLoop currentRunLoop] run]; } [pool release]; return 0; As I understand, as soon as the aux tasks reaches the runloop's run message, it blocks and is ready for connection messages. However there are 2 problems: 1) I need to block the main task until the aux task is ready to work. How do I do it? Sleep/poll connection/repeat doesn't seem a good approach, is there any better way? 2) How do I quit the aux task? [NSTask terminate] does not work, invalidating the connection does not work... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Best way to get a non-repeating random number?
On 15-Apr-2009, at 18:46, Michael Ash wrote, quoting Eric E. Dolecki: int result = (arc4random()%9) + 1; if (result = activeTarget) ++result; activeTarget = result; No it won't. Sorry, you're right; I was wrong. I wrote after a too brief analysis of the code. It's actually a rather algorithm. I apologize for the noise. The punishment for my error is that it will be indexed by Google for what passes on the Internet as eternity. My other points about Mersenne Twister burstiness, etc. stand. -- Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: sending emails using URLRequest and php
This was just a simple example of making this work, obviously it needs to be improved upon for implementation. Reza On 16 Apr 2009, at 11:52, I. Savant wrote: On Apr 16, 2009, at 5:26 AM, Reza Farhad wrote: The script sendInfo.php: ?php $message = $_REQUEST['message'] ; mail( t...@qu-s.eu, Test Message, $message ); ? This is a discussion for another list, but have you thought of the security implications of hosting such a script on a public-facing server? This is the kind of wide-open thing spammers love to find ... -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: sending emails using URLRequest and php
On Apr 16, 2009, at 6:52 AM, I. Savant wrote: This is a discussion for another list, but have you thought of the security implications of hosting such a script on a public-facing server? This is the kind of wide-open thing spammers love to find ... Sorry for the noise, I hit send too early. I meant to add: While it's very good the e-mail address is hard-coded, you're still going to get hammered with scripted attempts at a) using it to send out to other addresses, and b) simply spamming you with it. A simple contact form on a web site I manage gets felt up by scripts many times a day. Though the form does not send a copy of the body of the message, it does send a confirmation e-mail saying we received your e-mail. If it did, the form could be used to send spam from that web site's contact address. In addition, these scripts send all kinds of extra arguments in an attempt to find hidden features of the PHP script (from=spamaddress, sender=spamaddress, user=spamaddress, and so on). Be careful. -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: filteredArrayUsingPredicate and points
Something like: [NSPredicate predicateWithFormat: @containsPointString %@ == YES, NSStringFromPoint(point)]; On Apr 16, 2009, at 5:24 AM, Alexey Baev wrote: On Apr 15, 2009, at 19:59:39, Kirk Kerekes wrote: Untested suggestion: Try adding a method to MyDot that will accept the NSStringFromPoint representation, and then reference that method in your predicate, supplying a NSStringFromPoint as the object to be searched for. - (BOOL)containsPointString:(NSString *) stringRepresentation { return [self containsPoint: NSPointFromString(stringRepresentation)]; } I thought about this way but I don't know how I can create my predicate. I guess it has to be like this: NSPredicate* pr = [NSPredicate predicateWithFormat: @containsPointString ??? what to write here ??? == YES]; but I don't know exactly. -- Alexey ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: filteredArrayUsingPredicate and points
On 16/04/2009, at 8:24 PM, Alexey Baev wrote: I thought about this way but I don't know how I can create my predicate. I guess it has to be like this: NSPredicate* pr = [NSPredicate predicateWithFormat: @containsPointString ??? what to write here ??? == YES]; but I don't know exactly. Don't bother with predicates for this. It's unnecessarily complicated. Just iterate over the array and copy those objects that return YES to your question into another array. Job jobbed. It's likely to be a lot faster too. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
nstoolbar in tiger
Hello, I think I know the answer already but to be sure I'm not missing something if I want the equivalent of NSToolbar in Tiger I must create a custom window is that correct? Unless there's a trick I don't know about I can't use NSToolbar in Tiger right? Thanks for your input, Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: nstoolbar in tiger
Hi Rick/Jo/whoever, You don't need to create a subclass of NSwindow, all you need is an object to provide the NSWindow instance a NSToolbar. Running NSToolbar through Google would give you this result on the first page: http://cocoadevcentral.com/articles/37.php Hope this helps, Kiel :-) B.I.B.L.E. - Basic Instructions Before Leaving Earth On 16/04/2009, at 11:13 PM, Jo Phils wrote: Hello, I think I know the answer already but to be sure I'm not missing something if I want the equivalent of NSToolbar in Tiger I must create a custom window is that correct? Unless there's a trick I don't know about I can't use NSToolbar in Tiger right? Thanks for your input, Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/kiel.gillard%40gmail.com This email sent to kiel.gill...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Setting up an auxiliary task for use with Distributed Objects
On Thu, Apr 16, 2009 at 5:01 AM, Oleg Krupnov oleg.krup...@gmail.com wrote: I'm looking for the right way of setting up the auxiliary NSTask from within the main task. The aux task vends some Distributed Objects, and the main task uses them. The auxiliary task does this: NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MyVendedObject* vendedObj = [[[MyVendedObject alloc] init] autorelease]; NSConnection* connection = [NSConnection defaultConnection]; [connection setRootObject:vendedObj]; if ([connection registerName:@MyAuxTask]) { [[NSRunLoop currentRunLoop] run]; } [pool release]; return 0; As I understand, as soon as the aux tasks reaches the runloop's run message, it blocks and is ready for connection messages. However there are 2 problems: 1) I need to block the main task until the aux task is ready to work. How do I do it? Sleep/poll connection/repeat doesn't seem a good approach, is there any better way? 2) How do I quit the aux task? [NSTask terminate] does not work, invalidating the connection does not work... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jeremyw.sherman%40gmail.com This email sent to jeremyw.sher...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Fwd: Setting up an auxiliary task for use with Distributed Objects
Apologies for the multiple-send. Keep forgetting to reply to all. Looking to see if I can set that as default or just have to start slapping myself for negative reinforcement instead. -- Forwarded message -- From: Jeremy W. Sherman jeremyw.sher...@gmail.com Date: Thu, Apr 16, 2009 at 9:26 AM Subject: Re: Setting up an auxiliary task for use with Distributed Objects To: Oleg Krupnov oleg.krup...@gmail.com You can communicate with the task, since you seem to control it, by setting up a pipe (NSPipe) and setting its write/read file handles as the stdin/stdout for the task. The task can then send you a ready to go signal. You can use -[NSFileHandle waitForDataInBackgroundAndNotify] to get a callback when the ready signal is sent back. On the other side, you can have it check for a broken connection (is that possible with NSConnection/NSMachPort?) or just wait for a kill message to come across on its stdin, which your primary task can send over. I've not had much luck with DO, so there might be a better way out there. —Jeremy On Thu, Apr 16, 2009 at 5:01 AM, Oleg Krupnov oleg.krup...@gmail.com wrote: I'm looking for the right way of setting up the auxiliary NSTask from within the main task. The aux task vends some Distributed Objects, and the main task uses them. The auxiliary task does this: NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MyVendedObject* vendedObj = [[[MyVendedObject alloc] init] autorelease]; NSConnection* connection = [NSConnection defaultConnection]; [connection setRootObject:vendedObj]; if ([connection registerName:@MyAuxTask]) { [[NSRunLoop currentRunLoop] run]; } [pool release]; return 0; As I understand, as soon as the aux tasks reaches the runloop's run message, it blocks and is ready for connection messages. However there are 2 problems: 1) I need to block the main task until the aux task is ready to work. How do I do it? Sleep/poll connection/repeat doesn't seem a good approach, is there any better way? 2) How do I quit the aux task? [NSTask terminate] does not work, invalidating the connection does not work... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jeremyw.sherman%40gmail.com This email sent to jeremyw.sher...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: nstoolbar in tiger
On Thu, Apr 16, 2009 at 9:21 AM, Kiel Gillard kiel.gill...@gmail.com wrote: You don't need to create a subclass of NSwindow, all you need is an object to provide the NSWindow instance a NSToolbar. The difference that likely led Jo to this conclusion is that Interface Builder 3 (and the latest version of nibs/xibs that go with it) has the ability to create and store toolbars directly in the NIB, whereas previous versions did not. Before this, you had to do it all in code and there are a lot of examples to do so, one of which Kiel points out. In fact, on half the occasions I've had to create a toolbar with the latest and greatest tools, I was forced revert to code for better control. IB 3 is great for creating basic toolbars, but anything beyond basics will likely require code. B.I.B.L.E. - Basic Instructions Before Leaving Earth Yes, everybody should stone at least one adulterer to death before they go ... ;-) -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Combing Bindings with Target-Action
Thanks for the responses. I had used KVO on the bound property on an earlier version and was encountering a small problem due to the nature of my application. There might be cleaner way so some more details might be helpful. I'm writing an application that connects to my home theater receiver on its telnet port to remote control and monitor it. The model represents the state of the receiver and can be updated in three ways: 1. Through bindings to the application UI controls. 2. From events sent by the receiver as a response to commands sent by my app. 3. From events sent by the receiver due to other interactions with the receiver (IR remote, front panel, embedded web server). Two and three appear identical to my app but I can figure out case 2 by using the event handler's change dictionary's NSKeyValueChangeOldKey and NSKeyValueChangeNewKey values. I need to know if the model was updated by the UI or by networking code so that I only send command to the receiver in response to UI changes, not other interactions with the receiver. For example, the problem is the observer would see the model mute value change to on when I changed it at the receiver and interprets that as a change on the app UI. It would then send a redundant mute on command to the receiver. Using target-action with bindings solved the problem nicely with a minimum of extra code. If I fail to verify that a race condition doesn't exist I can fall back to reading the values from the action's sender parameter instead of the bound model. Jeff On Wed, Apr 15, 2009 at 11:26 PM, Kyle Sluder kyle.slu...@gmail.com wrote: On Wed, Apr 15, 2009 at 3:04 PM, Jeff Hutchison hutchison.j...@gmail.com wrote: I am relying on the binding messages to complete before the target-action message - is this an OK idea? Why not just register as an observer of the bound property? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: nstoolbar in tiger
Hello and thanks for the replies! Yes it's what I.S. mentioned about doing with IB3. That clears it up and I'll just do it the old-fashioned way following the examples... :-) Thanks again, Rick From: I. Savant idiotsavant2...@gmail.com To: Kiel Gillard kiel.gill...@gmail.com Cc: Jo Phils jo_p...@yahoo.com; cocoa dev cocoa-dev@lists.apple.com Sent: Thursday, April 16, 2009 9:49:25 PM Subject: Re: nstoolbar in tiger On Thu, Apr 16, 2009 at 9:21 AM, Kiel Gillard kiel.gill...@gmail.com wrote: You don't need to create a subclass of NSwindow, all you need is an object to provide the NSWindow instance a NSToolbar. The difference that likely led Jo to this conclusion is that Interface Builder 3 (and the latest version of nibs/xibs that go with it) has the ability to create and store toolbars directly in the NIB, whereas previous versions did not. Before this, you had to do it all in code and there are a lot of examples to do so, one of which Kiel points out. In fact, on half the occasions I've had to create a toolbar with the latest and greatest tools, I was forced revert to code for better control. IB 3 is great for creating basic toolbars, but anything beyond basics will likely require code. B.I.B.L.E. - Basic Instructions Before Leaving Earth Yes, everybody should stone at least one adulterer to death before they go ... ;-) -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Importing Word doc in Carbon app via Cocoa
I'm not a Cocoa developer, so I rarely have to touch the stuff. This code used to work, and I'm not sure when or why it got broken. It previously did not have the NSApplicationLoad or NSAutoreleasePool, so I added those in hopes that that was the problem. Before adding those 2 things, I would get a crash down in some Cocoa stuff (see stack after routine). After adding those 2 things, it crashes at [localPool release]. I was told to use those 2 things in a few other Cocoa routines we have in our Carbon app, and they still work (using NSCursor and NSAnimationEffectPoof). Any ideas on what might be wrong? I appreciate any help. void ConvertWordDataIntoRTFData(const Byte* const data, const UInt32 len, fAutoBufferchar outData) { outData.clear(); if(data != nil len 0) { if(NSApplicationLoad()) { NSAttributedString* attrStr; NSData* nsdata; NSDictionary* attr = nil; NSAutoreleasePool* localPool; localPool = [[NSAutoreleasePool alloc] init]; // Convert the Word doc data into an attributed string: nsdata = [NSData dataWithBytes:data length:len]; if(nsdata != nil) { attrStr = [[NSAttributedString alloc] initWithDocFormat:nsdata documentAttributes:attr]; [nsdata release]; if(attrStr != nil) { // Create rtf data from the attributed string: NSRange range = NSMakeRange(0, [[attrStr string] length]); nsdata = [attrStr RTFFromRange:range documentAttributes:attr]; [attrStr release]; if(nsdata != nil) { outData.append([nsdata length], (char*)[nsdata bytes]); [nsdata release]; } } } [localPool release]; } } } Crash stack before adding NSApplicationLoad dnd NSAutoreleasePool: #0 0x94022688 in objc_msgSend #1 0x926bf08f in NSPopAutoreleasePool #2 0x9600779f in _wrapRunLoopWithAutoreleasePoolHandler #3 0x90b319a2 in __CFRunLoopDoObservers #4 0x90b32c40 in CFRunLoopRunSpecific #5 0x90b33cd8 in CFRunLoopRunInMode #6 0x912712c0 in RunCurrentEventLoopInMode #7 0x912710d9 in ReceiveNextEventCommon #8 0x912cfc6e in _AcquireNextEvent #9 0x912ce3cb in RunApplicationEventLoop #10 0x00204edf in fApp::Run at fApp.cp:2432 #11 0x001eed79 in main at DogbertMain.cp:146 _ Steve Mills Me: 952-401-6255 Senior Software Architect MultiAd smi...@multiad.com www.multi-ad.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Importing Word doc in Carbon app via Cocoa
On Thu, Apr 16, 2009 at 11:32 AM, Steve Mills smi...@multi-ad.com wrote: I'm not a Cocoa developer, so I rarely have to touch the stuff. This code used to work, and I'm not sure when or why it got broken. It previously did not have the NSApplicationLoad or NSAutoreleasePool, so I added those in hopes that that was the problem. Before adding those 2 things, I would get a crash down in some Cocoa stuff (see stack after routine). After adding those 2 things, it crashes at [localPool release]. I was told to use those 2 things in a few other Cocoa routines we have in our Carbon app, and they still work (using NSCursor and NSAnimationEffectPoof). Any ideas on what might be wrong? I appreciate any help. Your code is full of memory management errors. It is fairly amazing that it ever worked. The lack of an autorelease pool probably covered up the errors in exchange for leaking. Anyway, read through this, and then fix up your code accordingly: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/2994-BAJHFBGH The particular error you're making is releasing objects that you don't own. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -viewDidMoveToWindow without subclassing? NSViewController?
On 2009 Apr 15, at 22:14, Michael Ash wrote: IMO that's a silly objection. Subclassing and adding this method is easy, straightforward, and it works. You only need to override one method to justify having a subclass. Thanks Michael. I decided to subclass the view that needs the initialization (NSPredicateEditor) instead of the tab view item's content view. So now it has some other code, relocated from the window controller. But it's the same idea. I'm still having trouble with NSPredicateEditor's - viewDidMoveToWindow, though. But before I pursue that I'd like to continue discussion of Graham's comment, to make sure I'm on the beaten path... On 2009 Apr 15, at 20:09, Graham Cox wrote: Views that are not in the currently selected tab are not in the view hierarchy ... [notShownView window] is always nil. It doesn't matter when you call it - if it's not visible in the selected tab you can't find the window that way. Conversly, when a tab is visible, any visible view in it will return the valid -window. Since I only need it once, during initialization, I grab it during -viewDidMoveToWindow. If you need the window, the window controller will return it from - window. The other way around, Graham. I need the window controller, so I get it from -window. See below. I don't see why you need to get this from an item in a tab view? You talk about the need to initialise something. What? How? What are you trying to do? In general, I need the document during initialization, so I do [[[aView window] windowController] document] Here are two examples of why I need the document: * In an NSPredicateEditor subclass, during -viewDidMoveToWindow, creating the row templates requires a reference to the document's managed object context, so it can get attribute types. See code [1]. * In an NSOutlineView subclass, during -viewDidMoveToWindow, I need to initialize and set a data source, which needs a (weak) reference to the document in order to get data objects. See code [2]. Is this an abnormal design pattern? I think I've seen people set their document as nib File's Owner, but I can't do that since my document is sometimes instantiated without a window. My nib File's Owner is a window controller. Jerry [1] In implementing a subclass of NSPredicateEditor... - (void)viewDidMoveToWindow { // To make sure this only runs once... if ([self isInitialized]) { return ; } [self setIsInitialized:YES] ; NSManagedObjectContext* moc = self window] windowController] document] managedObjectContext] ; NSEntityDescription* entityDescription = [NSEntityDescription entityForName:@Stark_entity inManagedObjectContext:moc] ; NSArray* rowTemplates = [self templatesWithAttributeKeyPaths:keyPaths inEntityDescription:entityDescription] ; [self addRowTemplates:rowTemplates] ; ... } [2] In implementing a subclass of NSOutlineView... - (void)viewDidMoveToWindow { // To make sure this only runs once... if ([self dataSource]) { return ; } // Create and set data source Bookshelf* document_ = [[[self window] windowController] document] ; ContentDataSource* dataSource = [[ContentDataSource alloc] initWithDocument:document_] ; [self setDataSource: dataSource] ; [dataSource release] ; // Set the doubleclick action. [self setTarget:[[[self window] windowController] document]] ; [self setDoubleAction:@selector(visitItems:)] ; ... } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Importing Word doc in Carbon app via Cocoa
You'll want to read Cocoa memory management: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#/ /apple_ref/doc/uid/2043 The general rule is that if you do *not* create an instance by using [[X alloc] initZZ] then you should *not* call release (because your instance has been auto released). I'm not a Cocoa developer, so I rarely have to touch the stuff. This code used to work, and I'm not sure when or why it got broken. It previously did not have the NSApplicationLoad or NSAutoreleasePool, so I added those in hopes that that was the problem. Before adding those 2 things, I would get a crash down in some Cocoa stuff (see stack after routine). After adding those 2 things, it crashes at [localPool release]. I was told to use those 2 things in a few other Cocoa routines we have in our Carbon app, and they still work (using NSCursor and NSAnimationEffectPoof). Any ideas on what might be wrong? I appreciate any help. void ConvertWordDataIntoRTFData(const Byte* const data, const UInt32 len, fAutoBufferchar outData) { outData.clear(); if(data != nil len 0) { if(NSApplicationLoad()) { NSAttributedString* attrStr; NSData* nsdata; NSDictionary* attr = nil; NSAutoreleasePool* localPool; localPool = [[NSAutoreleasePool alloc] init]; // Convert the Word doc data into an attributed string: nsdata = [NSData dataWithBytes:data length:len]; if(nsdata != nil) { attrStr = [[NSAttributedString alloc] initWithDocFormat:nsdata documentAttributes:attr]; Don't release here: // [nsdata release]; if(attrStr != nil) { // Create rtf data from the attributed string: NSRange range = NSMakeRange(0, [[attrStr string] length]); nsdata = [attrStr RTFFromRange:range documentAttributes:attr]; [attrStr release]; if(nsdata != nil) { outData.append([nsdata length], (char*)[nsdata bytes]); Don't release here: // [nsdata release]; } } } [localPool release]; } } } Crash stack before adding NSApplicationLoad dnd NSAutoreleasePool: #0 0x94022688 in objc_msgSend #1 0x926bf08f in NSPopAutoreleasePool #2 0x9600779f in _wrapRunLoopWithAutoreleasePoolHandler #3 0x90b319a2 in __CFRunLoopDoObservers #4 0x90b32c40 in CFRunLoopRunSpecific #5 0x90b33cd8 in CFRunLoopRunInMode #6 0x912712c0 in RunCurrentEventLoopInMode #7 0x912710d9 in ReceiveNextEventCommon #8 0x912cfc6e in _AcquireNextEvent #9 0x912ce3cb in RunApplicationEventLoop #10 0x00204edf in fApp::Run at fApp.cp:2432 #11 0x001eed79 in main at DogbertMain.cp:146 Jesper Storm Bache Core Technologies Adobe Systems Inc ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Importing Word doc in Carbon app via Cocoa
On Thu, Apr 16, 2009 at 8:32 AM, Steve Mills smi...@multi-ad.com wrote: Any ideas on what might be wrong? I appreciate any help. Simple misapplication of Cocoa memory management. Read the following (seriously it will save you a lot of time)... http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html // Convert the Word doc data into an attributed string: nsdata = [NSData dataWithBytes:data length:len]; The object pointed to by nsdata was made available to you by a method that doesn't also give you an ownership role for that object. if(nsdata != nil) { attrStr = [[NSAttributedString alloc] initWithDocFormat:nsdata documentAttributes:attr]; [nsdata release]; You then proceed to release the object pointed to by nsdata but you never retained it before this point in time (aka didn't take an ownership role so no need to give up ownership). if(attrStr != nil) { // Create rtf data from the attributed string: NSRange range = NSMakeRange(0, [[attrStr string] length]); nsdata = [attrStr RTFFromRange:range documentAttributes:attr]; Again the object pointed to by nsdata was made available to you by a method that doesn't also give you an ownership role for that object. [attrStr release]; if(nsdata != nil) { outData.append([nsdata length], (char*)[nsdata bytes]); [nsdata release]; Again you then proceed to release the object pointed to by nsdata but you never retained it before this point in time (aka didn't take an ownership role so no need to give up ownership). } } } [localPool release]; Then things crash under the above call (or at the end of the next event loop) because you over released objects out from under the auto release pool who was asked to release those same objects by the methods that originally gave your code access to the NSData instances. -Shawn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Importing Word doc in Carbon app via Cocoa
On Apr 16, 2009, at 10:44:07, Jesper Storm Bache wrote: You'll want to read Cocoa memory management: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#/ /apple_ref/doc/uid/2043 The general rule is that if you do *not* create an instance by using [[X alloc] initZZ] then you should *not* call release (because your instance has been auto released). Thanks for the help, everyone. I hope I remember the rules the next time I have to deal with Cocoa. _ Steve Mills Me: 952-401-6255 Senior Software Architect MultiAd smi...@multiad.com www.multi-ad.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Apple's PredicateEditorSample returns [self init] in -awakeFromNib ?!?
On 2009 Apr 15, at 22:07, Michael Ash wrote: It's completely busted ... File a bug ... I agree. Without objection, then ... Bug ID 6798076. Just for the record, there is something else very weird in PredicateEditorSample. When you run it, if you choose predicate operator contains, it shows in the log as IN, but it acts like CONTAINS. Very strange. Then, if you go into Interface Builder and un-check and then re-check contains and re-run the demo, you get an error. But then it worked in ^my^ app which is doing a Core Data fetch instead of a Spotlight search. I know that's not a real good description but I need to move on here. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Reading in dictionary from txt file: options for speed
Marcel, NOW we're talking. This has really been such an eye-opening thread. Now it's googling time to try to figure out how to search for a string in there. Thanks! On Wed, Apr 15, 2009 at 7:01 PM, WT jrca...@gmail.com wrote: Hi Marcel, that's quite impressive. On the simulator on my machine, it took 0.007 seconds, consistently. Learned something new with your message. Thanks! Wagner On Apr 16, 2009, at 12:35 AM, Marcel Weiher wrote: I would do the following: 1. map the file into memory using -[NSData dataWithContentsOfMappedFile:] (or mmap() if you really want to) 2. Do not convert to individual objects for the words 3. get the pointer to the raw bytes 4. search using a little bit of plain old C (assuming you're OK with encodings) Memory mapping will be essentially instantaneous, with the I/O performed on-demand when its actually needed (or you can pre-heat the data, for example in a background thread). More importantly, you will be doing good things for memory consumption, because the mapped memory can be released to the OS without having to kill your app in low-memory situations (without paging it out on Mac OS X, but the iPhone doesn't page memory out). I added an implementation of this approach to the testing program provided by Wagner (thanks!) and it loads + counts the words in 0.084 seconds on the device. That's anywhere from around 50 - 100 times faster than the other methods implemented in DictTest (plist / xml / txt ). On the simulator, it runs in 0.043 seconds, so around 30-40 times faster than the other methods. Download can be found here: http://www.metaobject.com/downloads/Objective-C/DictTest.tgz You mentioned that you were OK with search performance, so I won't go into that. Cheers, Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/vardpenguin%40gmail.com This email sent to vardpeng...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in dictionary from txt file: options for speed
Hi Wagner, we have rather impressive hardware these days, and Objective-C can access all that power if you let it. The 0.007 time for the simulator you got sounds about right, my 0.043 was a typo, I was missing a leading zero (fast MacPro). Incidentally, the - [start timeIntervalSinceNow] you used in your code is a really clever trick for getting elapsed time, it took me a while to figure out that it was not a bug :-) Cheers, Marcel On Apr 15, 2009, at 19:01 , WT wrote: that's quite impressive. On the simulator on my machine, it took 0.007 seconds, consistently. Learned something new with your message. On Apr 16, 2009, at 12:35 AM, Marcel Weiher wrote: I would do the following: 1. map the file into memory using -[NSData dataWithContentsOfMappedFile:] (or mmap() if you really want to) 2. Do not convert to individual objects for the words 3. get the pointer to the raw bytes 4. search using a little bit of plain old C (assuming you're OK with encodings) Memory mapping will be essentially instantaneous, with the I/O performed on-demand when its actually needed (or you can pre-heat the data, for example in a background thread). More importantly, you will be doing good things for memory consumption, because the mapped memory can be released to the OS without having to kill your app in low-memory situations (without paging it out on Mac OS X, but the iPhone doesn't page memory out). I added an implementation of this approach to the testing program provided by Wagner (thanks!) and it loads + counts the words in 0.084 seconds on the device. That's anywhere from around 50 - 100 times faster than the other methods implemented in DictTest (plist / xml / txt ). On the simulator, it runs in 0.043 seconds, so around 30-40 times faster than the other methods. Download can be found here: http://www.metaobject.com/downloads/Objective-C/DictTest.tgz You mentioned that you were OK with search performance, so I won't go into that. Cheers, Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Importing Word doc in Carbon app via Cocoa
Foundation memory management for CoreFoundation programmers, in brief: * the Create rule becomes the you own all references returned by a method beginning with new, copy, or alloc * the Get rule becomes you do not own any references returned by a method beginning with anything else * CFRetain(CFTypeRef blah) becomes [blah retain]. * CFRelease(CFTypeRef blah) becomes [blah release] or [blah autorelease]. See below for more on autoreleasing. The most common manifestation of this is [[NSBlah alloc] init] falls under the Create rule, while [NSBlah blah] falls under the Get rule. You see a lot more use of the Get rule because of Foundation's use of autorelease pools. get methods in Foundation generally have nothing to do with the Get rule. Foundation uses a get-prefixed method (like -getBlah:buffer) to indicate that a value will be returned by reference in the provided argument; sometimes you must provide the memory, sometimes it will be allocated for you – check the documentation to figure out what's going on. You are responsible for releasing via -release any owning references returned to you per the Foundation variation on the Create rule. You can release those references either directly and immediately via -release, or indirectly via -autorelease, at which point the topmost autorelease pool takes ownership of the reference from you. The autorelease pool stack is generally popped at the end of each cycle through the event loop. If you are not using a Cocoa event loop, you are responsible for setting up an autorelease pool and draining the pool when you are done with it. Sending the pool a -drain message (available in Mac OS X 10.4 and later) is preferable to sending it a release message, because drain will trigger a garbage collection if necessary in a garbage-collected environment (otherwise functioning as -release in a reference-counted environment), while -release is purely a no-op in a garbage-collected environment. —Jeremy On Thu, Apr 16, 2009 at 11:57 AM, Steve Mills smi...@multi-ad.com wrote: On Apr 16, 2009, at 10:44:07, Jesper Storm Bache wrote: You'll want to read Cocoa memory management: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#//apple_ref/doc/uid/2043 The general rule is that if you do *not* create an instance by using [[X alloc] initZZ] then you should *not* call release (because your instance has been auto released). Thanks for the help, everyone. I hope I remember the rules the next time I have to deal with Cocoa. _ Steve Mills Me: 952-401-6255 Senior Software Architect MultiAd smi...@multiad.com www.multi-ad.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jeremyw.sherman%40gmail.com This email sent to jeremyw.sher...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Importing Word doc in Carbon app via Cocoa
On Apr 16, 2009, at 11:43 AM, Jeremy W. Sherman wrote: Foundation memory management for CoreFoundation programmers, in brief: * the Create rule becomes the you own all references returned by a method beginning with new, copy, or alloc * the Get rule becomes you do not own any references returned by a method beginning with anything else pedantic s/beginning with/containing/g /pedantic mutableCopy would not be included otherwise. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Reading in dictionary from txt file: options for speed
On Apr 16, 2009, at 10:10 , Miles wrote: Marcel, NOW we're talking. This has really been such an eye-opening thread. Now it's googling time to try to figure out how to search for a string in there. 1. Get the bytes out of your search string in the encoding that your dictionary is in 2. surround with '\n' characters to make sure you find whole words, not substrings (you will need to add a leading '\n' to your strings file 3. Use strnstr() -- man strnstr() Cheers, Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: IsBadCodePtr in Cocoa or Unix?
I would suggest reading Microsoft's own notes on that function, which might tell you why it's a bad idea to use that function even under Windows, and give you a clue on how to do something similar on other platforms. You should probably look at catching a SIGSEGV, which should be possible, and is still a ridiculously bad idea (if the Microsoft warnings weren't enough). Also, just a note, the function is deprecated on Windows, and if it's deprecated on Windows, that's probably a good reason not to use it or anything similar. :) On Apr 16, 2009, at 11:09 AM, Eric Gorr wrote: I was wondering if anyone knows of a Cocoa or Unix based equivalent for this window function...? http://msdn.microsoft.com/en-us/library/aa366712(VS.85).aspx Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/colin.cornaby%40mac.com This email sent to colin.corn...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IsBadCodePtr in Cocoa or Unix?
On Thu, Apr 16, 2009 at 11:09 AM, Eric Gorr mail...@ericgorr.net wrote: I was wondering if anyone knows of a Cocoa or Unix based equivalent for this window function...? Not really. And if you're at the point where you're asking whether or not a pointer is bad in production code, you've already failed :) What problem are you actually trying to solve, perhaps there is a better way. Even on Windows, the use of that function is discouraged (as indicated by the documentation that you linked to): IsBadXxxPtr should really be called CrashProgramRandomly Often I'll see code that tries to protect against invalid pointer parameters. This is usually done by calling a function like IsBadWritePtr. But this is a bad idea. IsBadWritePtr should really be called CrashProgramRandomly. The documentation for the IsBadXxxPtr functions presents the technical reasons why, but I'm going to dig a little deeper. For one thing, if the bad pointer points into a guard page, then probing the memory will raise a guard page exception. The IsBadXxxPtr function will catch the exception and return not a valid pointer. But guard page exceptions are raised only once. You just blew your one chance... http://msdn.microsoft.com/en-us/library/aa366712(VS.85).aspx Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com This email sent to clarkc...@gmail.com -- Clark S. Cox III clarkc...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IsBadCodePtr in Cocoa or Unix?
On Apr 16, 2009, at 2:21 PM, Clark Cox wrote: On Thu, Apr 16, 2009 at 11:09 AM, Eric Gorr mail...@ericgorr.net wrote: I was wondering if anyone knows of a Cocoa or Unix based equivalent for this window function...? Not really. And if you're at the point where you're asking whether or not a pointer is bad in production code, you've already failed :) I agree. What problem are you actually trying to solve, perhaps there is a better way. It's actually not my problem, so I can't say for sure. I was just asked by someone who is porting some Windows code to the Mac what an equivalent function was and I didn't know. They wanted an answer, so I asked here for them. Even on Windows, the use of that function is discouraged (as indicated by the documentation that you linked to): IsBadXxxPtr should really be called CrashProgramRandomly Interesting. I didn't actually read it, but was just told it was the function they were using. I will forward your answer on and perhaps try to get some more information on what they are trying to do and why. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: IsBadCodePtr in Cocoa or Unix?
On Apr 16, 2009, at 11:21 AM, Colin Cornaby wrote: I would suggest reading Microsoft's own notes on that function, which might tell you why it's a bad idea to use that function even under Windows, and give you a clue on how to do something similar on other platforms. You should probably look at catching a SIGSEGV, which should be possible, and is still a ridiculously bad idea (if the Microsoft warnings weren't enough). As everyone has noted, there are good reasons why ordinary code should not start examining pointers handed to it for validity. However, there are occasionally debugging situations in which there are legitimate reasons to want to know whether a particular range of memory is mapped, and how. Typically one would use gdb and other tools to examine the address space, but if for some reason you need to do so programmatically, it is possible to find out all sorts of information about the address space of a process via various Mach APIs. This is pretty deep stuff, so I won't even start to explain it in a mail message; if you want to do it, you had better understand it thoroughly. Douglas Davidson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Reading in dictionary from txt file: options for speed
It looks like I have the search working like this, but I have to double-space the dictionary file to have a leading \n. NSString *searchStr= @\njoy\n; NSData *strData= [searchStr dataUsingEncoding:NSUTF8StringEncoding]; const char *strBytes= [strData bytes]; const char *fileBytes= [stringFileContents bytes]; char *ptr= strstr(fileBytes, strBytes); Is that what you were thinking? Thanks! On Thu, Apr 16, 2009 at 11:47 AM, WT jrca...@gmail.com wrote: Marcel, since he'll be dealing with the string's raw bytes, won't Miles have to manually add a null byte to terminate the search string? Wagner On Apr 16, 2009, at 7:57 PM, Marcel Weiher wrote: On Apr 16, 2009, at 10:10 , Miles wrote: Marcel, NOW we're talking. This has really been such an eye-opening thread. Now it's googling time to try to figure out how to search for a string in there. 1. Get the bytes out of your search string in the encoding that your dictionary is in 2. surround with '\n' characters to make sure you find whole words, not substrings (you will need to add a leading '\n' to your strings file 3. Use strnstr() -- man strnstr() Cheers, Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
BAS use of asl_log()
I am looking the Apple's Better Authorization Sample code to figure out how to launch privileged helper tools from a Cocoa app. The BAS code includes use of asl_log(), but sometimes the format field is a string literal like: err = asl_log(asl, aslMsg, ASL_LEVEL_ERR, Request failed: %m); and sometimes format is a variable like: const char * errStr = NULL; ... errStr = Unexpected error while accepting a connection: %m; ... err = asl_log(asl, aslMsg, ASL_LEVEL_ERR, errStr); Is there a requirement that at compile time the format field be known (as in the first example), or can it also be generated at run time (as in the second condition)? Thanks, Todd ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: QTMovieDidEndNotification
On Apr 14, 2009, at 4:59 PM, Tilo Villwock wrote: i have a list with QTMovie objects which are supposed to be played one after another. Now, to recognize when a movie has finished playing i registered for the QTMovieDidEndNotification. For some reason though this notification is sometimes posted several times leading to a somewhat random behaviour, so that some movie objects are sometimes skipped and sometimes it works. Has anyone experienced something similar? Any suggestions? I've never had a problem with it. My guess is something in your code is causing multiple end notifications? -- Seth Willits ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Simulating a click in NSStepper
I'm using a NSStepper with the little up and down arrows. I want to simulate a click where the correct arrow will get highlighted as if someone clicked into it. I'm unclear how I should do this. I can do a perform click but that does not specify what arrow to click. Any suggestions? thanks for the help -dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Setting a layer delegate affects drawRect being called
Hi, I have a View whose drawRect method never gets called when I call [View setNeedsDisplay]. It looks like the reason is that the View's layer delegate is been set and If I remove that drawRect is called. Is this an expected behavior or something else is going on ? thanks -mohan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Create folder in protected directory
Hello everyone, My App has to create a folder in a directory owned by the system. How would I go about doing this, do I need to use the security framework and get the user to authenticate themselves as an admin? Thanks! --Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: BAS use of asl_log()
On 2009 Apr 16, at 12:40, Todd Heberlein wrote: err = asl_log(asl, aslMsg, ASL_LEVEL_ERR, Request failed: %m); ... err = asl_log(asl, aslMsg, ASL_LEVEL_ERR, errStr); Is there a requirement that [a] at compile time the format field be known (as in the first example), or [b] can it also be generated at run time (as in the second condition)? Looks like the answer, by example, is (b), Todd. If you have any doubts, you can get the documentation for asl_log by option-clicking it in Xcode, or in Xcode's Help menu click Open man page, then type in asl_log. If the documentation is ambiguous, as it sometimes is on these bsd- level functions, I believe the appropriate place to ask questions would be darwin-ker...@lists.apple.com. They give good help over there. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Reading in dictionary from txt file: options for speed
Also, any idea why these lines would give different results in different projects? NSString *searchStr= @\njoy\n; NSData *strData= [searchStr dataUsingEncoding:NSUTF8StringEncoding]; const char *strBytes= [strData bytes]; When this code is in the project you sent, strBytes shows '\njoy\n' in the debugger (which is what I'd expect), but when i copy the exact code to a different project strBytes shows extra memory stuff after it, like '\njoy\n\x1b\x14\xc0' Seems very odd. On Thu, Apr 16, 2009 at 12:01 PM, Miles vardpeng...@gmail.com wrote: It looks like I have the search working like this, but I have to double-space the dictionary file to have a leading \n. NSString *searchStr= @\njoy\n; NSData *strData= [searchStr dataUsingEncoding:NSUTF8StringEncoding]; const char *strBytes= [strData bytes]; const char *fileBytes= [stringFileContents bytes]; char *ptr= strstr(fileBytes, strBytes); Is that what you were thinking? Thanks! On Thu, Apr 16, 2009 at 11:47 AM, WT jrca...@gmail.com wrote: Marcel, since he'll be dealing with the string's raw bytes, won't Miles have to manually add a null byte to terminate the search string? Wagner On Apr 16, 2009, at 7:57 PM, Marcel Weiher wrote: On Apr 16, 2009, at 10:10 , Miles wrote: Marcel, NOW we're talking. This has really been such an eye-opening thread. Now it's googling time to try to figure out how to search for a string in there. 1. Get the bytes out of your search string in the encoding that your dictionary is in 2. surround with '\n' characters to make sure you find whole words, not substrings (you will need to add a leading '\n' to your strings file 3. Use strnstr() -- man strnstr() Cheers, Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSView modifies CALayer's masksToBounds?
Is there a way to stop an NSView from modifying its CALayer's masksToBounds property? It looks like it's making the change during a frame resize. It's making a call to some internal selector called _updateLayerMasksToBoundsFromView. AFAIK, there's no way to turn on or off masking from the NSView level, except for maybe - wantsDefaultClipping. Is that the way to do it? Thanks, Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Quickie question on text edit cycle (and textDidEndEditing notification)
Hello Cocoa listers. What is the best/right way to obtain the context object for a piece of text that has been edited by the editing system (i.e. in a cell in NSOutlineView) once the textDidEndEditing notification is delivered to an observer? This is the second or third time I have added text editors in controls where I've wanted to capture the final state of the editor to set it into an object (i.e. not doing this automatically with binding). Each case has been a bit different. In this case I have a fairly straight-forward NSOutlineView and a custom cell really just to do some specific text editing stuff. Pretty much everything is working fine - but unlike previous occasions when I have used the field editor, in this case once I get my textDidEndEditing notification, I need to find the object that the editor is representing in order to update a property. What I'm wondering is how this is _supposed_ to be done. The actual notification of textDidEndEditing does not include much contextual information AFAICS. It does provide you with the NSText object that handled the editing, from which I can happily get the final text. However, I'm not sure what the best practice is for obtaining the 'represented object' to which this text should be assigned. I've chosen to implement the notification method in my custom cell class, which works fine, but the instance of this cell appears is not initialised with outlineView:willDisplayCell:forTableColumn:item. Therefore the cell's representedObject is nil and I cannot use this way to get the context. I could simply ask the control (the outline view) what the currently selected row is, and get the object to update from the arrangedObjects of my NSTreeController. This seems a very 'long way round' though. I suspect I'm simply missing some way to have the editing system remember a context object for me and pick it up later (but I don't see anything obviously doing this in the NSText interface, that I'm guaranteed to be able to obtain and use from the textDidEndEditing notification). -- Luke ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Create folder in protected directory
Thanks for reply Kyle. The app restores a user's user folder and needs to recreate that folder within the /Users directory. Is there an easier way to accomplish this then having to use the Authorization services C library? On Apr 16, 2009, at 3:53 PM, Kyle Sluder kyle.slu...@gmail.com wrote: On Thu, Apr 16, 2009 at 5:59 PM, Chris Purcell haroldthehun...@mac.com wrote: My App has to create a folder in a directory owned by the system. How would I go about doing this, do I need to use the security framework and get the user to authenticate themselves as an admin? Yes, the Security framework is necessary here, but the more important question is why you need to do this. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in dictionary from txt file: options for speed
Miles wrote: NSString *searchStr= @\njoy\n; NSData *strData= [searchStr dataUsingEncoding:NSUTF8StringEncoding]; const char *strBytes= [strData bytes]; Think about what you're doing here, then look at the NSString method - UTF8String. Also, think about whether dataUsingEncoding: includes or excludes a terminating null. For example, if searchStr were assigned @, what is the length of the resulting strData, and exactly what does [strData bytes] return? A combination of referring to reference docs and some experimenting is the usual approach here. Next, consider the above in light of the args to strstr(), which are expected to be null-terminated C-style strings. Finally, consider what happens if searchStr isn't found. I urge you to try it with a searchStr assigned a misspelled word like @spelchek. If it seems like I'm asking you to debug and understand your own code without asking the list for the complete answer, you're right. This is a pretty elementary example to work on, and there's no substitute for being able to figure it out for yourself. If you can't debug this one without direct assistance, you will be lost at sea when the debugging gets harder (and it WILL get harder). -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Reading in dictionary from txt file: options for speed
No null terminator... Now it's perfectly possible the bytes will get written into a zeroed block, and so there will be a null terminator purely by chance some times, and not other times. Why the NSData? Why not just get a C string from searchStr, if that's what you want? Otherwise, in general an NSData is not a string; it won't end with a 0 byte unless you put one there, and it can contain 0s mid-stream as well. That's why it's got an explicit length. -- Scott Ribe scott_r...@killerbytes.com http://www.killerbytes.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Reading in dictionary from txt file: options for speed
I'm all for just a little guidance, and thank you for it. Everything you said makes sense now, and I have it working: NSString *searchStr= @\nJOY\n; const char *cString = [searchStr UTF8String]; const char *fileBytes = [stringFileContents bytes]; char *ptr= strstr(fileBytes, cString); Thanks again On Thu, Apr 16, 2009 at 4:43 PM, Greg Guerin glgue...@amug.org wrote: Miles wrote: NSString *searchStr= @\njoy\n; NSData *strData= [searchStr dataUsingEncoding:NSUTF8StringEncoding]; const char *strBytes= [strData bytes]; Think about what you're doing here, then look at the NSString method -UTF8String. Also, think about whether dataUsingEncoding: includes or excludes a terminating null. For example, if searchStr were assigned @, what is the length of the resulting strData, and exactly what does [strData bytes] return? A combination of referring to reference docs and some experimenting is the usual approach here. Next, consider the above in light of the args to strstr(), which are expected to be null-terminated C-style strings. Finally, consider what happens if searchStr isn't found. I urge you to try it with a searchStr assigned a misspelled word like @spelchek. If it seems like I'm asking you to debug and understand your own code without asking the list for the complete answer, you're right. This is a pretty elementary example to work on, and there's no substitute for being able to figure it out for yourself. If you can't debug this one without direct assistance, you will be lost at sea when the debugging gets harder (and it WILL get harder). -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/vardpenguin%40gmail.com This email sent to vardpeng...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Setting up an auxiliary task for use with Distributed Objects
On Apr 16, 2009, at 4:01 AM, Oleg Krupnov wrote: 2) How do I quit the aux task? [NSTask terminate] does not work, invalidating the connection does not work... First, your MyVendedObject class should expose a method for the client to request that the server terminate. Then, you can change your code... MyVendedObject* vendedObj = [[[MyVendedObject alloc] init] autorelease]; NSConnection* connection = [NSConnection defaultConnection]; [connection setRootObject:vendedObj]; if ([connection registerName:@MyAuxTask]) { Replace this line: [[NSRunLoop currentRunLoop] run]; with something like: while ([vendedObj shouldKeepRunning]) [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate: [NSDate distantFuture]]; } 1) I need to block the main task until the aux task is ready to work. How do I do it? Sleep/poll connection/repeat doesn't seem a good approach, is there any better way? Have you considered reversing the roles of the two processes, in terms of which is the server and which the client? You can have the main task register a connection under a known name. It will vend an object with which the auxiliary task will register. It will start the auxiliary task. The auxiliary task will obtain the vended object from the main task using the known name. The auxiliary task will create a worker object. It will pass that worker object to the main task in a check-in message. It will then run the run loop in the manner illustrated above. The main task will passively receive a reference (proxy) for the auxiliary task's worker object. It can then invoke methods of that object just as it would in the design you were working with. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Create folder in protected directory
On Thu, Apr 16, 2009 at 7:23 PM, Chris Purcell haroldthehun...@mac.com wrote: Thanks for reply Kyle. The app restores a user's user folder and needs to recreate that folder within the /Users directory. Is there an easier way to accomplish this then having to use the Authorization services C library? Ah. I'm afraid not, at least not directly. I think there's some machinery in the OS to recreate a skeleton home directory for users, but that might only be involved in a network environment. Make sure to read and understand the BetterAuthorizationSample and the security implications mentioned therein. Also read up on messages regarding AuthorizationExecuteWithPrivileges on this list (maybe also the CDSA list as well? I'm not a subscriber). Good luck, --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in dictionary from txt file: options for speed
On Thu, Apr 16, 2009 at 8:09 PM, Miles vardpeng...@gmail.com wrote: char *ptr = strstr(fileBytes, cString); OK, this makes sense, but you're still doing a linear scan through the data you've loaded (and I'm assuming creating NSString objects from what you find because plain old C strings will be pretty useless to you otherwise). You might very well find that storing the plist representation winds up being faster or saving you from some code in the future. Particularly if you are doing lookups in the dictionary based on user input, because Unicode is tricky with what is considered equal. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSView modifies CALayer's masksToBounds?
On Thu, Apr 16, 2009 at 7:14 PM, Mike Manzano m...@instantvoodoomagic.com wrote: Is there a way to stop an NSView from modifying its CALayer's masksToBounds property? The layer that backs a layer-backed view is Not Yours(TM). If you want control over the layer, you need to use a layer-hosted view. This means you might have to do a lot more work to keep AppKit's view of the world in sync with your layer tree. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Simulating a click in NSStepper
On Apr 16, 2009, at 3:13 PM, David Alter wrote: I'm using a NSStepper with the little up and down arrows. I want to simulate a click where the correct arrow will get highlighted as if someone clicked into it. I'm unclear how I should do this. I can do a perform click but that does not specify what arrow to click. Any suggestions? You can do this by creating fake mouse down and mouse up events, and add them to the application's event queue so that the mouse down event is handled before the mouse up event. See the NSEvent documentation for details on how to make your own events. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in dictionary from txt file: options for speed
On Apr 16, 2009, at 12:01 , Miles wrote: It looks like I have the search working like this, but I have to double-space the dictionary file to have a leading \n. No, you just need one initial extra newline at the start, the newline from the end of the last string matches up with the starting newline of the modified search string. NSString *searchStr= @\njoy\n; NSData *strData= [searchStr dataUsingEncoding:NSUTF8StringEncoding]; const char *strBytes= [strData bytes]; const char *fileBytes= [stringFileContents bytes]; char *ptr= strstr(fileBytes, strBytes); Is that what you were thinking? Roughly. -(BOOL)containsString:(NSString*)searchString { int stringLen=[searchString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; if ( stringLength 200 ) { char buffer[ stringLen +4 ]; char *ptr; buffer[0]='\n'; [searchString getBytes:buffer+1 maxLength:stringLen usedLength:NULL encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0,stringLen) remainingRange:NULL]; buffer[stringLen+1]='\n'; buffer[stringLen+2]=0; ptr = strnstr([stringFileContents bytes], buffer, [stringFileContents length] ); return ptr != NULL; } } 1. I use a local buffer and copy the string into that, and assume you don't have words with more than 200 characters. 2. I copy the newlines into that buffer and null terminate it. - Your method is probably just as good, except that you need to null terminate your strings, not sure that happens. 3. I use strnstr() instead of strstr() because the dict isn't null terminated either. Cheers, Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: -viewDidMoveToWindow without subclassing? NSViewController?
On 17/04/2009, at 1:43 AM, Jerry Krinock wrote: The other way around, Graham. I need the window controller, so I get it from -window. See below. I don't see why you need to get this from an item in a tab view? You talk about the need to initialise something. What? How? What are you trying to do? In general, I need the document during initialization, so I do [[[aView window] windowController] document] Here are two examples of why I need the document: * In an NSPredicateEditor subclass, during -viewDidMoveToWindow, creating the row templates requires a reference to the document's managed object context, so it can get attribute types. See code [1]. * In an NSOutlineView subclass, during -viewDidMoveToWindow, I need to initialize and set a data source, which needs a (weak) reference to the document in order to get data objects. See code [2]. Is this an abnormal design pattern? I think I've seen people set their document as nib File's Owner, but I can't do that since my document is sometimes instantiated without a window. My nib File's Owner is a window controller. This does sound like an abnormal design pattern. The controller should be in charge, so going from view - window - controller - document seems backwards. The controller's initialization (whether at awakeFromNib or windowDidLoad time) should be handling this, so you can do self - document to access the document. The controller is responsible for forging the necessary links and set up between any views it knows about and the document. The view definitely shouldn't be doing this, the controller definitely should be. I've not used NSPredicateEditor, so I'm not familiar with it, but as a view it shouldn't be talking directly to the data model. Instead, the controller should give it what it needs as appropriate. The same pattern definitely applies to NSOutlineView, which I am familiar with. The controller is typically its datasource, which you can set in IB. The controller then gathers data from the real datasource (the document, say) and presents it to the view. Effectively the controller proxies the data from the document on demand. This approach requires no special initialisation - the NSOutlineView won't ask for data until it's ready to display it, at which point it must by definition be visible and in a window. The controller can then just fetch (and possibly cache) data from the document and return it to the outline view in the usual way. I'd be surprised if the same technique would be inappropriate for the predicate editor also. Trying to hook into certain moments like when a view is moved to the window sounds error prone, tricky, and unnecessary. I've never found the need to do that sort of thing using window controllers - let the views come to the window controller for their data, and let the window controller be in charge of obtaining it. It seems like you're trying to short-circuit the controller and simply using it to make a direct connection between the document and the view - this is probably where you're going wrong. Place the controller in the data pathway, don't just use it to make a pathway directly between data model and view. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSView modifies CALayer's masksToBounds?
The example in the docs say: CoreAnimationdoesn'tprovideameansforactuallydisplayinglayersinawindow , theymustbehostedby aview. Whenpairedwithaview, theviewmustprovideevent- handlingfortheunderlyinglayers, whilethe layersprovidedisplayofthecontent. In the sample code, here is the example given to put a layer into a view: [theView setLayer: theRootLayer]; [theView setWantsLayer:YES]; Is this what you mean by a layer-hosted view? If so, does that mean that theRootLayer is mine to manage as I wish? Currently, I am just modifying the layer given to the view after I call -setWantsLayer on it. How is this layer different from theRootLayer in the example? Thanks, Mike On Apr 16, 2009, at 5:33 PM, Kyle Sluder wrote: On Thu, Apr 16, 2009 at 7:14 PM, Mike Manzano m...@instantvoodoomagic.com wrote: Is there a way to stop an NSView from modifying its CALayer's masksToBounds property? The layer that backs a layer-backed view is Not Yours(TM). If you want control over the layer, you need to use a layer-hosted view. This means you might have to do a lot more work to keep AppKit's view of the world in sync with your layer tree. --Kyle Sluder smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Reading in dictionary from txt file: options for speed
I'm creating a game for where the dictionary file will never get modified, so I'm not really worried about that. The strings that I am searching for are not from user input, but from user selection, so I'm guaranteed to have the case be correct -- so I don't need to worry about upper vs lower-case for this. You can think of it in the context of something like the game Wurdle, where the user selects those scrabble-like tiles and the tiles each have a predefined character associated with it. Yes, the original suggestion to use strstr(). It is slow, for a word that's never found it takes 0.704 seconds on the device. Definitely too long. To answer your other questions... It's initalized like this: NSString *filePath = [[NSBundle mainBundle] pathForResource: @dictionary ofType: @txt]; stringFileContents = [[NSData alloc] initWithContentsOfMappedFile:filePath]; On Thu, Apr 16, 2009 at 5:55 PM, Greg Guerin glgue...@amug.org wrote: Miles wrote: const char *fileBytes = [stringFileContents bytes]; char *ptr= strstr(fileBytes, cString); Are you certain the bytes returned by [stringFileContents bytes] null-terminated? How was that data initialized? If it's reading from a file, is there guaranteed to be a null-terminator in the file? What happens if there isn't? Suppose the file gets edited and loses any overt null-terminator you have now, what will your program do? Was the original suggestion to use strstr(), or was there a similar function with a length? You also need to think about case-sensitivity, because searching for joy, Joy, joY, or JOY might be different depending on where the search-term is coming from, and what letter-case means (or doesn't mean) in context. And what is the context? I don't think you ever said what you were trying to accomplish with this dictionary and searching in it. And since you have the words options for speed in the Subject, it's possible that strstr()'s linear search could be a speed problem. Or it's possible that linear search is fine (for worst-case, test it with a word that you know isn't anywhere in the dictionary). And that goes back to the What are you trying to accomplish? question, now that the how to has been more or less answered, at least for one case. -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/vardpenguin%40gmail.com This email sent to vardpeng...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSView modifies CALayer's masksToBounds?
On Thu, Apr 16, 2009 at 9:17 PM, Mike Manzano m...@instantvoodoomagic.com wrote: [theView setLayer: theRootLayer]; [theView setWantsLayer:YES]; Is this what you mean by a layer-hosted view? If so, does that mean that theRootLayer is mine to manage as I wish? Yes. If you set the layer before calling -setWantsLayer:, you get a layer-hosted view (think of it as AppKit saying I will allow the view you provided to host this view.) On the other hand, if you call -setWantsLayer: without calling -setLayer:, AppKit creates a private view and says Mine!. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reading in dictionary from txt file: options for speed
On Thu, Apr 16, 2009 at 2:47 PM, WT jrca...@gmail.com wrote: Marcel, since he'll be dealing with the string's raw bytes, won't Miles have to manually add a null byte to terminate the search string? The strnstr() function takes a length, and can thus be safely used on buffers which contain no NUL byte. On Tiger and earlier, strnstr() had a bug where it could read one byte past the length specified, which could cause a crash in certain circumstances. Had a grand old time tracking that one down, I did. It was eventually fixed in a security update, and I believe it was fixed in Leopard from the start. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[SOLVED] Re: NSView modifies CALayer's masksToBounds?
That did it. Thanks! One last question. If I supply my own layer, is it legal to add subviews to the view that's hosting my layer? On Apr 16, 2009, at 6:46 PM, Kyle Sluder wrote: On Thu, Apr 16, 2009 at 9:17 PM, Mike Manzano m...@instantvoodoomagic.com wrote: [theView setLayer: theRootLayer]; [theView setWantsLayer:YES]; Is this what you mean by a layer-hosted view? If so, does that mean that theRootLayer is mine to manage as I wish? Yes. If you set the layer before calling -setWantsLayer:, you get a layer-hosted view (think of it as AppKit saying I will allow the view you provided to host this view.) On the other hand, if you call -setWantsLayer: without calling -setLayer:, AppKit creates a private view and says Mine!. --Kyle Sluder smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Reading in dictionary from txt file: options for speed
On Apr 16, 2009, at 18:59 , Michael Ash wrote: On Thu, Apr 16, 2009 at 2:47 PM, WT jrca...@gmail.com wrote: since he'll be dealing with the string's raw bytes, won't Miles have to manually add a null byte to terminate the search string? The strnstr() function takes a length, and can thus be safely used on buffers which contain no NUL byte. As far as I can tell it only takes one length, and that's for the string to be searched, so he will have to NULL-terminate the search string (which is what WT was talking about as far as I can tell). Well that would be the case if strnstr() were actually useful for him, which I guess it isn't. On Tiger and earlier, strnstr() had a bug where it could read one byte past the length specified, which could cause a crash in certain circumstances. Had a grand old time tracking that one down, I did. It was eventually fixed in a security update, and I believe it was fixed in Leopard from the start. Funky stuff! Marcel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Create Library of Media File
Hi,everyone Now, I am trying to write a music player app. So I want to create a Library to add my sound files to it. The function of the library is same as iTunes library. What's the principle of creating the Library? And,how to implement it? Any clues and documents about about is lucky for me. Mac ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
The fact that Core Data cannot fetch using a predicate based on transient properties [1] seems to greatly limit the utility of the NSPredicateEditor view, and makes me very sad. For example, say that my objects are student test results with a 'score' attribute and two dozen other properties. I could give the user an NSPredicateEditor and let them have oodles of fun constructing complex predicates. But what if I need the user to be able to set a predicate with a left- side-expression of letter grade and a right-side-expression popup menu showing 'A' - 'F'. If I could fetch based on a transient 'letterGrade' attribute, I could implement some custom accessors which would calculate 'letterGrade' from 'score' as needed, the predicate emitted from the NSPredicateEditor would just work, and life would be sweet. But since I can't use transient properties in my predicate, providing a popup like that in NSPredicateEditor seems to mean that I'm going to have to somehow deconstruct the compound predicate which Apple put so many man-years of engineering into, have Core Data do sub-fetches, then do my own filtering and put the results back together. I fear that writing bug-free code to handle the general compound predicate would be very time-consuming, and also it would be MVC hell with my NSPredicateEditor subclass (view) code wanting to have model logic such as if score 93, letterGrade = 'A'. Does anyone have any suggestions for a least worst workaround? Thanks, Jerry [1] http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdFetching.html#/ /apple_ref/doc/uid/TP40002484 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Cocoa program without xib file
Hello everyone: I want to build a Cocoa program without xib file. But I can't find any introductions or tutorials. Does anybody know where I can find those source? best wishes YongLi ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Advice on server-side web service technology
I am working on a custom Obj-C framework that I need to expose through web services on an Xserve. I am finding a serious lack of support for server-side web services in the Cocoa frameworks. My searching has turned up little from others following this same path. From what I have found, these are my options: - WebObjects (Java, is this still recommended for use? still supported and maintained?) - gSOAP (or other C/C++ technology in front of the Obj-C, little messy but doable) - Mono (web services would be easy, connecting it up to my Obj-C library may be tricky) Are there other options I am unaware of? Your opinions on the best path to follow? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSMetadataQueryDidUpdateNotification problem with volumes
I've setup a NSMetaDataQuery to search for particular file types. I've set the search scope to NSMetadataQueryLocalComputerScope. The initial search phase works correctly. The query returns all of the expected files on all of the local volumes. Now if I add a file to the root volume I get the NSMetadataQueryDidUpdateNotification notification as expected. But adding a file to any of the other local volume does not seem to fire the notification. I know that spotlight is indexing the files because a similar search through the finder will return the newly added files. Also if I restart my application the new files will be found in the initial search phase. Is this a bug or am I missing something? -- Eddie Aguirre ed...@markzware.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cocoa program without xib file
On Apr 15, 2009, at 10:35 PM, YongLi wrote: I want to build a Cocoa program without xib file. But I can't find any introductions or tutorials. Does anybody know where I can find those source? What are you trying to do? Building a Cocoa program without a MainMenu.xib [or MainMenu.nib] is possible, but it is not recommended, supported, or at all standard/ typical. b.bum ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [SOLVED] Re: NSView modifies CALayer's masksToBounds?
No. On 2009-04-16, at 10:50 PM, Mike Manzano wrote: That did it. Thanks! One last question. If I supply my own layer, is it legal to add subviews to the view that's hosting my layer? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cocoa program without xib file
Please search the cocoa-dev archives. This is talked about at considerable length... On Apr 16, 2009, at 12:35 AM, YongLi wrote: Hello everyone: I want to build a Cocoa program without xib file. But I can't find any introductions or tutorials. Does anybody know where I can find those source? best wishes YongLi ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net This email sent to a...@webis.net Alex Kac - President and Founder Web Information Solutions, Inc. The optimist proclaims that we live in the best of all possible worlds; and the pessimist fears this is true. -- James Clabell ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cocoa program without xib file
Why would you want to do that? Even if it is possible, and I'm not sure it is, it would imply writing, debugging, and maintaining a zillion more lines of code, code that has already been written, debugged, and is maintained regularly by Apple. Also, like I said, it might not even be possible, since (a) so much of Cocoa is dependent on interface builder and (b) it might require access to private APIs that only Apple has access to. Don't fight the APIs, unless you have a very good reason to do it. Do you have such a good reason? Wagner On Apr 16, 2009, at 7:35 AM, YongLi wrote: Hello everyone: I want to build a Cocoa program without xib file. But I can't find any introductions or tutorials. Does anybody know where I can find those source? best wishes YongLi ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jrcapab%40gmail.com This email sent to jrca...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cocoa program without xib file
Hello YongLi, are you writing for osx or iphone? http://ericasadun.com/ has sample code for iphone development, this sample code does not use xib files. On 16/04/2009, at 3:35 PM, YongLi wrote: Hello everyone: I want to build a Cocoa program without xib file. But I can't find any introductions or tutorials. Does anybody know where I can find those source? best wishes YongLi ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/compoundeye.dev%40gmail.com This email sent to compoundeye@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cocoa program without xib file
Jeff Johnson has written a series of articles exploring a nibless Cocoa app. You will find them at http://lapcatsoftware.com/blog/?s=%22working+without+a+nib%22. If you simply want to use Foundation without a nib, that's as easy as can be. If you want to use AppKit, good luck, and read Jeff's articles. —Jeremy On Thu, Apr 16, 2009 at 11:37 PM, Alex Kac a...@webis.net wrote: Please search the cocoa-dev archives. This is talked about at considerable length... On Apr 16, 2009, at 12:35 AM, YongLi wrote: Hello everyone: I want to build a Cocoa program without xib file. But I can't find any introductions or tutorials. Does anybody know where I can find those source? best wishes YongLi ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net This email sent to a...@webis.net Alex Kac - President and Founder Web Information Solutions, Inc. The optimist proclaims that we live in the best of all possible worlds; and the pessimist fears this is true. -- James Clabell ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jeremyw.sherman%40gmail.com This email sent to jeremyw.sher...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Setting up an auxiliary task for use with Distributed Objects
@Jeremy You can communicate with the task, since you seem to control it, by setting up a pipe (NSPipe) and setting its write/read file handles as the stdin/stdout for the task. The task can then send you a ready to go signal. You can use -[NSFileHandle waitForDataInBackgroundAndNotify] to get a callback when the ready signal is sent back. On the other side, you can have it check for a broken connection (is that possible with NSConnection/NSMachPort?) or just wait for a kill message to come across on its stdin, which your primary task can send over. Yes, it's an option to consider, thanks. However, DO seems to provide such a nice way to avoid using pipes, that I would first try to avoid introducing them just for the purpose of handshaking and termination the aux task. @Ken with something like: while ([vendedObj shouldKeepRunning]) [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; I think I've seen this code somewhere in the docs, but I haven't and I still don't understand how it can terminate the run loop, if the beforeDate specifies distant future? The shouldKeepRunning flag seems to be checked once at the beginning and never again. Could you explain how it's supposed to work? Have you considered reversing the roles of the two processes, in terms of which is the server and which the client? You can have the main task register a connection under a known name. It will vend an object with which the auxiliary task will register. It will start the auxiliary task. The auxiliary task will obtain the vended object from the main task using the known name. The auxiliary task will create a worker object. It will pass that worker object to the main task in a check-in message. It will then run the run loop in the manner illustrated above. The main task will passively receive a reference (proxy) for the auxiliary task's worker object. It can then invoke methods of that object just as it would in the design you were working with. It's a smart idea, but I don't see how it could help to block the main process until the aux process is initialized. As I understood, the advantage of this approach is that there's a way to notify the main process asynchronously from the aux process that the latter is ready to work. (So, the main process should temporarily switch into a waiting mode until the notification arrives, right?) However, I'm not sure that passing the worker object to the main task will work as you designed. I'm afraid that instead of the proxy, the main task will receive a copy of the worker object, because the worker object is not vended. Isn't it what vending is for - to obtain proxies instead of copies? An explanation would be appreciated. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Loading Entities from a CoreData document
Dear List, A while ago I wrote a simple application in which users create and manipulate CoreData entities named DataSets. Simple enough. I used the document preset so I didn't have to deal with any of the file writing stuff. Anyways, I'm writing a new application that uses these data sets. Users save the file from the prior application and can import data sets into this new application. At least, hypothetically at this point. The issue is, when using code like this (url points to a document full of data sets): NSPersistentDocument *pd = [NSPersistentDocument new]; BOOL success = [pd configurePersistentStoreCoordinatorForURL:url ofType:NSXMLStoreType modelConfiguration:nil storeOptions:nil error:error]; NSSet *ros = [[pd managedObjectContext] registeredObjects]; success comes back true, but there are no managed objects in 'ros'. So, is there some sample code I can see which loads the managed objects of an xml file? I've looked pretty exhaustively and everything seems too high level (relying on the single-file model that I implemented in my original application.) Am I missing something silly? Thanks in advance, Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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