Re: Binding to currently selected object in a list?
On Oct 9, 2009, at 5:08 PM, A B wrote: Is there a way to bind an ivar to the currently selected object of a list which is being represented in an NSTableView via bindings? Unfortunately there does not seem to be a selectedObject key (though there is one for selectedObjects). Binding to the controller's selection doesn't really work as I'd expect and even if it did, I'd only be getting back a proxy object - which negates the purpose for which I want to use it, which is to call methods on the object. I had put in a hack which observes changes in selection, gets the selectedObjects list, checks for a count 0, grabs the first and stuffs it into the ivar, etc. but not only does that feel really hackish, but doesn't always work. This would seem to be a pretty simple thing to want to do (i.e. present a list of objects, do things to/with the currently selected object) but I'm at somewhat of a loss to understand what I'm doing wrong. There's something just like this for NSPopUpButton. You bind its 'content' (and possibly 'contentObjects') binding to an indexed collection property of the controller. Then you bind its 'selectedObject' binding to a to-one property of the controller. When the pop-up is first set up, it displays the selected object as originally set on the controller's to-one property. Then, as the user selects items from the pop-up, the newly selected object is passed to the setter for that to-one property. Strangely, there's nothing quite like that for NSArrayController. I think the best you can do is to bind the array controller's selectionIndexes binding to an attribute of your coordinating controller. (For illustration purposes, I'll call this attribute property selectedWidgetIndexes.) Then that coordinating controller can have a selectedWidget to-one property which is set up to reflect the object which is selected in the array controller. One way is to make the selectedWidget property computed-on-the-fly based on the selection indexes: +(NSSet*)keyPathsForValuesAffectingSelectedWidget { return [NSSet setWithObject:@selectedWidgetIndexes]; } -(Widget*)selectedWidget { if (![self.selectedWidgetIndexes count]) return nil; return [self.widgets objectAtIndex:[self.selectedWidgetIndexes firstIndex]]; } In this scenario, you don't actually have an ivar backing the selectedWidget property. It's completely based off of the selectedWidgetIndexes property and the widgets to-many property. (The widgets property is assumed to be the indexed collection property that the array controller is representing. The selectedWidgetIndexes property can be a typical @synthesized copy property.) Another approach is to implement the setter for selectedWidgetIndexes and use that to update the selectedWidget property directly. In this case, selectedWidget isn't computed on the fly, but is actually held (cached) in an ivar: -(void)setSelectedWidgetIndexes(NSIndexSet*)newSelectedWidgetIndexes { if (![selectedWidgetIndexes isEqual:newSelectedWidgetIndexes]) { [selectedWidgetIndexes release]; selectedWidgetIndexes = [newSelectedWidgetIndexes copy]; if ([selectedWidgetIndexes count]) self.selectedWidget = [self.widgets objectAtIndex: [selectedWidgetIndexes firstIndex]]; else self.selectedWidget = nil; } } You don't need +keyPathsForValuesAffectingSelectedWidget since you're going through the setter for the selectedWidget property. The selectedWidget property can be a typical @synthesized retain property. By the way, notice that all of this discussion is in terms of the array controller and the coordinating controller. No mention of the table view because it's not directly relevant. The MVC design pattern in action. ;) 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: Document architecture - stop it from opening untitled documents?
On Oct 9, 2009, at 8:57 PM, aaron smith wrote: On Fri, Oct 9, 2009 at 6:52 PM, aaron smith beingthexemplaryli...@gmail.com wrote: Hey All, quick question. I'm trying to figure out how to stop untitled documents from opening when the application first runs. I've been looking on google, and tried some different combinations of method overrides on NSDocumentController. I figured out how to stop the untitled doc from opening, by overriding - (id)makeUntitledDocumentOfType:(NSString *)typeName error:(NSError **)outError, but the problem is that it's required to give it an NSError, which is fine. But the the application automatically opens up an alert error. if anyone has a quick pointer in the right direction that would be awesome. Thanks. ok. nevermind. I got it. You have to implement a method from NSApplicationDelegate: - (BOOL) applicationOpenUntitledFile:(NSApplication *) theApplication { return true; } Better to implement: - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { return FALSE; } That expresses that the application shouldn't open an untitled document, rather than it thinking it should and you faking success. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
re: [iPhone} Exception After Creating First Object
Hello, I got a couple of private messages about breakpoints and stacktraces, which, of course, I had done before I posted my question. That's how I discovered that [mod processPendingChanges] led to an exception when adding to an empty database table. I learned a little more about the exception. It occurs in [self.tableView endUpdates] which is invoked, I think, as a result of [moc processPendingChanges]. I have had problems in the past with [self.tableView endUpdates] with empty database tables but thought that this time was different. Previously, I had tried preventing [self.tableView endUpdates] being called when the database tables was empty but that caused other problems (e.g. my Add Entity Name button didn't appear when the database table was empty). I've seen others mention problems with [self.tableView endUpdates]. Does anyone know how to make [self.tableView endUpdates] less vulnerable when the associated database table is empty? Best regards, Steve ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to ease the burden on the Garbage Collector?
Thanks for the response. So, is 20% CPU time for the GC thread normal? Yup, that shows about 20% (of a core) being spent in GC. Best regards, Gabriel. 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
Fwd: UTIs and readFromURL/writeToURL
Hello, Suppose I have an application which can read and write images (using Image I/O). To make this known to the OS, I have to add stuff to my Info.plist, and wanted to do this using UTIs as I understand that's the new standard. However, I have a few problems here. First, do I really have to add all types to my Info.plist file? If the OS gets an update which adds a new file type to Image I/O, I have to update my Info.plist? I copied the relevant part of Preview.app, so I now have a nice list of two dozen of supported UTIs in my plist. However, I understood that when adding a known UTI, the system somehow would be able to fill in things like file extensions and human readbale file type name (Portable Network Graphics file for public.png). Do I need to add all the UTIs to the imported types section for that to work..? I noticed that I needed to add Document Type Name to each supported type, or they would not show up in the File Types pop up in the save panel I get when selecting Save As But when a type is selected there, I notice that I receive this human readable string as typeName in my writeToUrl:ofType:error. That's unfortunate, because CGImageDestinationCreateWithURL doesn't understand these typeNames, and wants the UTI. Do I really have to set up a table linking these human readable type names to UTIs programmatically? Also, I notice that I have to add file extensions to each type myself or my app's Open File panel keeps the files greyed out. This is probably related to the import UTIs question above. I (think I) have read the relevant documentation on developer.apple.com, but I can't seem to figure this out. I'm sure I can get it to work by adding extensions and CFBundleTypeNames to all the UTI types, and doing a lookup translating the CFBundleTypeName back to the UTI, but I have a feeling this can't be the proper way... Thanks, Sander ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to allocate and delegate; or how to keep GC and the static analyzer happy
All I have several cases of the following pattern in my code: - (void)start { [[Something alloc] initWithDelegate:self]; } - (void)finishWithSomething:(Something*)something { [something release]; } The intent of course is that the Something object calls back the caller with finishWithSomething: and that does the cleanup. Several UI classes can work this way e.g. -[UIActionSheet initWithTitle:delegate:...]. On 10/10/2009, at 12:29 PM, Jens Alfke wrote: On Oct 8, 2009, at 7:33 PM, Glen Low wrote: 1. The code is not GC friendly as between the end of start and the beginning of finishWithSomething, there are no references to the object, so it may be collected. There must be references to it; otherwise how would that object's methods get called later on? Either it's a delegate of another object (an NSURLConnection or NSTimer or whatever) or it starts a new thread to run one of its methods. Either way, there are references to the object that keep it alive. Not necessarily. In a pathological but presumably legit case, whatever happens in initDelegate: might only form a weak reference to the Something object, thus the Something object would be subject to GC. Or the thread etc. could somehow fail and never call finishWithSomething: (thus leaking the Something object). The main point is that I don't think I can rely on anything keeping a reference to the newly allocated Something object. 2. The static analyzer in Xcode 3.2 doesn't like the construction, thinking that the object is leaking from the start method. I'm not sure what to do about that. Casting the result to (void) might help, to explicitly state that you don't want to use the result. (Does the static analyzer even work with GC? Stating that the object is leaking only makes sense in a ref-counted environment.) I tried casting to void but the static analyzer wasn't swayed. I suppose I can use the following pattern instead: - (void)start { Something* something = [[Something alloc] initWithDelegate:self]; [_somethings addObject:something]; [something release]; } - (void)finishWithSomething:(Something*)something { [_somethings removeObject:something]; } ... except for the overhead of keeping an array of _somethings around. Cheers, Glen Low --- pixelglow software | simply brilliant stuff www.pixelglow.com aim: pixglen twitter: pixelglow ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: using QLPreviewPanel and supporting 10.5
Replace all calls to [QLPreviewPanel sharedPreviewPanel] and other class calls to weak calls: [NSClassFromString(@QLPreviewPanel) sharedPreviewPanel]. On Sat, Oct 10, 2009 at 3:47 AM, Mitchell Livingston livings...@mac.comwrote: Hello, I want to support Quick Look in my application, but still support 10.5. I'm using the 10.6 SDK and 10.5 deployment target. Launching on 10.5 gives: Dyld Error Message: Symbol not found: _OBJC_CLASS_$_QLPreviewPanel Referenced from: /Users/robertvehse/Desktop/Transmission.app/Contents/MacOS/Transmission xpected in: /System/Library/Frameworks/Quartz.framework/Versions/A/Quartz Obviously this is from using objects only available in 10.6. I won't be using the QL classes on 10.5. Is there a way around this? Thanks, Mitch ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jjalon%40gmail.com This email sent to jja...@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
releasing an object
Hi, There is a instance variable in my AppController class named Volume. I'm doing alloc and initWithDictionary to get an instance of Volume. I have to do [selectedPTVolume retain]; when allocing to get it to work properly. When destroying this object to get a new one, I'm doing [selectedPTVolume release]; but then the retainCount is still one. If I release it twice, the GUI hangs (selectedPTVolume contains the root item of a outline view). How to release it properly? Shall I get its retainCount and then release it that many times? Thanks, Nick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: releasing an object
On 10/10/2009, at 9:31 PM, Nick Rogers wrote: Shall I get its retainCount and then release it that many times? For heavens' sake, NO! Ignore retain counts. They are not reliable evidence of anything you can use. Instead, just follow the rules: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html I'm doing alloc and initWithDictionary to get an instance of Volume. I have to do [selectedPTVolume retain]; when allocing to get it to work properly. Show your code. This sounds wrong, but without seeing the code it can't really be inferred from the description. --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
Removing an Object with A Certain Title from an NSTreeController.
Hi, I am wondering how I could delete an object depending on it's title for the CoreData 'name' property I have. To Add an Object I use this code: NSManagedObjectContext *moc = [self managedObjectContext]; JGManagedObject *theParent = [NSEntityDescription insertNewObjectForEntityForName:@projects inManagedObjectContext:moc]; [theParent setValue:nil forKey:@parent]; // This is where you add the title from the string array [theParent setValue:@myTitle forKey:@name]; [theParent setValue:[NSNumber numberWithInt:0] forKey:@position]; But I can't seem to find an equivalent function to remove An object. You See, I have an array of strings so I was hoping I could loop through it deleting the objects with the title of any of the strings. Cheers. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Snow Leopard: unsupported PointerFunctions configuration was requested
Below is the RegexKit code that causes the Snow Leopard error. After reading the doco, I don't feel very enlightened about what the unsupported configuration is, or what the solution might be. Can anyone give me a clue? + (void)load { RKAtomicMemoryBarrier(); // Extra cautious if(RKCacheLoadInitialized== 1) { return; } if(RKAtomicCompareAndSwapInt(0, 1, RKCacheLoadInitialized)) { if((cacheMapKeyCallBacks= dlsym(RTLD_DEFAULT, NSIntegerMapKeyCallBacks)) == NULL) { cacheMapKeyCallBacks= dlsym(RTLD_DEFAULT, NSIntMapKeyCallBacks); } #ifdef ENABLE_MACOSX_GARBAGE_COLLECTION id garbageCollector = objc_getClass(NSGarbageCollector); if(garbageCollector != NULL) { if([garbageCollector defaultCollector] != NULL) { id pointerFunctions = objc_getClass(NSPointerFunctions); RKCacheIntegerKeyPointerFunctions = [pointerFunctions pointerFunctionsWithOptions:NSPointerFunctionsIntegerPersonality]; RKCacheIntegerKeyPointerFunctions.acquireFunction = intPointerFunctionsAcquire; RKCacheIntegerKeyPointerFunctions.descriptionFunction = intPointerFunctionsDescription; RKCacheIntegerKeyPointerFunctions.hashFunction= intPointerFunctionsHash; RKCacheIntegerKeyPointerFunctions.isEqualFunction = intPointerFunctionsIsEqual; RKCacheIntegerKeyPointerFunctions.relinquishFunction = intPointerFunctionsRelinquish; RKCacheIntegerKeyPointerFunctions.sizeFunction= intPointerFunctionsSize; RKCacheObjectValuePointerFunctions = [pointerFunctions pointerFunctionsWithOptions:(NSPointerFunctionsZeroingWeakMemory| NSPointerFunctionsObjectPersonality)]; [[garbageCollector defaultCollector] disableCollectorForPointer:RKCacheIntegerKeyPointerFunctions]; [[garbageCollector defaultCollector] disableCollectorForPointer:RKCacheObjectValuePointerFunctions]; } } #endif // ENABLE_MACOSX_GARBAGE_COLLECTION } } From: Bill Bumgarner b...@mac.com To: Chris Idou idou...@yahoo.com Cc: cocoa-dev@lists.apple.com Sent: Thu, 24 September, 2009 12:36:04 PM Subject: Re: Snow Leopard: unsupported PointerFunctions configuration was requested On Sep 23, 2009, at 7:09 PM, Chris Idou wrote: Very early in application startup, even before main() is called, I get the following error: 2009-09-24 12:07:11.462 MyApp[5534:a0f] *** An unsupported PointerFunctions configuration was requested, probably for use by NSMapTable, NSHashTable, or NSPointerArray. The requested configuration fails due to integer personality not using opaque memory It happens twice on startup, and below are the stack traces when it happens: What does it all mean? #00x7fff84b342f7 in NSLog #10x7fff84ac84d1 in +[NSConcretePointerFunctions initializeSlice:withOptions:] #20x7fff84aea796 in -[NSConcretePointerFunctions initWithOptions:] #30x7fff84aea74d in +[NSPointerFunctions pointerFunctionsWithOptions:] #40x10004b633 in +[RKCache load] One change to the NSPointerFunction based collection classes (which support a number of things that NSArray the like do not) between Leopard and Snow Leopard was to tighten up the validation of the pointer function validation such that a handful of non-sensical configurations are detected that weren't before. I.e. RKCache is trying to create a set of pointer functions that doesn't make sense (and for whose behavior is undefined). As someone else pointed out, RK is most likely RegexKit and, thus, the source is available and can be fixed. Given the relatively common use of RK*, please provide a patch to the author so it can be fixed upstream. b.bum __ Get more done like never before with Yahoo!7 Mail. Learn more: http://au.overview.mail.yahoo.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: Removing an Object with A Certain Title from an NSTreeController.
Ok, I'll post the actual code that I am using and is giving the problem. Here it is: for(NSString *title in oldTasks) { // Get the moc and prepare a fetch request for the required entity NSManagedObjectContext *moc = [self managedObjectContext]; NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@projects inManagedObjectContext:moc]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:entityDescription]; // Create a predicate for an array of names. NSPredicate *predicate = [NSPredicate predicateWithFormat:@title IN %d, oldTasks]; [request setPredicate:predicate]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@name ascending:YES]; [request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]]; // Execute the fetch request put the results into array NSError *error = nil; NSArray *resultArray = [moc executeFetchRequest:request error:error]; if (resultArray == nil) { // Diagnostic error handling NSAlert *anAlert = [NSAlert alertWithError:error]; [anAlert runModal]; } JGManagedObject *objectToDelete = [resultArray objectAtIndex:0]; // Delete the object. [moc deleteObject:objectToDelete]; } - Josh From: Abizern abiz...@gmail.com To: Joshua Garnham joshua.garn...@yahoo.co.uk Sent: Saturday, 10 October, 2009 13:04:06 Subject: Re: Removing an Object with A Certain Title from an NSTreeController. 2009/10/10 Joshua Garnham joshua.garn...@yahoo.co.uk Hi, I am wondering how I could delete an object depending on it's title for the CoreData 'name' property I have. To Add an Object I use this code: NSManagedObjectContext *moc = [self managedObjectContext]; JGManagedObject *theParent = [NSEntityDescription insertNewObjectForEntityForName:@projects inManagedObjectContext:moc]; [theParent setValue:nil forKey:@parent]; // This is where you add the title from the string array [theParent setValue:@myTitle forKey:@name]; [theParent setValue:[NSNumber numberWithInt:0] forKey:@position]; But I can't seem to find an equivalent function to remove An object. You See, I have an array of strings so I was hoping I could loop through it deleting the objects with the title of any of the strings. Cheers. Didn't I answer this on Stack Overflow? http://stackoverflow.com/questions/1535778/, even posting a suggested method. You'd be better off posting the actual code that you've tried that you're having trouble with. You've already done so in a comment to me.-- Abizer Send instant messages to your online friends http://uk.messenger.yahoo.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: using QLPreviewPanel and supporting 10.5
How would that work with storing the instance variables? Thanks, Mitch On Saturday, October 10, 2009, at 05:30AM, Julien Jalon jja...@gmail.com wrote: ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to set checkbox state in TableView columnheader
Thank you so much for you guys' help. Jerry's sample code is extremely helpful for a newbie like me. =) I'll try this out once I'm back to my office. And let you know the outcome once I get 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
NSURLRequest
I've got an NSArray that I initialise with data from a plist stored on a remote webserver. I've been doing it like this: NSURL *url = [NSURL URLWithString:@http://www.server.com/data.plist;]; NSArray *myArray = [NSArray arrayWithContentsOfURL:url]; which has been working just fine so far. But now I'm reading through the URL Loading System docs, and wondering if I should be using all the NSURLRequest stuff instead. It's more complicated, so are there any advantages it would have over what I'm doing now? dkj ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
real verses Virtual memory
I have an app that run's a process every 20 seconds during the day... is there a way to force it to use real memory rather than virtual? because it runs every 20 seconds, and is defaulting to normal memory allocation, it has a lot of disk swapping in and out, many many times during the day, and it seems like this would negatively effect the life of a disk and performance of the whole machine? Jon. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSURLRequest
On Oct 10, 2009, at 7:36 AM, DKJ wrote: I've got an NSArray that I initialise with data from a plist stored on a remote webserver. I've been doing it like this: NSURL *url = [NSURL URLWithString:@http://www.server.com/ data.plist]; NSArray *myArray = [NSArray arrayWithContentsOfURL:url]; which has been working just fine so far. But now I'm reading through the URL Loading System docs, and wondering if I should be using all the NSURLRequest stuff instead. It's more complicated, so are there any advantages it would have over what I'm doing now? if it's working well for you, why make things more complicated than necessary. ;-) NSURLRequest allows you to set and or get extra detail out of a URL, but for stuff like loading an array with a simple URL on a remote server, what you're doing should suffice. Just make sure myArray isn't null before you do any stuff on 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: NSURLRequest
On Oct 10, 2009, at 9:36 AM, DKJ wrote: I've got an NSArray that I initialise with data from a plist stored on a remote webserver. I've been doing it like this: NSURL *url = [NSURL URLWithString:@http://www.server.com/ data.plist]; NSArray *myArray = [NSArray arrayWithContentsOfURL:url]; which has been working just fine so far. But now I'm reading through the URL Loading System docs, and wondering if I should be using all the NSURLRequest stuff instead. It's more complicated, so are there any advantages it would have over what I'm doing now? arrayWithContentsOfURL: is a blocking call. Typically, when working with data over networks, it's best to do things asynchronously. When going the async route, you're going to get much better error- handling too. The call you're currently using will simply return nil upon any error. You then wouldn't know if the URL is bad, timeout occurred, file is bad, etc. ___ Ricky A. Sharp mailto:rsh...@instantinteractive.com Instant Interactive(tm) http://www.instantinteractive.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: real verses Virtual memory
On Oct 10, 2009, at 7:37 AM, jon wrote: I have an app that run's a process every 20 seconds during the day... is there a way to force it to use real memory rather than virtual? because it runs every 20 seconds, and is defaulting to normal memory allocation, it has a lot of disk swapping in and out, many many times during the day, and it seems like this would negatively effect the life of a disk and performance of the whole machine? This is a potentially broad topic, and the correct answer probably ultimately depends on how you decide to redo that process. Is it polling for something (e.g. existence of a file or some state change?). Polling is something you really ought to try to avoid. Maybe some kind of notification would work better. Could you change that process to just reuse it's memory (instead of allocating and releasing space) between each run? If it's hitting disk each time it's run, are you unnecessarily allocating a lot of memory? You'd probably get a much more thorough better answer from the list if you elaborated on what the ultimate goal of that repeating process is. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
it loads a website, to see if there are changes to the website, it then does a lot of work, the large memory things, like the webView are just one instance, and are not deallocating... (uses just that one instance over and over again, not making new ones) so that i don't think is the problem... (or maybe even if the instance is allocated just once, does reloading a webView do any thing that makes it write to memory?) and then all the little stuff of allocating for a small variable, is adding up each time, i really don't want to make every variable global... but if that is proper technique, then i'll do that... are we saying there is no way to make a process use real memory? Jon. On Oct 10, 2009, at 9:04 AM, Michael Dautermann wrote: You'd probably get a much more thorough better answer from the list if you elaborated on what the ultimate goal of that repeating process is. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
Le 10 oct. 2009 à 17:24, jon a écrit : it loads a website, to see if there are changes to the website, it then does a lot of work, the large memory things, like the webView are just one instance, and are not deallocating... (uses just that one instance over and over again, not making new ones) so that i don't think is the problem... (or maybe even if the instance is allocated just once, does reloading a webView do any thing that makes it write to memory?) and then all the little stuff of allocating for a small variable, is adding up each time, i really don't want to make every variable global... but if that is proper technique, then i'll do that... are we saying there is no way to make a process use real memory? Jon. What is real memory ? Do you want to address the RAM directly without any virtual to physical mapping ? -- Jean-Daniel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: real verses Virtual memory
exactly, I look at Activity monitor, disk Activity and i can see a spike of disk data read/writes every 20 seconds. Jon. On Oct 10, 2009, at 9:31 AM, Jean-Daniel Dupas wrote: What is real memory ? Do you want to address the RAM directly without any virtual to physical mapping ? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: releasing an object
Hi, Thanks for the reply. In AppController.h I have an ivar: Volume *selectedPTVolume; In a method in AppController, I have the following: NSMutableDictionary *data = [partitionListDictArray objectAtIndex: [tableViewPTList selectedRow]]; selectedPTVolume = [[Volume alloc] initWithDictionary:data]; [selectedPTVolume retain];// if I comment this the GUI hangs, selectedPTVolume contains an ivar HDIR *dirRoot; which is passed as the root item of an outline view. dirRoot has an mutable array, which contains other HDIR objects as its children and so on a tree is formed. In a method, where I need to release selectedPTVolume, I have: if (selectedPTVolume) { volumeScanType = [selectedPTVolume volumeScanType];// selectedPTVolume retainCount = 2 here [selectedPTVolume release]; [selectedPTVolume release];// selectedPTVolume retainCount = 1 here selectedPTVolume = nil;// selectedPTVolume retainCount = 0 here and sometimes still shows as 1 while debugging. if (outlineViewData) [outlineViewData reloadData];/ crashes here } Releasing selectedPTVolume also releases HDIR *dirRoot. Wishes, Nick On 10-Oct-2009, at 4:06 PM, Graham Cox wrote: On 10/10/2009, at 9:31 PM, Nick Rogers wrote: Shall I get its retainCount and then release it that many times? For heavens' sake, NO! Ignore retain counts. They are not reliable evidence of anything you can use. Instead, just follow the rules: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html I'm doing alloc and initWithDictionary to get an instance of Volume. I have to do [selectedPTVolume retain]; when allocing to get it to work properly. Show your code. This sounds wrong, but without seeing the code it can't really be inferred from the description. --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: real verses Virtual memory
On Oct 10, 2009, at 8:24 AM, jon wrote: it loads a website, to see if there are changes to the website, it then does a lot of work, the large memory things, like the webView are just one instance, and are not deallocating... (uses just that one instance over and over again, not making new ones) so that i don't think is the problem... (or maybe even if the instance is allocated just once, does reloading a webView do any thing that makes it write to memory?) and then all the little stuff of allocating for a small variable, is adding up each time, i really don't want to make every variable global... but if that is proper technique, then i'll do that... are we saying there is no way to make a process use real memory? I don't know the answer to that last question off the top of my head. It sounds like you're using a repeatedly polling process with a potentially large footprint. No wonder you're seeing the disk thrashing you are. Is this a website that you have control over? Where if anything changes, you could have a notification sent to the application to do the work it needs to do (so you could avoid all that crazy polling that you're doing)? Could you lengthen the time between polls safely? 30 minutes between polls might be nicer on a machine than 20 seconds and you'd still catch your content updates. Does the remote site have lots of resources that you have to check (i.e. dynamic layout, constantly changing images, etc.), or are the files/filenames mostly static, with periodic content updates? If it's the latter, then why download the files? I believe there are ways to retrieve examine just the HTTP headers of the files (to check the content size, date/time last updated, etc.) to get an idea if the file has been changed. Other people are likely to have even better ideas than me... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Updating application info plist
Am 10.10.2009 um 01:05 Uhr schrieb Rob Keniger: To do this, surely they must be rewriting the LSUIElement key in the app's own Info.plist while the app is running, right? Or is there another way to do this? I did this once, because there was no other way to switch between UIElement and normal application mode. Obviously this was only possible if the user had write access to the application bundle. Fortunately since 10.5 there's now an working API. See Kyle's comment and this page: http://www.cocoadev.com/index.pl?TransformProcessType Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Sat, Oct 10, 2009 at 8:34 AM, jon trambl...@mac.com wrote: is there a way to force it to use real memory rather than virtual? This is, as stated, nonsensical. Your process works in its own independent virtual memory space that is mapped to physical RAM as needed by the virtual memory system. That is how it is for processes. If physical memory becomes heavily utilized (what the OS always attempts to do, unused physical RAM is wasted RAM) then you could incur swapping if no non-dirty pages exist but it isn't clear that is what you are seeing based on the information you posted and the terminology you have been using. exactly, I look at Activity monitor, disk Activity and i can see a spike of disk data read/writes every 20 seconds. Use something like fs_usage or Instruments to understand what files, etc. you process is using to understand what the IO is possibly related to. If you are using WebKit, etc. I bet the disk IO you are seeing is related to the the caching WebKit, NSURLRequest, etc. can do under ~/Library/Caches. You can turn off aspects of this if you don't want any on disk caching of fetched pages, etc. to take place. If you have code doing IO to files of your own and it is highly unlikely you aren't going to be access those files again for a long while then you could also look at marking your access to those files as not needing file caching. It is very hard to assist you with the limited information about how your process works, what it does, what API it uses to do things, etc. ...and exactly what problem you perceive to exist. Anyway you seem to be confused on how memory is managed in an application given some of your statements. You may want to find some online resources on modern virtual memory systems and theory. -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: using QLPreviewPanel and supporting 10.5
On Oct 10, 2009, at 5:40 AM, Mitchell Livingston livings...@mac.com wrote: How would that work with storing the instance variables? 1) Why are you concerned with QLPreviewPanel's instance variables? 2) The API is different between 10.5 and 10.6; you can't just drop in NSClassFromString and continue on as normal. --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: releasing an object
Am 10.10.2009 um 17:43 Uhr schrieb Nick Rogers: selectedPTVolume = [[Volume alloc] initWithDictionary:data]; [selectedPTVolume retain]; Read the memory management rules again. By calling alloc the retain count of the created object is one. There is no need to send it an additional retain message. if I comment this the GUI hangs, Then you've got another problem somewhere else. [selectedPTVolume release]; selectedPTVolume = nil; if (outlineViewData) [outlineViewData reloadData];/ crashes here I guess it crashes because you just pulled the outline view's model data from under it's feet. How is the outline view connected to the model? Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: releasing an object
On Sat, Oct 10, 2009 at 8:43 AM, Nick Rogers roger...@mac.com wrote: Hi, Thanks for the reply. In AppController.h I have an ivar: Volume *selectedPTVolume; In a method in AppController, I have the following: NSMutableDictionary *data = [partitionListDictArray objectAtIndex:[tableViewPTList selectedRow]]; The above is an object this code doesn't own but has gain access to use. selectedPTVolume = [[Volume alloc] initWithDictionary:data]; The above is a new object that this code owns and hence has the responsibility to relinquish ownership of before this code loses its reference to the object. I presume that -[Volume initWithDictionary] is coded to take ownership (retain) of data, if not it needs to. Then in -[Volume dealloc] it needs to release ownership. [selectedPTVolume retain];// if I comment this the GUI hangs, selectedPTVolume contains an ivar HDIR *dirRoot; which is passed as the root item of an outline view. dirRoot has an mutable array, which contains other HDIR objects as its children and so on a tree is formed. You already have ownership of the object pointed at by selectedPTVolume, no need to retain it again (aka no need to claim ownership again). I rewrote the following... In a method, where I need to release selectedPTVolume, I have: if (selectedPTVolume) { volumeScanType = [selectedPTVolume volumeScanType];// selectedPTVolume retainCount = 2 here [selectedPTVolume release]; [selectedPTVolume release];// selectedPTVolume retainCount = 1 here selectedPTVolume = nil;// selectedPTVolume retainCount = 0 here and sometimes still shows as 1 while debugging. if (outlineViewData) [outlineViewData reloadData];/ crashes here } ...as with the likely possibility of removing the if (selectedPTVolume != nil) depending on what zero means for volumeScanType... if (selectedPTVolume != nil) { volumeScanType = [selectedPTVolume volumeScanType]; [outlineViewData reloadData] } Anyway the amount of code you have posted leave to much out to understand all that may be wrong with your memory management. Also you haven't posted much information about the crash to help us understand the location of it. Look up information on how to use NSZombie or if you are on Snow Leopard use the Zombie feature of Instruments to track down memory management issues like this. -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: releasing an object
Ooops meant... if (selectedPTVolume != nil) { volumeScanType = [selectedPTVolume volumeScanType]; [selectedPTVolume release]; [outlineViewData reloadData] } On Sat, Oct 10, 2009 at 9:21 AM, Shawn Erickson shaw...@gmail.com wrote: if (selectedPTVolume != nil) { volumeScanType = [selectedPTVolume volumeScanType]; [outlineViewData reloadData] } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: using QLPreviewPanel and supporting 10.5
On Oct 10, 2009, at 9:18 AM, Kyle Sluder wrote: 2) The API is different between 10.5 and 10.6; you can't just drop in NSClassFromString and continue on as normal. It works fine for me. I believe this comment only applies if you were foolish enough to link against the private framework in 10.5 :). 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: using QLPreviewPanel and supporting 10.5
On Saturday, October 10, 2009, at 12:18PM, Kyle Sluder kyle.slu...@gmail.com wrote: On Oct 10, 2009, at 5:40 AM, Mitchell Livingston livings...@mac.com wrote: How would that work with storing the instance variables? 1) Why are you concerned with QLPreviewPanel's instance variables? It won't run on 10.5 with this variable, and NSClassFromString won't work for that. I am storing a variable as done in Apple's example program QuickLookDownloader. 2) The API is different between 10.5 and 10.6; you can't just drop in NSClassFromString and continue on as normal. I do not want to use quick look on 10.5, only 10.6. --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: real verses Virtual memory
no, no control over the website, but on webView i turned off all the java script and flash and stuff, so that helps with the speed, not with it using virtual memory every 20 seconds, and it does need to be 20 seconds. Jon. On Oct 10, 2009, at 9:44 AM, Michael Dautermann wrote: Is this a website that you have control over? Where if anything changes ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On 10 Oct 2009, at 17:44, jon wrote: no, no control over the website, but on webView i turned off all the java script and flash and stuff, so that helps with the speed, not with it using virtual memory every 20 seconds, and it does need to be 20 seconds. So if you change your process to sleep 20 seconds and then repeat - instead of exiting and getting restarted - how does that change the disk activity? Cheers, 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: real verses Virtual memory
Ok, let me re-word it then, is there a way i can keep a process from using Disk writes as a form of it's own memory use? I already know that it is a memory thing since the program never uses the disk to write out any files. (during the process)... nor use the disk in any other way, except for the memory being virtual. there are no files being accessed, only the webView that is it's source of data it's only source. it works on that data, finishes, and does nothing for 20 more seconds. (a trigger can happen, but even if there was no trigger, the disk writes are there) Jon. On Oct 10, 2009, at 10:08 AM, Shawn Erickson wrote: This is, as stated, nonsensical. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: releasing an object
On Sat, Oct 10, 2009 at 12:21 PM, Shawn Erickson shaw...@gmail.com wrote: Anyway the amount of code you have posted leave to much out to understand all that may be wrong with your memory management. The code does show one common anti-pattern - calls to -retain and -release that should be hidden in an accessor method. Each instance variable that refers to an object should have a setVariable: setter method that properly releases the old value and retains the new value. Encapsulating the memory-management code makes it far easier to debug - scattering it throughout your code leads to torn hair and madness. It's also good OOP; when you find yourself repeating some code around access to an instance variable, it's often a good idea to factor the repetitious code into accessor methods. That makes the repeated code easier to manage, and leaves less clutter in the calling code. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: using QLPreviewPanel and supporting 10.5
On Oct 10, 2009, at 9:31 AM, Adam R. Maxwell wrote: On Oct 10, 2009, at 9:18 AM, Kyle Sluder wrote: 2) The API is different between 10.5 and 10.6; you can't just drop in NSClassFromString and continue on as normal. It works fine for me. I believe this comment only applies if you were foolish enough to link against the private framework in 10.5 :). Ugh...I'm wrong. NSClassFromString does return a class on 10.5, even though I don't load the private QL UI framework. How unfortunate. 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: real verses Virtual memory
On Sat, Oct 10, 2009 at 12:53 PM, jon trambl...@mac.com wrote: there are no files being accessed, only the webView WebView can access files on its own. Have you disabled cacheing? sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Removing an Object with A Certain Title from an NSTreeController.
On Oct 10, 2009, at 05:28, Joshua Garnham wrote: NSPredicate *predicate = [NSPredicate predicateWithFormat:@title IN %d, oldTasks]; %d? oldTasks is a NSArray. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
Le 10 oct. 2009 à 18:53, jon a écrit : Ok, let me re-word it then, is there a way i can keep a process from using Disk writes as a form of it's own memory use? I already know that it is a memory thing since the program never uses the disk to write out any files. (during the process)... nor use the disk in any other way, except for the memory being virtual. You don't know, you assume, and everybody here know that assumptions are evil. Instead of basing your work on false assumptions, use the proper tools to determine what is the issue, as Shawn suggest. there are no files being accessed, only the webView that is it's source of data it's only source. it works on that data, finishes, and does nothing for 20 more seconds. (a trigger can happen, but even if there was no trigger, the disk writes are there) Jon. On Oct 10, 2009, at 10:08 AM, Shawn Erickson wrote: This is, as stated, nonsensical. -- Jean-Daniel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: real verses Virtual memory
On Oct 10, 2009, at 9:53 AM, jon wrote: Ok, let me re-word it then, is there a way i can keep a process from using Disk writes as a form of it's own memory use? I already know that it is a memory thing since the program never uses the disk to write out any files. (during the process)... nor use the disk in any other way, except for the memory being virtual. there are no files being accessed, only the webView that is it's source of data it's only source. it works on that data, finishes, and does nothing for 20 more seconds. (a trigger can happen, but even if there was no trigger, the disk writes are there) If there are reads and writes being caused by such a process, it could be because of several reasons: 1) as the app is launched, the executables (app and frameworks) and data files will be read from the filesystem (but not necessarily off disk) 2) if there is a persistent cache -- a web cache, perhaps? -- it may be updated, causing I/O 3a) if the system is under memory pressure, allocations may cause other applications to page out memory 3b) if memory pressure there are other active applications, your app may page out / in memory 4) your code may be indirectly triggering other disk I/O events via the APIs it calls (1) is normal and there isn't anything you can do about it (other than not relaunch your app all the time -- maybe a daemon instead?). However, on a system that isn't under memory pressure, all of the executable gunk will be in cache -- in memory -- after the first launch and subsequent launches won't hit the disk. (2) is, again, normal and the default behavior. Depending on your needs, you might want to turn off the caches used by the URL loading subsystem. And, if possible, use a HEAD request to determine if the remote content has changed before pulling it all down with a GET or POST. (3a/b) Not much you can do here beyond minimizing your app's memory use. (4) Use Instrument's file I/O instruments to determine what is triggering I/O. Then figure out if you can eliminate it. In other words: No, there isn't a way for your app to use real memory. Or, to rephrase, there isn't a way -- at least, not a polite way -- to guarantee that your app is going to have a certain amount of physical RAM allocated to it. Since there is no way for your app to know what demands may be made by other applications, there is no way for you to reserve memory resources without potentially grossly negatively impacting the performance of some other application. The system goes to great lengths to dole out resources efficiently and it is best to let it do its job as best it can. 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: Binding to currently selected object in a list?
Ken, Thank you for the well-expressed response. I understand both options as you've explained them and will try them both to see which ones I end up having a better feel for. I may have to go for the second example as I think that it will get executed in a more deterministic order earlier - which is something that I will need to be reasonably assured of as the 'selectedWidget' value is one that is used by other KVO-triggered actions and that therefore lack of guaranteed order of setting can end up causing me problems. On Friday, October 09, 2009, at 11:57PM, Ken Thomases k...@codeweavers.com wrote: On Oct 9, 2009, at 5:08 PM, A B wrote: Is there a way to bind an ivar to the currently selected object of a list which is being represented in an NSTableView via bindings? Unfortunately there does not seem to be a selectedObject key (though there is one for selectedObjects). Binding to the controller's selection doesn't really work as I'd expect and even if it did, I'd only be getting back a proxy object - which negates the purpose for which I want to use it, which is to call methods on the object. I had put in a hack which observes changes in selection, gets the selectedObjects list, checks for a count 0, grabs the first and stuffs it into the ivar, etc. but not only does that feel really hackish, but doesn't always work. This would seem to be a pretty simple thing to want to do (i.e. present a list of objects, do things to/with the currently selected object) but I'm at somewhat of a loss to understand what I'm doing wrong. There's something just like this for NSPopUpButton. You bind its 'content' (and possibly 'contentObjects') binding to an indexed collection property of the controller. Then you bind its 'selectedObject' binding to a to-one property of the controller. When the pop-up is first set up, it displays the selected object as originally set on the controller's to-one property. Then, as the user selects items from the pop-up, the newly selected object is passed to the setter for that to-one property. Strangely, there's nothing quite like that for NSArrayController. I think the best you can do is to bind the array controller's selectionIndexes binding to an attribute of your coordinating controller. (For illustration purposes, I'll call this attribute property selectedWidgetIndexes.) Then that coordinating controller can have a selectedWidget to-one property which is set up to reflect the object which is selected in the array controller. One way is to make the selectedWidget property computed-on-the-fly based on the selection indexes: +(NSSet*)keyPathsForValuesAffectingSelectedWidget { return [NSSet setWithObject:@selectedWidgetIndexes]; } -(Widget*)selectedWidget { if (![self.selectedWidgetIndexes count]) return nil; return [self.widgets objectAtIndex:[self.selectedWidgetIndexes firstIndex]]; } In this scenario, you don't actually have an ivar backing the selectedWidget property. It's completely based off of the selectedWidgetIndexes property and the widgets to-many property. (The widgets property is assumed to be the indexed collection property that the array controller is representing. The selectedWidgetIndexes property can be a typical @synthesized copy property.) Another approach is to implement the setter for selectedWidgetIndexes and use that to update the selectedWidget property directly. In this case, selectedWidget isn't computed on the fly, but is actually held (cached) in an ivar: -(void)setSelectedWidgetIndexes(NSIndexSet*)newSelectedWidgetIndexes { if (![selectedWidgetIndexes isEqual:newSelectedWidgetIndexes]) { [selectedWidgetIndexes release]; selectedWidgetIndexes = [newSelectedWidgetIndexes copy]; if ([selectedWidgetIndexes count]) self.selectedWidget = [self.widgets objectAtIndex: [selectedWidgetIndexes firstIndex]]; else self.selectedWidget = nil; } } You don't need +keyPathsForValuesAffectingSelectedWidget since you're going through the setter for the selectedWidget property. The selectedWidget property can be a typical @synthesized retain property. By the way, notice that all of this discussion is in terms of the array controller and the coordinating controller. No mention of the table view because it's not directly relevant. The MVC design pattern in action. ;) 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: Old-style (carbon?) blue generic view shows up under Logic
On 10 Oct 2009, at 01:14, tahome izwah wrote: Yes, actually it does as of version 8.0.5 Hooray, where's the champagne! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
ok thanks, i was pretty sure it is normal behavior i am only asking if there is away around that particular behavior, and your answer was what i figured might be the case... so i am a little clearer, it is normal for apps to use disk IO in the way we are describing, even if there is no real memory pressure, correct? (a form of it's virtualization?) I am looking at cacheing right now to see if there could be anything better done in that area. in IB , i disabled everything for the webView (java, java script, ect...) the program is not relaunching every 20 secs, it is reloading a webView every 20 secs. and then doing a bunch of work on that data, there is no real calls to anything API except of course the webView reload itself, which i assume is what is causing normal memory use, it definitely is causing a CPU use spike, and there is no user interface to update, except again, for the webView object instance, and it is hidden...there is only number crunching after the webview load... including using memory to store variables... i never thought there was anything wrong, only maybe a way to keep the process from using disk swaps as it's source of memory. Jon. On Oct 10, 2009, at 11:03 AM, Bill Bumgarner wrote: In other words: No, there isn't a way for your app to use real memory. Or, to rephrase ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
jon write: there are no files being accessed, only the webView that is it's source of data it's only source. it works on that data, finishes, and does nothing for 20 more seconds. (a trigger can happen, but even if there was no trigger, the disk writes are there) Consider using something other than a WebView. Maybe libcurl is more in line with what you're trying to accomplish. http://developer.apple.com/mac/library/documentation/Darwin/Reference/ ManPages/man3/libcurl.3.html -- 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: real verses Virtual memory
I could use an explanation then, if you go into activity monitor you will see a heading of real memory and virtual memory. specifically for all the current Processes.. what does Apple mean by real memory?in that, I might see why you asked the question?and why you think that i am using it incorrectly for my particular process... i can see Apple label my process as using real memory? and virtual memory what does apple mean? Jon. On Oct 10, 2009, at 9:31 AM, Jean-Daniel Dupas wrote: What is real memory ? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
Jon, please use Instruments.app (and/or various related tools; Activity Monitor.app, Shark.app, sample, top, fs_usage, vm_stat, vmmap/vmmap64, etc.) to understand what your process it doing both in terms of IO, memory utilization/allocations and even CPU time. Using those tools you can understand what your application is doing and make informed decisions on what, if anything, you need to change/optimize. You so far haven't listed any actual data about what is going on so we can only speculate and you yourself appear to be making guesses and assumptions on limited information/knowledge. Save yourself time (and us) by using the available tools to analyze things. -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: real verses Virtual memory
oh yes, i plan on optimization, but this was not the original question, not one of how should i optimize, it was one of can i keep my process from using Disk I0, as a means of it's memory use?. to save on wear and tear of the disk for this particular process. On Oct 10, 2009, at 11:49 AM, Shawn Erickson wrote: Jon, please use Instruments.app ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Sat, Oct 10, 2009 at 10:55 AM, jon trambl...@mac.com wrote: oh yes, i plan on optimization, but this was not the original question, not one of how should i optimize, it was one of can i keep my process from using Disk I0, as a means of it's memory use?. to save on wear and tear of the disk for this particular process. Again it isn't clear if swapping is what is actually happing based on what you have so far posted to this list. It may be clear to you but the information provided and terminology you have used leaves me (and others) wondering what it really taking place. Just trying to understand what is going on so we can give you correct guidance. -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: real verses Virtual memory
On Sat, Oct 10, 2009 at 10:48 AM, jon trambl...@mac.com wrote: I could use an explanation then, if you go into activity monitor you will see a heading of real memory and virtual memory. specifically for all the current Processes.. what does Apple mean by real memory?in that, I might see why you asked the question?and why you think that i am using it incorrectly for my particular process... i can see Apple label my process ashas bee using real memory? and virtual memory what does apple mean? http://support.apple.com/kb/HT1342 http://support.apple.com/kb/TA20517 In a nutshell.. Real Memory is essentially how much physical RAM is currently being used by the process. It doesn't count swapped out pages. Virtual Memory is how much of the processes virtual memory space has been consumed by allocations. Note just because an allocation was made in the virtual memory space doesn't mean that any physical RAM or on disk swap has been yet used. In fact pages related to the allocation may never be touched by the process, hence never cause a page fault requiring the mapping of physical/disk page. -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: real verses Virtual memory
Hi Bill, in this theme of normal behavior, maybe this would make what i'm asking more clear. in an exercise of thought, if you wrote an app, and the only thing it did was put up a window permanently (for the run of it's process life), with a single webview in it, and hardwired a load of any particular website you wished that had any substance to load in that webview... and then put in a trigger to simply reload that same website every 20 seconds... and that was it, no number crunching, or extra processes, or UI. if you had to guess, if you looked in activity monitor, do you think this thought experiment would use disk IO every 20 seconds? thanks, Jon. On Oct 10, 2009, at 11:03 AM, Bill Bumgarner wrote: 2) if there is a persistent cache -- a web cache, perhaps? -- it may be updated, causing I/O ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
ok, I have Activity monitor open, particularly to the disk activity tab, and the IO checked, as i said before, and i can see Disk writes every 20 secs.is there a clearer way to demonstrate that Disk IO is happening? am i fulling my self by looking at this tool? Jon. On Oct 10, 2009, at 12:07 PM, Shawn Erickson wrote: Again it isn't clear if swapping is what is actually happing based on what you have so far posted to this list. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Old-style (carbon?) blue generic view shows up under Logic
On 10 Oct 2009, at 11:20, Stephen Blinkhorn wrote: On 10 Oct 2009, at 01:14, tahome izwah wrote: Yes, actually it does as of version 8.0.5 Hooray, where's the champagne! sorry, wrong list. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
If it was using a web cache, then yes. A webview uses webkit. Which uses URL caches and web caches. There are many things going on here. Way more than just one little view. It could simply be checking for the data in a cache, for example. You don't know because its not your code. I just don't think you can do what you're asking. On Oct 10, 2009, at 1:08 PM, jon wrote: Hi Bill, in this theme of normal behavior, maybe this would make what i'm asking more clear. in an exercise of thought, if you wrote an app, and the only thing it did was put up a window permanently (for the run of it's process life), with a single webview in it, and hardwired a load of any particular website you wished that had any substance to load in that webview... and then put in a trigger to simply reload that same website every 20 seconds... and that was it, no number crunching, or extra processes, or UI. if you had to guess, if you looked in activity monitor, do you think this thought experiment would use disk IO every 20 seconds? thanks, Jon. On Oct 10, 2009, at 11:03 AM, Bill Bumgarner wrote: 2) if there is a persistent cache -- a web cache, perhaps? -- it may be updated, causing I/O ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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. To educate a person in mind and not in morals is to educate a menace to society. -- Theodore Roosevelt ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
No, Activity Monitor as not a developer tool. As I said (and other too), uses proper tools. Instrument, may be a good starting point. Le 10 oct. 2009 à 20:12, jon a écrit : ok, I have Activity monitor open, particularly to the disk activity tab, and the IO checked, as i said before, and i can see Disk writes every 20 secs.is there a clearer way to demonstrate that Disk IO is happening? am i fulling my self by looking at this tool? Jon. On Oct 10, 2009, at 12:07 PM, Shawn Erickson wrote: Again it isn't clear if swapping is what is actually happing based on what you have so far posted to this list. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 -- Jean-Daniel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: real verses Virtual memory
ahh, ok thanks, that helps a lot. Jon. On Oct 10, 2009, at 12:30 PM, Alex Kac wrote: If it was using a web cache, then yes. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Sat, Oct 10, 2009 at 11:08 AM, jon trambl...@mac.com wrote: Hi Bill, in this theme of normal behavior, maybe this would make what i'm asking more clear. in an exercise of thought, if you wrote an app, and the only thing it did was put up a window permanently (for the run of it's process life), with a single webview in it, and hardwired a load of any particular website you wished that had any substance to load in that webview... and then put in a trigger to simply reload that same website every 20 seconds... and that was it, no number crunching, or extra processes, or UI. if you had to guess, if you looked in activity monitor, do you think this thought experiment would use disk IO every 20 seconds? I built a simple application with a single window, a WebView, a text field for URL, and a button to trigger a reload... all defined in the main xib. No other code written. I turned off support for plugins, java and javascript for the fun of it. Then I monitored that application and found the following every time I loaded a page. MacPro:~ shawnce$ sudo fs_usage -w -f filesys 26906 | tee fstrace.txt 11:24:03.163 open F=7(R_) /Users/shawnce/Library/Cookies/Cookies.plist 0.71 MyBasicWebView 11:24:03.163 fstat F=7 0.05 MyBasicWebView 11:24:03.165 read F=7B=0xe55d1 0.000544 MyBasicWebView 11:24:03.165 close F=7 0.16 MyBasicWebView 11:24:03.272 ioctl F=7 CMD=0x8004667e 0.03 MyBasicWebView 11:24:03.272 ioctl F=10 CMD=0xc0206911 0.04 MyBasicWebView 11:24:03.272 fcntl F=7 GETFL 0.03 MyBasicWebView 11:24:03.322 ioctl F=10 CMD=0xc0206911 0.05 MyBasicWebView 11:24:03.322 ioctl F=10 CMD=0xc0206911 0.02 MyBasicWebView 11:24:03.322 ioctl F=10 CMD=0xc0206911 0.02 MyBasicWebView 11:24:03.322 ioctl F=10 CMD=0xc0206911 0.02 MyBasicWebView 11:24:03.322 ioctl F=10 CMD=0xc0206911 0.02 MyBasicWebView 11:24:03.645 fcntl F=3 SETLK 0.07 MyBasicWebView 11:24:03.645 fcntl F=3 SETLK 0.02 MyBasicWebView 11:24:03.645 fcntl F=3 SETLK 0.03 MyBasicWebView 11:24:03.645 access [ 2] (___F) /Users/shawnce/Library/Caches/com.yourcompany.MyBasicWebView/Cache.db-journal 0.82 MyBasicWebView long list of stuff snipped... If I watch this application using the File Activity template of Instruments I get a lot of nice information. For example I can see the stack track related to a disk write among many other things. 13 CFNetwork CFURLCacheWorkerThread(void*) 12 CoreFoundation CFRunLoopRunInMode 11 CoreFoundation CFRunLoopRunSpecific 10 CFNetwork CFURLCacheTimerCallback(__CFRunLoopTimer*, void*) 9 CFNetwork ProcessCacheTasks(__CFURLCache*) 8 CFNetwork __CFURLCache::ExecuteSQLInsert(_CFCachedURLResponse const*, __CFString const*, _CFURLRequest const*) 7 CFNetwork __CFURLCache::StepSQLStatementToCompletion(sqlite3_stmt*, long) 6 libsqlite3.0.dylib sqlite3_step 5 libsqlite3.0.dylib sqlite3Step 4 libsqlite3.0.dylib sqlite3VdbeExec 3 libsqlite3.0.dylib sqlite3BtreeInsert 2 libsqlite3.0.dylib sqlite3PagerWrite 1 libsqlite3.0.dylib pager_write 0 libSystem.B.dylib pwrite$UNIX2003 Which is exactly what I expected (and others) given the fact that by default the URL loading sub-system used on Mac OS X will attempt to cache remote resources. This is all done in support of the standard HTTP resource caching scheme. For example review... http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Concepts/CachePolicies.html#//apple_ref/doc/uid/20001843-BAJEAIEE http://developer.apple.com/mac/library/documentation/Cocoa/Reference/WebKit/Classes/WebPreferences_Class/Reference/Reference.html#//apple_ref/occ/instm/WebPreferences/setCacheModel : -Shawn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Re: real verses Virtual memory
thanks for doing that, it helped, cacheing hmmm... i don't think there is away around this, i need a fresh load to see if the data has changed each time at the website.It appears that disk IO is here to stay. Jon. On Oct 10, 2009, at 12:57 PM, Shawn Erickson wrote: Which is exactly what I expected (and others) given the fact that by default the URL loading sub-system used on Mac OS X will attempt to cache remote resources. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
oh wait, that means i can turn off cacheing, I at least can see if that will help, I'll go read up on how to turn off cacheing.. Jon. On Oct 10, 2009, at 12:57 PM, Shawn Erickson wrote: Which is exactly what I expected (and others) given the fact that by default the URL loading sub-system used on Mac OS X will attempt to cache remote resources. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Sat, Oct 10, 2009 at 12:04 PM, jon trambl...@mac.com wrote: thanks for doing that, it helped, cacheing hmmm... i don't think there is away around this, i need a fresh load to see if the data has changed each time at the website.It appears that disk IO is here to stay. Stepping back from this issue... What is this process trying to do? (not how it is currently doing it but why does it need to load a page? what does it do with that loaded page? etc.) Basically using something like a WebView may be a little to high-level of a object/tool to use for what you really need to do. -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: real verses Virtual memory
I take the info off the website, data if you like... data that changes or could change at any given time, every second even and process it, and trigger an event if the data is to my liking. how would i get the data off a website, formated in the only way i know it? which is how it is displayed on the website, html formated, (i don't control the website). is there a better process? Jon. On Oct 10, 2009, at 1:06 PM, Shawn Erickson wrote: (not how it is currently doing it but why does it need to load a page? what does it do with that loaded page? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Sat, Oct 10, 2009 at 12:12 PM, jon trambl...@mac.com wrote: I take the info off the website, data if you like... data that changes or could change at any given time, every second even and process it, and trigger an event if the data is to my liking. how would i get the data off a website, formated in the only way i know it? which is how it is displayed on the website, html formated, (i don't control the website). is there a better process? WebView is primarily about displaying a webpage. It sounds like you aren't using it for that. So likely no need to pay for the extra overhead, etc. It sounds like you need to get at the HTTP content itself and pull data out of that, right? If all you need is the HTTP content you can drop down to things like Foundation's URL Loading System [1], maybe drop down lower to CFNetwork [2], or use something like libcurl (as Greg suggested, possibly the better suggestion depending on your exact needs). Also make sure to understand the standard HTTP caching so you can avoid unneeded data loads (note Mac OS X provided HTTP API honor this scheme, so you likely don't have to do any work of your own). http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html -Shawn [1] http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html [2] http://developer.apple.com/mac/library/samplecode/CFNetworkHTTPDownload/index.html [3] http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man3/libcurl.3.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
I meant to ask if you are accessing the HTTP or using WebKit's DOM API to get at the pages content? Basically how are using using WebView to access the data you need. -Shawn On Sat, Oct 10, 2009 at 12:25 PM, Shawn Erickson shaw...@gmail.com wrote: On Sat, Oct 10, 2009 at 12:12 PM, jon trambl...@mac.com wrote: I take the info off the website, data if you like... data that changes or could change at any given time, every second even and process it, and trigger an event if the data is to my liking. how would i get the data off a website, formated in the only way i know it? which is how it is displayed on the website, html formated, (i don't control the website). is there a better process? WebView is primarily about displaying a webpage. It sounds like you aren't using it for that. So likely no need to pay for the extra overhead, etc. It sounds like you need to get at the HTTP content itself and pull data out of that, right? If all you need is the HTTP content you can drop down to things like Foundation's URL Loading System [1], maybe drop down lower to CFNetwork [2], or use something like libcurl (as Greg suggested, possibly the better suggestion depending on your exact needs). Also make sure to understand the standard HTTP caching so you can avoid unneeded data loads (note Mac OS X provided HTTP API honor this scheme, so you likely don't have to do any work of your own). http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html -Shawn [1] http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html [2] http://developer.apple.com/mac/library/samplecode/CFNetworkHTTPDownload/index.html [3] http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man3/libcurl.3.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
A couple of points… [1] Yes, it is possible to allocate wired memory that is forced to stay in physical RAM and never be paged to disk. But this ability is pretty much used only by low-level software like kernel extensions, device drivers, and real-time audio processors. These are things that either interact with memory below the level of the VM system, or that will fail if a memory access has to wait for disk I/O. It's generally pretty bad for other software to use wired memory, because it makes that RAM unavailable for any other process on the system. In effect, it is slowing down every other process, to benefit itself. You really don't want to do this. The OS kernel is very highly tuned to balance the needs of all running processes. [2] File-system activity is not the same thing as disk I/O. There is a lot of caching going on (in fact caching and virtual memory are just two aspects of the same subsystem). Multiple reads of the same file are not going to hit the disk at all because the file should still be in cache. Writes will hit the disk, but often not immediately. [3] Unless the OS is really low on available RAM, or you're allocating huge amounts of memory, your app is not going to cause VM paging. In fact, if your app does stuff every 20 seconds, it's not going to get paged out to disk. Instead, other processes will be paged out to make room, if necessary. The kernel tries to keep the most recently used memory in RAM. [4] The disk I/O you're seeing is almost certainly due to CFNetwork's caching and cookie mechanisms. You probably don't want to turn off cookies if the site you're accessing uses any type of login or persistent state. In any case, the cookies are mostly just going to be read from disk, not incurring I/O. Turning off caching will increase the amount of network activity and server-side time, because the server will have to send the full page to you every time even if it hasn't changed. I don't recommend that. Many large websites will ban your IP address if they find you repetitively fetching pages like this. [5] You haven't described any functionality that requires using a WebView. All you need, I think, is NSURLConnection to fetch the contents of the page. If you need to parse the HTML, you can use NSXMLDocument for that — it supports a query format called XPath that makes it very easy to find specific data in an HTML page. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Document architecture - stop it from opening untitled documents?
Thanks Ken. On Sat, Oct 10, 2009 at 12:05 AM, Ken Thomases k...@codeweavers.com wrote: On Oct 9, 2009, at 8:57 PM, aaron smith wrote: On Fri, Oct 9, 2009 at 6:52 PM, aaron smith beingthexemplaryli...@gmail.com wrote: Hey All, quick question. I'm trying to figure out how to stop untitled documents from opening when the application first runs. I've been looking on google, and tried some different combinations of method overrides on NSDocumentController. I figured out how to stop the untitled doc from opening, by overriding - (id)makeUntitledDocumentOfType:(NSString *)typeName error:(NSError **)outError, but the problem is that it's required to give it an NSError, which is fine. But the the application automatically opens up an alert error. if anyone has a quick pointer in the right direction that would be awesome. Thanks. ok. nevermind. I got it. You have to implement a method from NSApplicationDelegate: - (BOOL) applicationOpenUntitledFile:(NSApplication *) theApplication { return true; } Better to implement: - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { return FALSE; } That expresses that the application shouldn't open an untitled document, rather than it thinking it should and you faking success. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: real verses Virtual memory
Please take this off list. Thanks, Tom Wetmore On Oct 10, 2009, at 3:28 PM, Shawn Erickson wrote: I meant to ask if you are accessing the HTTP or using WebKit's DOM API to get at the pages content? Basically how are using using WebView to access the data you need. -Shawn On Sat, Oct 10, 2009 at 12:25 PM, Shawn Erickson shaw...@gmail.com wrote: ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
ok, i'll do research on these.. Jon. On Oct 10, 2009, at 1:25 PM, Shawn Erickson wrote: It sounds like you need to get at the HTTP content itself and pull data out of that, right? If all you need is the HTTP content you can drop down to things like Foundation's URL Loading System [1], maybe drop down lower to CFNetwork [2], or use something like libcurl (as Greg suggested, possibly the better suggestion depending on your exact needs). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
using DOM, Jon. On Oct 10, 2009, at 1:28 PM, Shawn Erickson wrote: using WebKit's DOM API to get at the pages content? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to allocate and delegate; or how to keep GC and the static analyzer happy
On Oct 10, 2009, at 2:25 AM, Glen Low wrote: Not necessarily. In a pathological but presumably legit case, whatever happens in initDelegate: might only form a weak reference to the Something object, thus the Something object would be subject to GC. That's true, although unlikely. In that case you could create an instance variable of the owning object, to point to the Something object. Or the thread etc. could somehow fail and never call finishWithSomething: (thus leaking the Something object). I don't think you mean leak there; if the thread exits, the Something object would just be collected. The Something method that runs on the thread should have an @try block around it, so that if anything goes wrong it can clean up (including calling back into your main object) before it finishes. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
oh... that is good to know... hmm, well it looks like i need to go lower in the mechanism, stuff i don't know anything about, so i'll do research on the best way to get the info off the website at a lower level. Jon. On Oct 10, 2009, at 1:33 PM, Jens Alfke wrote: Many large websites will ban your IP address if they find you repetitively fetching pages like this. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to ease the burden on the Garbage Collector?
On Oct 10, 2009, at 1:14 AM, Gabriel Zachmann wrote: So, is 20% CPU time for the GC thread normal? That's a lot more than I'd expect based on what you're doing. Either you've got code you haven't shown us that's allocating a ton of objects during the animation, or some system framework (CoreAnimation, presumably) is allocating a lot of collectable objects. I've used CA in some GC'd apps and haven't seen noticeable collection activity, but maybe I haven't used the same APIs as you. What you need, I think, is to find out how to use Instruments or Shark to track only the allocation of collectable objects. Then you can see where that's occurring. I don't know how to do that, myself, but I'm sure someone here does. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Oct 10, 2009, at 12:35 PM, Thomas Wetmore wrote: Please take this off list. Why? This seems like a relevant discussion for cocoa-dev. Just because you're not interested in it doesn't make it off-topic. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
wait, if CFNetwork is doing the caching, I would need to go lower to avoid it? what would i use to get html or xml type of info off the website, without giving the website pause for what i am doing? (or best guess on what a website might consider bad behavior) Jon. On Oct 10, 2009, at 1:33 PM, Jens Alfke wrote: [4] The disk I/O you're seeing is almost certainly due to CFNetwork's caching and cookie mechanisms. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
oh i see (too late for that last post of mine) that you are recommending NSURLConnection... I'll look into that... You are right, i am probably not needing WebView, i only am using it, because that is what i founddrives me crazy the documentation... it is there, but you have to know what to look for before you ever go down the correct tangent. Jon. On Oct 10, 2009, at 1:33 PM, Jens Alfke wrote: [5] You haven't described any functionality that requires using a WebView. All you need, I think, is NSURLConnection to fetch ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
capturing special keys when focused in an NSTextField
Quick question - I have a window that I run as a sheet, which contains an NSTextField to enter a message. I have the window setup to close the sheet when the Escape key is pressed, however, when the text field is focused I can't figure out how to respond to these types of special keys. I've tried subclassing NSTexField and overriding keyDown:, but it doesn't get called. And I've tried setting the text field's next responder to be the controller object for the view, etc. No go. Can someone point me in the right direction? Thanks much. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Sat, Oct 10, 2009 at 2:56 PM, jon trambl...@mac.com wrote: wait, if CFNetwork is doing the caching, I would need to go lower to avoid it? If I load CNN.com right now, I fetch the HTML page, plus at least 127 image, CCS, and javascript files. So if you use something more low level, like CFNetwork or NSURLConnection, then right away you've reduced your cache access by 99.2% (by not fetching/checking all those external resources). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Oct 10, 2009, at 3:35 PM, Thomas Wetmore wrote: Please take this off list. That's an awfully presumptuous demand, don't you think? It's a relevant and interesting Cocoa topic. I've been following it with interest and it's quite obvious others have as well. -- 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: real verses Virtual memory
On Oct 10, 2009, at 12:41 PM, jon wrote: oh... that is good to know... hmm, well it looks like i need to go lower in the mechanism, stuff i don't know anything about, so i'll do research on the best way to get the info off the website at a lower level. RSS or Atom feeds are often used for this purpose. Does the site have feeds that you can check to find when things change? If so, look at the PubSub framework in 10.5+ which will automatically subscribe to and track feeds for you. It tries hard to be as efficient about it as possible. (Disclaimer: I wrote part of that framework so I'm biased :) If you can't use a feed, use NSURLRequest to fetch the page. If you leave the caching settings alone, it should be pretty good about being lazy: it will send a conditional GET that allows the server to respond with a nothing's changed response (just a couple of bytes) if the page hasn't changed. You can check the Last-Modified and ETag headers in the NSHTTPURLResponse object and compare them to what you got last time; if they're the same, there's no need to parse the page. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
that looks promising... thanks, Jon. On Oct 10, 2009, at 3:26 PM, Jens Alfke wrote: You can check the Last-Modified and ETag headers in the NSHTTPURLResponse object and compare them to what you got last time; ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Oct 10, 2009, at 1:01 PM, jon wrote: drives me crazy the documentation... it is there, but you have to know what to look for before you ever go down the correct tangent. There's certainly a lot of stuff, and it takes a while to learn what's in there. :/ The good part is that all these things make your job a lot easier. Take a look at the Tree-Based XML Programming Guide For Cocoa. (Pretty much wherever they say XML there, it includes regular HTML.) To fetch and parse the page, you just use [[NSXMLDocument alloc] initWithContentsOfURL: ... options: ... error: error]; There's an option flag to tidy the syntax before parsing; definitely include that flag, because most real-world HTML needs tidying to be parseable as XML. Then see the subsection Querying An XML Document and read the stuff about XPath. (You can also work with the tree of DOM nodes directly, pretty much like in WebView, just with different class names; but once you learn it, XPath is a lot more powerful.) —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
i was using a notification that was standard that told me when the page finished loading... does this have the same sort of mechanism? (or need it) when fetching the page? On Oct 10, 2009, at 3:26 PM, Jens Alfke wrote: If you can't use a feed, use NSURLRequest to fetch the page ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: capturing special keys when focused in an NSTextField
On Oct 10, 2009, at 1:13 PM, aaron smith wrote: Quick question - I have a window that I run as a sheet, which contains an NSTextField to enter a message. I have the window setup to close the sheet when the Escape key is pressed, however, when the text field is focused I can't figure out how to respond to these types of special keys. IIRC, this event gets handled by the button's -performKeyEquivalent: method, before normal key processing. You could override that method in another view to handle the Esc key, but it would probably need to be an ancestor view of the button. It might be easier just to clear the button's key equivalent property when the text view gets focus and restore it afterwards. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: real verses Virtual memory
On Oct 10, 2009, at 2:54 PM, jon wrote: i was using a notification that was standard that told me when the page finished loading... does this have the same sort of mechanism? (or need it) when fetching the page? NSURLConnection has a delegate object you can set, which will get called when the load finishes. You can read about it in the class docs. I'm pretty sure there is also sample code that demonstrates how to use NSURLConnection. If you don't care about doing it asynchronously, NSXMLDocument is a bit easier to use (it will just block until the page is loaded, and then return.) —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
re: [iPhone} Exception After Creating First Object
I got a couple of private messages about breakpoints and stacktraces, which, of course, I had done before I posted my question. That's how I discovered that [mod processPendingChanges] led to an exception when adding to an empty database table. I learned a little more about the exception. It occurs in [self.tableView endUpdates] which is invoked, I think, as a result of [moc processPendingChanges]. I have had problems in the past with [self.tableView endUpdates] with empty database tables but thought that this time was different. Previously, I had tried preventing [self.tableView endUpdates] being called when the database tables was empty but that caused other problems (e.g. my Add Entity Name button didn't appear when the database table was empty). I've seen others mention problems with [self.tableView endUpdates]. Does anyone know how to make [self.tableView endUpdates] less vulnerable when the associated database table is empty? Steve, Which version of iPhoneOS SDK are you building for ? This sounds like an issue that was fixed in 3.1. There has been more discussion of known issues and work arounds for the NSFetchedResultsController on the devforums. You might try searching them, or looking at https://devforums.apple.com/message/100783#100783 - Ben ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Drawing NSImageView Over NSOpenGLview
On Oct 10, 2009, at 1:26 PM, Steven Yiqiang Nie wrote: I'm new into opengl development on mac. Currently, I'm looking for a way to draw a NSImageView over NSOpenglView. I googled it, and it seems like I need to put the opengl thing into layer. I don't understand this, Could someone explain this ? Thanks a lot! O You may be referring to Core Animation, but I don't have experience with that. Another possibility is to use the NSOpenGLCPSurfaceOrder attribute with your NSOpenGLContext, to make the OpenGL surface draw below the window. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Detecting when sheet has finished appearing
A sheet animates into view. I want to detect it when this animation is complete. There are certain things (like a progressbar) that I wish to start only when the sheet has actually finished appearing on the screen. I don't want the progress bar to start before that. All I can find are a bunch of SheetWillBegin stuff. But I cannot seem to find any SheetDidBegin stuff. I therefore ask: How can I detect it when the sheet has completely appeared on the screen, i.e. detect when the sheet animation is complete? _ Windows Live: Make it easier for your friends to see what you’re up to on Facebook. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Detecting when sheet has finished appearing
-beginSheet methods return once the sheet has finished animating (IIRC). If you call -beginSheet you can add the code you want to execute after the sheet has been displayed immediately after that (but before any modal calls such as -runModalForWindow). The code will execute after the sheet animation has finished. On Sat, Oct 10, 2009 at 3:50 PM, Squ Aire squ...@live.com wrote: A sheet animates into view. I want to detect it when this animation is complete. There are certain things (like a progressbar) that I wish to start only when the sheet has actually finished appearing on the screen. I don't want the progress bar to start before that. All I can find are a bunch of SheetWillBegin stuff. But I cannot seem to find any SheetDidBegin stuff. I therefore ask: How can I detect it when the sheet has completely appeared on the screen, i.e. detect when the sheet animation is complete? _ Windows Live: Make it easier for your friends to see what you’re up to on Facebook. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com This email sent to bravo...@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: CoreData Bug? (SQLite vs XML) + isolated reproducible case
Hi all, Coming back to my original question (http://www.cocoabuilder.com/archive/message/cocoa/2009/9/13/244940 ), I isolated a reproducible case whereby CoreData loses a relationship on save (only when using SQLite). Link to the sample project is included below (check out the README for an explanation). I'd appreciate it if some of the CoreData gurus can confirm that it's indeed a bug in CD (in which case I'll file a radar) and not my code's fault. Many thanks. M http://dl.getdropbox.com/u/645995/CoreDataBug.zip ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Fw: Snow Leopard: unsupported PointerFunctions configuration was requested
Below is the RegexKit code that causes the Snow Leopard error. After reading the doco, I don't feel very enlightened about what the unsupported configuration is, or what the solution might be. Can anyone give me a clue? + (void)load { RKAtomicMemoryBarrier(); // Extra cautious if(RKCacheLoadInitialized== 1) { return; } if(RKAtomicCompareAndSwapInt(0, 1, RKCacheLoadInitialized)) { if((cacheMapKeyCallBacks= dlsym(RTLD_DEFAULT, NSIntegerMapKeyCallBacks)) == NULL) { cacheMapKeyCallBacks= dlsym(RTLD_DEFAULT, NSIntMapKeyCallBacks); } #ifdef ENABLE_MACOSX_GARBAGE_COLLECTION id garbageCollector = objc_getClass(NSGarbageCollector); if(garbageCollector != NULL) { if([garbageCollector defaultCollector] != NULL) { id pointerFunctions = objc_getClass(NSPointerFunctions); RKCacheIntegerKeyPointerFunctions = [pointerFunctions pointerFunctionsWithOptions:NSPointerFunctionsIntegerPersonality]; RKCacheIntegerKeyPointerFunctions.acquireFunction = intPointerFunctionsAcquire; RKCacheIntegerKeyPointerFunctions.descriptionFunction = intPointerFunctionsDescription; RKCacheIntegerKeyPointerFunctions.hashFunction= intPointerFunctionsHash; RKCacheIntegerKeyPointerFunctions.isEqualFunction = intPointerFunctionsIsEqual; RKCacheIntegerKeyPointerFunctions.relinquishFunction = intPointerFunctionsRelinquish; RKCacheIntegerKeyPointerFunctions.sizeFunction= intPointerFunctionsSize; RKCacheObjectValuePointerFunctions = [pointerFunctions pointerFunctionsWithOptions:(NSPointerFunctionsZeroingWeakMemory| NSPointerFunctionsObjectPersonality)]; [[garbageCollector defaultCollector] disableCollectorForPointer:RKCacheIntegerKeyPointerFunctions]; [[garbageCollector defaultCollector] disableCollectorForPointer:RKCacheObjectValuePointerFunctions]; } } #endif // ENABLE_MACOSX_GARBAGE_COLLECTION } } From: Bill Bumgarner b...@mac.com To: Chris Idou idou...@yahoo.com Cc: cocoa-dev@lists.apple.com Sent: Thu, 24 September, 2009 12:36:04 PM Subject: Re: Snow Leopard: unsupported PointerFunctions configuration was requested On Sep 23, 2009, at 7:09 PM, Chris Idou wrote: Very early in application startup, even before main() is called, I get the following error: 2009-09-24 12:07:11.462 MyApp[5534:a0f] *** An unsupported PointerFunctions configuration was requested, probably for use by NSMapTable, NSHashTable, or NSPointerArray. The requested configuration fails due to integer personality not using opaque memory It happens twice on startup, and below are the stack traces when it happens: What does it all mean? #00x7fff84b342f7 in NSLog #10x7fff84ac84d1 in +[NSConcretePointerFunctions initializeSlice:withOptions:] #20x7fff84aea796 in -[NSConcretePointerFunctions initWithOptions:] #30x7fff84aea74d in +[NSPointerFunctions pointerFunctionsWithOptions:] #40x10004b633 in +[RKCache load] One change to the NSPointerFunction based collection classes (which support a number of things that NSArray the like do not) between Leopard and Snow Leopard was to tighten up the validation of the pointer function validation such that a handful of non-sensical configurations are detected that weren't before. I.e. RKCache is trying to create a set of pointer functions that doesn't make sense (and for whose behavior is undefined). As someone else pointed out, RK is most likely RegexKit and, thus, the source is available and can be fixed. Given the relatively common use of RK*, please provide a patch to the author so it can be fixed upstream. b.bum Get more done like never before with Yahoo!7 Mail. Learn more. __ Get more done like never before with Yahoo!7 Mail. Learn more: http://au.overview.mail.yahoo.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
Should I try to avoid loading principal class of plug-in?
I'm working on a plug-in-based app. While I have to scan all of the plug-ins and load some information from their info.plists, I don't necessarily need to load any of the code until a plug-in is actually used. My main question is, is it worth it to do this? It seems like that's one advantage of plug-ins, but now I'm at a point where it's more elegant if I can determine if the plug-in class derives from a particular base class, rather than storing a key in info.plist (it would be redundant). 1) I'm assuming [NSBundle bundleWithPath:] doesn't load a bundle's code, right? The docs seem to suggest this is the case. 2) Once the principal class is loaded, everything is loaded, right? Plug-ins get grouped into a few different types, and it seems nicer to distinguish any given plug-in by what base class it inherits, rather than by specifying a key in the bundle's info.plist. The latter approach means a plug-in developer has to ensure that the proper key is present, the former requires loading of the code on app startup (when it scans plug-in directories to build a list of available plug- ins). I suppose I could look for the key, and if it's not present, then load the principal class and find out. Thoughts? TIA, 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: How to allocate and delegate; or how to keep GC and the static analyzer happy
On 10/10/2009, at 12:29 PM, Jens Alfke wrote: On Oct 8, 2009, at 7:33 PM, Glen Low wrote: 1. The code is not GC friendly as between the end of start and the beginning of finishWithSomething, there are no references to the object, so it may be collected. There must be references to it; otherwise how would that object's methods get called later on? Either it's a delegate of another object (an NSURLConnection or NSTimer or whatever) or it starts a new thread to run one of its methods. Either way, there are references to the object that keep it alive. 2. The static analyzer in Xcode 3.2 doesn't like the construction, thinking that the object is leaking from the start method. I'm not sure what to do about that. Casting the result to (void) might help, to explicitly state that you don't want to use the result. (Does the static analyzer even work with GC? Stating that the object is leaking only makes sense in a ref-counted environment.) It occurs to me that if I try to simulate the usual design pattern of NSAlert, NSThread etc. callbacks that will keep the static analyzer happy and probably be safer in the long run i.e. - (void)start { Something* something = [[Something alloc] initWithDelegate:self]; [something doSomething]; [something release];// #3 } - (void)finishWithSomething:(Something*)something { [something release]; } Note that the finishWithSomething: callback can happen after start has finished. So if Something uses e.g. an NSAlert - (id)initWithDelegate:(id)delegate { if (self = [super init]) { _alert = [[NSAlert alloc] init]; _alert.delegate = self; _delegate = delegate; } return self; } - (void)doSomething { [self retain]; // #1 [_alert beginSheetModalForWindow:xxx modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:NULL]; } - (void)alertDidEnd:(NSAlert*)alert returnCode:(int)returnCode contextInfo:(void*)contextInfo { [_delegate finishWithSomething:self]; [self release]; // #2 } Qn: 1. Are #1 and #2 strictly necessary? At the point of #1, the retain count of something is just 1, since the alert doesn't retain its delegate, and the release at #3 would have caused the object to be dealloc'ed. Then the alert will end up messaging a zombie. Therefore we need to add an extra retain and release around the callback. 2. In the presence of GC, #1 and #2 are no-ops. Does calling beginSheetModalForWindow: with modalDelegate == self sufficient to keep a reference alive to the something object? Or should I use CFRetain and CFRelease instead (are the effects different here from - retain and -release)? Cheers, Glen Low --- pixelglow software | simply brilliant stuff www.pixelglow.com aim: pixglen twitter: pixelglow ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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