Re: Slow down a scroller?
The Change Time Scale slider in Apple's Instruments application implements a novel self centering time based algorithm. A very interesting approach to a slider. Perhaps you also need to think outside the box and implement the desired behavior in a custom control. --Richard Somers On Jul 31, 2013, at 10:09 AM, Steve Mills smi...@makemusic.com wrote: Is there any way to make a scroller less touchy? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exiting non-POSIX threads?
On Jul 29, 2013, at 2:34 AM, Oleg Krupnov oleg.krup...@gmail.com wrote: Is there a way to exit a GCD thread? You can exit a GCD thread with something like this. - (void)invalidateQueue { _isQueueCanceled = YES; dispatch_sync(_queue, ^{}); } - (void)submitWorkToBeDone { dispatch_async(_queue, ^{ for ( ... ) { if (_isQueueCanceled == YES) { break; } else { // do work } } }); } When invalidateQueue returns the thread has been canceled. Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Reverse Engineering KickStarter Project
Just curious. Which Core Data document format are you trying to reverse engineer: XML, binary, SQLite, or all of them? Richard Somers On Jun 25, 2013, at 8:31 PM, Michael Crawford mdcrawf...@gmail.com wrote: Take a guess at the document format. Write an importer that reads that format. Put assertions everywhere. If your first guess is wrong, you'll trip an assertion. Lather. Rinse. Repeat. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSArrayController Added /Removed Objects
I have a programmatic NSArrayController wired up to a Core Data managed object context. I need to know what objects are added or removed from arrangeObjects. I have tried using KVO but that did not work. When KVO is used to observe arrangedObjects, the notification only indicates that the content has changed. It does not indicated what objects were added or removed. I thought about overriding some of the NSArrayController add / remove methods and identifying which objects are added or removed. But when objects are added to the managed object context, the only NSArrayController method that gets called is setContent:. None of the add or insert methods are called. It is interesting to note that when objects are removed from the managed object context, some of the NSArrayController remove methods are called but setContent: is not called. This is just the opposite of what happens when adding objects to the managed object context. Does anyone have any insight on how to determine what objects are added or removed from an NSArrayController? Thanks, Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: book for n00b
On Jan 16, 2013, at 11:14 AM, Scott Ribe scott_r...@elevated-dev.com wrote: I know someone who's developed an interest in developing for Mac. No programming experience, some HTML, so classic newbie. Would Hillegass' book still be the best intro? No that will not work. Hillegass's book assumes that you already have a background in Java, C, C++ or the like. A more gentle introduction is needed. On Jan 16, 2013, at 11:21 AM, T.J. Usiyan griotsp...@gmail.com wrote: An alternative is Stephen Kochan's Programming Objective C That would be a much better choice. On Jan 16, 2013, at 12:10 PM, Erik Stainsby erik.stain...@roaringsky.ca wrote: I'd also recommend Scott Stevenson's Cocoa and Objective-C: Up and Running and follow that with Stephen G. Kochan's Programming in Objective-C That would also be a good choice. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: HiDPI retina issue with multi-screen overlay window and Core Animation
On Jan 12, 2013, at 7:08 AM, William J. Cheeseman wjcheese...@gmail.com wrote: My best guess is that the problem results from the fact that the overlay window spans all attached screens. An NSLog() call confirms that the window's backingScaleFactor is always 1.0 (because it is initially created on a non-retina display in my testing). There is no NSWindow method to -setBackingScaleFactor, so there appears to be nothing I can do about this. Reading the documentation about CALayer and HiDPI screens very, very carefully, I notice that it always assumes that the layer-hosting view is in a window that is being dragged across screen boundaries. Am I correct in guessing that a fixed multi-screen window simply isn't capable of displaying HiDPI images if the window started out with a backingScaleFactor of 1.0? If that's correct, I guess I'll have to abandon my multi-screen overlay window and implement a multi-overlay-window solution, which is going to be a ton of work. Unless somebody can suggest a different approach using a multi-screen overlay window. A single window which overlays multiple screens with each screen using a possibly different backingScaleFactor. Wow! It seems like you have three options. 1. Use a single overlay window for all screens and continue fighting the frameworks. 2. Use one overlay window for each screen and go with the flow of the frameworks. 3. Try cursor replacement. Take the current cursor image, combine it with your image, and then somehow tell the system to use that. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: HiDPI retina issue with multi-screen overlay window and Core Animation
On Jan 12, 2013, at 12:53 PM, William J. Cheeseman wjcheese...@gmail.com wrote: I have no prior experience in this area. Can a cursor be created that animates using Core Animation? I know you can do offscreen rendering with some parts of Core Animation. So perhaps you could have your offscreen rendering machine updating or replacing the cursor image every so often. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Does anyone find Restore Snapshot kind of weak?
I use Git and have a work flow similar to what you are describing. My git commits are usually frequent, focused and sometimes staged. But I also manually copy the entire project folder or repository at various points in time and put it in a manual backup or history folder. I usually keep the last 20 or more of these manual backups. This frees me up for doing what ever crazy thing I want in the active git repository. If it starts going south I can just throw it all away (along with the Xcode project specific DerivedData directory), pull out a prior version from the manual backup directory and start fresh again. The whole process takes about a minute and has been bullet proof. I still use Git for reviewing history, managing branches, merging changes from one branch to another, etc., but this modified workflow has made my day to day development go much faster. --Richard Somers On Nov 29, 2012, at 1:02 PM, Yi Lin yionco...@gmail.com wrote: I do use Git, and take advantaging of its staging abilities. But sometimes, I want to do some quick experiments and want to get back to a previous state. Kind of like undoing with Command-Z except it involves multiple files. Yes, theoretically, Git can do all that. But are you telling me people who use Git never invoke undo? Snapshot would work more like named, multi-file undo for me, rather than as VC. But still, I just want Snapshot to work. Right now it doesn't, except on the simplest of projects. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Scalability of CALayers
On Oct 25, 2012, at 6:18 PM, Graham Cox graham@bigpond.com wrote: I'm wondering how scalable the Core Animation layer model is. Look at the WWDC 2006 video around the 0:50 mark. Scott Forstall introduces Core Animation and discusses its scalability. He show a demo of the iTunes album screen saver app written to show case the power of Core Animation but running in real time. (But of course the real reason Apple wrote Core Animation was not for an iTunes album commercial but for the iPhone which would be released the following year.) http://www.youtube.com/watch?v=w6SXMtmUsX0 --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
App Sandbox Container or Data Directory
I do not understand what is going on with an application's sandboxed container or Data directory. NSHomeDirectory for an OS X sandboxed app points here. ~/Library/Containers/bundle_id/Data The sandbox Data directory is pre-populated with items. Data/Desktop (Alias) Data/Documents Data/Downloads (Alias) Data/Library Data/Movies (Alias) Data/Music (Alias) Data/Pictures(Alias) So here are some of the unusual things. 1. If you specify No Access to the Music, Movies, Pictures, or Downloads folders for the App Sandbox you can still save a document to those folders. So much for the sandbox. 2. When a file is saved to the Documents folder in a save dialog, the file is actually saved to ~/Documents not Data/Documents. So what is Data/Documents for? 3. Data/Documents is pre-populated with an iChat file alias. What is that for? 4. Local log files go in Data/Library/Logs but this location is not visible from Console app. So all local log files are visible from Console except for apps that are sandboxed. How can a user see local sandboxed log files? 5. Data/Library/Preferences is pre-populated with a bunch of preference plist file aliases. One of the items is an alias to com.apple.iWork.Pages.plist. Why would my app need default access to the Pages preference plist file? This seems like a violation of sandboxing. A lot of this simply does not make sense. What am I missing? --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: App Sandbox Container or Data Directory
On Oct 23, 2012, at 1:29 PM, Mike Abdullah cocoa...@mikeabdullah.net wrote: The sandbox is intended to limit what an *app* can do by itself, not what a *user* can do. Users are free to save things wherever they like; the only entitlement that plays a role in that is com.apple.security.files.user-selected.read-only Not true. The user can navigate in the save panel to where ever but saving to an unapproved location will result in an error. The document could not be saved. You don't have permission. As in you’re setting up ASL to write to a specific file within your container? Yes, writing to NSHomeDirectory/Library/Logs using ASL but sandboxed library logs do not show up in Console. I have not tried to access the Pages plist file. I strongly suspect any attempt to access it would fail unless you have a temporary entitlement to do so. You are correct. The Pages plist file is readable but not writable. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: App Sandbox Container or Data Directory
On Oct 23, 2012, at 2:43 PM, Kyle Sluder k...@ksluder.com wrote: If by unapproved you mean my app's sandbox hasn't been extended to include this path then you are incorrect. The user can choose the destination, and the NSURL you get back from the open panel will carry the rights to access that location. If by unapproved you mean the user my app is running as doesn't have write permission to this location, then yes that is expected behavior. I sandboxed my app in Xcode. In the app target entitlement area there are access control options for Music, Movies, Pictures, and Downloads folders. Access to these folders remained the default No Access. I launched the app and and saved a new document. In the save panel the Music folder was showing as a Recent Place. I selected this as the save location and saving was a success. As a developer, based on the entitlement settings, I was expecting failure. Saving a new document to the users home directory (choose the home directory in the save panel) resulted in failure. The document could not be saved. You don't have permission. As a developer this is what I expected. From a users point of view I was surprised that the save panel let the user choose a location where a save was not allowed and subsequently would result in failure. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
On Sep 11, 2012, at 10:06 AM, Motti Shneor su...@bezeqint.net wrote: OK. Could you spare some pseudo-code for this? Or some link to a known code-sample? or maybe some 10 highlight lines from your own utilities? Documentation on method swizzling isn't that easy to use. In my case, all I need to do is to swizzle? (like override) the addObserver of my observed object, and record the high-level observation info (observer, options, context, etc.) in some static container, so I can later question the observed object about its observer. But how do I do that on my NSManagedObject sublcass? Sorry about the delayed response. I have been buried in work. I switched to 10.8 Mountain Lion and I am still adjusting to the revised Mail applicaiton. You could do swizzling like this. #import JRSwizzle.h @implementation NSManagedObject (MySpecialCategory) // Do the swizzling + (void)load { @autoreleasepool // NSAssert requires an autorelease pool { NSError *error = nil; [[NSObject class] jr_swizzleMethod:@selector(method) withMethod:@selector(my_swizzled_method) error:error]; NSAssert(error == nil, @%@, error); } } // Framework method // - (void)method // { // ... // } // Swizzled method - (void)my_swizzled_method { // do your thing // call original implementation [self my_swizzled_method]; } @end Note that the NSManagedObject documentation indicates As with any class, you are strongly discouraged from overriding the key-value observing methods. I view swizzling like this: You are at your wits end, you have examined all other options, you want to use Apple's frameworks but you simply can figure out any other way. So you try swizzling. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
On Sep 10, 2012, at 5:59 AM, Motti Shneor wrote: Although I don't need such heavy-weapons, and I don't at all deal with programmatic bindings here, I'd still like (if possible) to learn some more about the implementation of your internal tools. I didn't yet have a chance to work with swizzling, and maybe its time I started. My case is not of complexity, but of performance. If I simply observe all the time, and then filter what I need, penalty would be too much. I get huge amount of observation-calls (every refresh of my core-data context) and I need to inspect lots Method swizzling lets your replacement method make use of the original method, almost like subclassing. In my case it let me add a form of bindings introspection. For example, what objects currently have active bindings and what are those bindings. I have found that the tools available for debugging bindings to be almost non-existant. (None of the malloc diagnostics tools help and for some reason adding -NSBindingDebugLogLevel 1 has never helped.) Given that bindings are just a relatively thin veneer on Key Value Observing perhaps there is some similarity here. One of the problems I faced was that when an edit was underway certain objects with active bindings would cause an avalanche of KVO notifications resulting in a substantial performance penalty. One of the things I did to help alleviate the situation was to programmatically remove and recreate the binding for objects that did not directly participate in the edit. I guess this does seem like a lot of work but then again most people would likely say that writing glue code is a lot of work. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
On Sep 9, 2012, at 3:32 AM, Motti Shneor wrote: - (NSUInteger)isObserver:(id)object on keyPath:(NSString *)keyPath withContext:(void *)context]; // the returned number is the count of same observances with 0 as not-observing). and something like - (BOOL)removeObserver:(id)object;// where I instruct the receiver to remove object as an observer, on all key-paths and contexts. should return YES if object was an observer, and was removed, NO otherwise. Any ideas? I recently did something similar only for bindings. @interface NSObject (MYBindings) + (NSString *)my_objectsWithActiveBindings; // for debugging + (NSUInteger)my_objectsWithActiveBindingsCount; // for debugging - (void)my_revmoveAllBindings; @end This was implemented by swizzling the NSObject implementation of -bind:toObject:withKeyPath:options: and -unbind: at runtime using JRSwizzle along with keeping binding information for each instance in a single static mutable dictionary (associative storage pattern). The swizzled methods call the NSObject implementation of -bind:... and -unbind: and also keep track of the additional binding information needed. I am working on a project with a lot of programmatic bindings and I needed some debugging aids and other routines to help with binding management. At first I was hesitant to swizzle a framework method but I desperately needed some help. So far it seems to be working well and the new routines helped uncover a bug that I literally spent days trying to find with no success. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Malloc Error: pointer being freed was not allocated
On Sep 7, 2012, at 3:55 PM, Jens Alfke wrote: On Sep 7, 2012, at 12:01 PM, Richard Somers rsomers...@awinets.com wrote: MyApp(469,0x1009fbcc0) malloc: *** error for object 0x12f6b19a0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Following the instructions and adding a symbolic break point (malloc_error_break) results in nothing different. The application still halts at the same location with the same error. From the stack it looks like the environment variable MallocErrorAbort is already set, so you’ve already stopped at the point of the error. I have searched through every stack frame and can find no reference to the pointer in question 0x12f6b19a0. You would think that this pointer would be located somewhere in one of the stack frames. The only stack frame that would necessarily be referring to it is #3, gfxReleaseSharedState — I don’t know if that’s your code or not. That function has called free( ) on that pointer. A po or p on the pointer in the debug console produces nothing useful. It isn't an Objective-C object, because gfxReleaseSharedState is directly calling free() on it. I don’t have much more advice, because it looks like the code on the stack is related to OpenGL, which I don’t know anything about. It’s possible you’ve got the refcounting wrong for something GL-related, so that the ‘shared state’ referred to has already been freed. The stack looks like this: #0 0x0001008700b6 in __kill () #1 0x0001009109f6 in abort () #2 0x000100828195 in free () #3 0x0001064c01b3 in gfxReleaseSharedState () #4 0x00012cc3d91f in gliDestroyContext () #5 0x000100166de4 in CGLReleaseContext () #6 0x000100169faa in CGLDestroyContext () #7 0x00010001468d in -[RSTriadLayer releaseCGLContext:] at RSTriadLayer.m:302 Jens, thanks for the help. I found the pointer. It appears in frame #2 free () and higher frames in one of the general purpose registers. One would think that the pointer would show up in frame #3 gfxReleaseSharedState () which calls free () but it does not. My code is frame #7 and #10 and everything else is from the frameworks. Yes, it appears this is some sort of OpenGL related memory management issue. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Malloc Error: pointer being freed was not allocated
I have an intermittent error that I can not make any progress on solving so I thought I would ask for some help from someone more experienced than myself in debugging. Program execution halts in Xcode with the following error: MyApp(469,0x1009fbcc0) malloc: *** error for object 0x12f6b19a0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Following the instructions and adding a symbolic break point (malloc_error_break) results in nothing different. The application still halts at the same location with the same error. I have searched through every stack frame and can find no reference to the pointer in question 0x12f6b19a0. You would think that this pointer would be located somewhere in one of the stack frames. A po or p on the pointer in the debug console produces nothing useful. The stack looks like this: #0 0x0001008700b6 in __kill () #1 0x0001009109f6 in abort () #2 0x000100828195 in free () #3 0x0001064c01b3 in gfxReleaseSharedState () #4 0x00012cc3d91f in gliDestroyContext () #5 0x000100166de4 in CGLReleaseContext () #6 0x000100169faa in CGLDestroyContext () #7 0x00010001468d in -[RSTriadLayer releaseCGLContext:] at RSTriadLayer.m:302 #8 0x0001003cd52a in CAOpenGLLayerDestroy(CAOpenGLLayer*, bool) () #9 0x0001003cd5f2 in -[CAOpenGLLayer dealloc] () #10 0x0001000141d6 in -[RSTriadLayer dealloc] at RSTriadLayer.m:204 #11 0x0001001864ff in CA::release_root_if_unused(CALayer*, CALayer*, void*) () #12 0x000100186453 in x_hash_table_remove_if () #13 0x000100186268 in CA::Transaction::commit() () #14 0x000100baeb07 in __CFRunLoopDoObservers () #15 0x000100b89daf in CFRunLoopRunSpecific () #16 0x0001026aa7ee in RunCurrentEventLoopInMode () #17 0x0001026aa551 in ReceiveNextEventCommon () #18 0x0001026aa4ac in BlockUntilNextEventMatchingListInMode () #19 0x0001013e4eb2 in _DPSNextEvent () #20 0x0001013e4801 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] () #21 0x0001013aa68f in -[NSApplication run] () #22 0x0001013a33b0 in NSApplicationMain () #23 0x00011eb2 in main at main.m:27 #24 0x00011e84 in start () Any suggestions? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView scrolling
On Jul 30, 2012, at 12:19 PM, ecir hana wrote: when jumping from line to line in a textview with up and down keys, it exhibits this scrolling behavior - when the cursor is at the very top and I hit up (and vice versa), it scrolls the document half page up, that is, the current line is now in the middle of the textview. Is it possible to disable this behavior? Is it possible to make it scroll by just one line? So that the current line stays always at the top (bottom)? This might help. http://www.cocoabuilder.com/archive/cocoa/145464-nstextview-auto-scroll-up-behaviour.html --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Window-Frame Controls in Lion
Controls in the window-frame area (that is, in the toolbar or bottom bar) normally have a textured style as stated in the OS X Human Interface Guidelines. In 10.7 Lion textured controls became semi-transparent with some of the background showing through. This results in most window-frame controls taking on more of a bland gray look. Not all applications suffer from the bland gray toolbar look in Lion. Apple's iCal sports a bold new brown leather look. You may or may not like the new look but one thing is does have and that is sharply defined window-frame controls. Even though the window-frame background and controls are both brown, the contrast between the two is sharp. Compare this to the Finder window-frame in Lion where the controls are not nearly as sharp. One measure of the contrast between the background and the control is the difference in brightness between the two. The fact that the background and control have the same base color makes this measurement especially meaningful. Application OS XBase Color Background-Control Brightness Finder 10.6Gray61 - 4 = 57% Finder 10.7Gray67 - 21 = 46% iCal10.7Brown 71 - 13 = 58% These measurements correlate to the general perception that window-frame controls the new iCal and the old Finder are sharp and identifiable. Whereas window-frame controls in the new Finder appear less defined and muddy. I have an application that relies heavily on the toolbar. In my option the usability of standard toolbar controls has been degraded in Lion because of this change. Does this bother anyone else besides me? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Trap mouse and keyboard events
On Jun 24, 2012, at 11:56 PM, Abhijeet Singh wrote: I want to perform some action in my application whenever user presses any key on keyboard or uses the mouse. How can I trap these events. One way to do this would be to subclass NSApplication and override sendEvent:. The documentation indicates Override sendEvent: if you want to change how events are dispatched or perform some special event processing. https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/nsapplication_Class/Reference/Reference.html --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Demo Version
The Mac App Store guidelines indicates that Apps that are beta, demo, trial, or test versions will be rejected. So if potential customers need to go to my website to download a demo version then I might as well offer the retail version for sale on my website also. Why use the Mac App Store? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Managed Objects and Contexts
John and Mikkel, Thanks for the insight on multiple contexts in Core Data. It helps a bunch. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Managed Objects and Contexts
I have a question about multiple contexts. First a quote from the Core Data Programming Guide - To consider this from a different perspective, a given object in a persistent store may be edited in more than one context simultaneously. Each context, however, has its own managed object that corresponds to the source object, and each managed object may be edited independently. This can lead to inconsistencies during a save-Core Data provides a number of ways to deal with this. So to recap, a given object in a persistent store may be edited in multiple contexts simultaneously and each context has its own managed object corresponding to the given source object. And when the user saves everything is sorted out by Core Data. I know that Core Data is not multi-user but this sounds like a multi-user data base use case scenario. Multiple contexts (users) all potentially looking at the same data and the first one to save wins. Why did Apple do this? What would be a legitimate use case for this scenario? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Window cascading
On May 8, 2012, at 3:01 AM, ecir hana wrote: I create a window like this: id window = [[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO] autorelease]; [window cascadeTopLeftFromPoint:NSMakePoint(20,20)]; but it cascades just vertically - the next window is positioned to the very top left of my screen, the next one is just 20px lower (and 0px right), the next one is again 20px lower than the previous one but it wont move horizontally. Why's that? Do I have to remember the returned NSPoint and pass it to next cascadeTopLeftFromPoint:? If I remember correctly you are using the document architecture. The documentation has this to say. If you use the Cocoa document architecture, you can use the setShouldCascadeWindows: method of NSWindowController to set whether the window, when it is displayed, should cascade in relation to other document windows (that is, have a slightly offset location so that the title bars of previously displayed windows are still visible). The default is true, so typically you have no additional work to perform. If you are not using the document architecture, you can use the cascadeTopLeftFromPoint: method ofNSWindow to cascade windows yourself. The method returns a point shifted from the top-left corner of the window that can be passed to a subsequent invocation of cascadeTopLeftFromPoint: to position the next window so the title bars of both windows are fully visible. http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/WinPanel/Tasks/SizingPlacingWindows.html Have you examined the EnhancedDataBurn sample code? It has two examples of where -[NSWindow cascadeTopLeftFromPoint:] is used. http://developer.apple.com/library/mac/#samplecode/EnhancedDataBurn/Introduction/Intro.html --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Window cascading
On May 8, 2012, at 8:51 AM, ecir hana wrote: Yes, document-based. However, not sure if it is an issue, but I have my own subclassed window controller. The docs also say that the default for shouldCascadeWindows is YES. I tried to set it to YES in setShouldCascadeWindows:, without luck. I look at the EnhancedDataBurn example but it uses the origin of already shown window, which is slightly different than my case, I believe. I would suggest that you download the solutions for Cocoa Programming For Mac OS X (3rd Edition) and look at Chapter 10_Archiving. This chapter contains a modern fully functional document based sample application with window cascading working perfectly. You should be able to quickly get the sample project up and running in a few minutes in Xcode 4.2 by validating the project build settings and setting the default SDK. http://www.bignerdranch.com/book/cocoa_programming_for_mac_os_x_rd_edition_ Subclassing the window controller is a more advanced topic and if I were you I would not focus on that right now. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Minimal document-based app
On May 2, 2012, at 7:19 AM, ecir hana wrote: - I saw that Xcode named the Info.plist differently (it prepends my project name to it) - is it ok just to call it Info.plist? Is there any convention? https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/ConfigFiles.html - this CFBundleDocumentTypes - what if I wanted to have only one kind of documents? Does it have to be an array as well? What is the absolute minimum every CFBundleDocumentTypes must contain? https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFBundleRef/Reference/reference.html - is it really the case that I don't need the AppDelegate? It currently makes sense to me but maybe I'm missing something? http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html - I don't want to put the window in init, where else should I put it? Does NSDocument have an equivalent of applicationDidFinishLaunching, i.e. when the document is created is there any callback fired? https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/nsdocument_Class/Reference/Reference.html - new windows are positioned over the previous ones - I know this is because of that NSMakeRect() - the application created using Xcode (with NIBs) put every new window slightly to the right, slightly below the previous window - what is responsible for it? The NIB? It is called window cascading. https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/nswindowcontroller_Class/Reference/Reference.html You should also read this. http://cocoawithlove.com/2008/03/cocoa-application-startup.html --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Minimal document-based app
On May 1, 2012, at 8:50 AM, Fritz Anderson wrote: NIBs _are_ how it works. They don't contain or generate code. They don't contain or generate scripts. They don't exercise much of the API you're trying to use. They contain archived objects and their connections. True, but the beginner may not have the slightest clue as to what those objects in Interface Builder are and what functionality they provide and how they should be properly connected. I have often found that once you understand a class and its methods by reading the documentation again and again and even doing some coding, then when you look at it in Interface Builder a light will go on and you will exclaim eureka, now I understand what this is trying to tell me! But for me it has NEVER been the other way around. I have NEVER learned a concept first Interface Builder and have it make sense. I have often thought that Interface Builder was created by very gifted programmers who knew the underlying objects and API and to them it all makes perfect sense but they are completely oblivious to the fact that it makes almost no sense to a beginner. Apple has done an incredible job with the Cocoa API, documentation, and developer tools but the learning curve can still be overwhelming. My advice to a beginner is start very small and work your way up. Read the documentation, get a good book like Cocoa Programming for Mac OS X Third Edition by Hillegass, and start working your way through the examples. There are no shortcuts. Hillegass covers the document architecture in Chapter 10 starting on page 157 which is almost half way through the book. Maybe it is just me, but that has been my experience. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSKeyValueBindingCreation Protocol
I have a number of controls with custom bindings that are programmatically added to a view hierarchy in a window. Calling –unbind: on these controls when the window is closes is a challenge. But it actually does not seem to matter. If –unbind: is never called and the window is closed there are no memory leaks reported in Instruments. Apple has an undocumented class NSAutounbinder which apparently addresses a problem with retain cycles when binding to File's Owner from a nib file. However I am binding programmatically not inside a nib file. But perhaps NSAutounbinder is somehow working in my behalf. Is unbinding my programmatic bindings when the window closes something that I should worry about? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSKeyValueBindingCreation Protocol
On Apr 28, 2012, at 1:30 PM, Quincey Morris wrote: To get an answer on this, you'll probably need to say which memory model you're using: GC, ARC or traditional RR. I am using traditional retain and release. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSKeyValueBindingCreation Protocol
On Apr 28, 2012, at 1:30 PM, Quincey Morris wrote: To get an answer on this, you'll probably need to say which memory model you're using: GC, ARC or traditional RR. Actually now that I have done a little more research it appears that my question regarding programmatically calling -unbind: when the window closes is not related to which memory model I am using: GC, ARC or traditional RR. GC is not recommended any more and ARC only deals with retain/release. ARC does not remove observers and thus would be unable to -unbind:. So this question would apply equally to ARC and manual RR. http://stackoverflow.com/questions/8122976/objective-c-automatic-reference-counting-arc-and-key-value-observing http://stackoverflow.com/questions/7827953/removing-observers-in-post-arc-cocoa http://stackoverflow.com/questions/13927/in-cocoa-do-i-need-to-remove-an-object-from-receiving-kvo-notifications-when-deallocating-it --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSKeyValueBindingCreation Protocol
Kyle, Thanks for the advice. I programmatically add subviews to a view using a loop. The loop has a lot of logic in it. Not all subviews are the same. Some have bindings and some do not and not all bindings are the same. Some subviews have additional retained objects with their own bindings. So I would need to loop through all these objects in dealloc and figure out which ones have what bindings and unbind them. I have never used a looping construct in a dealloc method before, so that is why I was hesitating. --Richard On Apr 28, 2012, at 7:07 PM, Kyle Sluder wrote: On Apr 28, 2012, at 10:17 AM, Richard Somers rsomers...@awinets.com wrote: I have a number of controls with custom bindings that are programmatically added to a view hierarchy in a window. Calling –unbind: on these controls when the window is closes is a challenge. Why? Someone has to have called -bind::: on them. Make that thing call -unbind: when your window delegate (most likely your NSWindowController subclass) gets -windowWillClose:. But it actually does not seem to matter. If –unbind: is never called and the window is closed there are no memory leaks reported in Instruments. You're probably leaking observers and might crash at some point. You said custom bindings; how are your bindings implemented? Apple has an undocumented class NSAutounbinder which apparently addresses a problem with retain cycles when binding to File's Owner from a nib file. However I am binding programmatically not inside a nib file. But perhaps NSAutounbinder is somehow working in my behalf. Doubtful. I believe NSAutounbinder is only used by the nib loading machinery. Is unbinding my programmatic bindings when the window closes something that I should worry about? 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Automatic Lightweight Migration
On Apr 2, 2012, at 11:01 PM, Jerry Krinock wrote: That is expected behavior. The tildefied document, as I call it (tilde = ~) is in fact the old document, prior to migration, which Core Data has renamed. It is an undocumented feature of Core Data. Apparently, the idea is that, with help from your Support Department, a distressed user can revert if the migration gave undesired results. I was thinking along the same line of reasoning. If a core data tildefied document baffles an uninformed developer then what in the world is the end user going to do? So it looks like your SQLite migration is working correctly. Only your XML migration is failing. The failing XML migration is still under consideration. Thanks for your help. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Automatic Lightweight Migration
On Apr 2, 2012, at 4:20 PM, Richard Somers wrote: Can anyone shed some light on this? It appears that others have also recently experienced frustration with automatic lightweight migration and have come up with zero answers. Jan 26, 2012 http://stackoverflow.com/questions/9014668/core-data-automatic-lightweight-migration-failing-in-xcode-4-using-process-the-w Mar 20, 2012 http://stackoverflow.com/questions/9791706/automatic-core-data-migration-fails-on-mac-os-x-10-5-but-not-on-10-6-or-10-7 --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSTextField Selected Text
When tabbing into a text field containing text, the text is selected. When clicking into a text field containing text, the I-beam cursor indicates the insertion point. How can I make clicking into text field containing text, initially select all the text just like tabbing does? Thanks for your help, --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextField Selected Text
On Mar 30, 2012, at 3:22 PM, Richard Somers wrote: When tabbing into a text field containing text, the text is selected. When clicking into a text field containing text, the I-beam cursor indicates the insertion point. How can I make clicking into text field containing text, initially select all the text just like tabbing does? Just found an answer to my question on stack overflow. I previously did a search of the web and the documentation and came up with nothing. But I tried it again and found this. http://stackoverflow.com/questions/2195704/selecttext-of-nstextfield-on-focus --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to get max size of view according to constraints?
On Mar 19, 2012, at 10:20 PM, Charles Srstka wrote: As everyone knows, if you have a view with a bunch of subviews and you’ve got NSLayoutConstraints set up for everything, in many cases you might end up with a minimum or maximum size for the view beyond which the constraints are impossible to satisfy, and if you try to resize the view outside these bounds either in IB or in the actual program (if the view is the content view of a resizable window, for example), the resizing will simply stop at those boundaries. I have worked with constraints in another system and one of the things I learned is that a collection of constraints must be exercised or driven from one extreme to the other in order to have confidence that they are correct. If you have a min or max size condition for the view beyond which the constraints are impossible to satisfy, but this in not what you want, then you need to change the constraints so that you get what you want under all conditions. The constraint engine is mathematically correct and does not lie. So if there is a problem, it is in how you are specifying and arranging the constraints or in the number of constraints you have. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: There's obviously something I don't understand about autorelease.
On Mar 17, 2012, at 6:12 PM, Roland King wrote: So often I find I start with @synthesize foo=_foo; and by the time I get to the end of the project I've written custom foo: and setFoo: methods which do something else too. I have also done that but I recently read a blog where the writer recommends Do not override @synthesized properties with your own code: use @dynamic properties instead http://wiki.akosma.com/Objective-C_Code_Standards I would be curious if anyone else has an opinion on that one way or the other. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UIKit-additions and class references
On Mar 6, 2012, at 2:28 PM, Mikkel Islay wrote: Does anyone know the reason why the UIKit-additions for NSString, NSValue etc. aren't mentioned in the respective class references in the Apple documentation for iOS? It appears that the same NSString Class Reference documentation for the Mac OS X Developer Library is also used for the iOS Developer Library. The original Mac OS X documentation does not mention iOS. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: HELP!! Big problem with relationships and saving in iOS core data
On Mar 1, 2012, at 7:12 AM, Eric Giguere wrote: I'm on the verge of loosing my sanity... I've been hitting this error for a long time now. If I try deleting the C object before saving the new stuff, I get this error: Domain=NSCocoaErrorDomain Code=134030 The operation couldn’t be completed. (Cocoa error 134030.) NSUnderlyingException = Cannot update object that was never inserted.; And if I save, then delete then save again I get back to the NSObjectInaccessibleException. Take a deep breath and get a good nights sleep. Hillegass suggests 10 hours of sleep may be needed when learning a new topic. Generally it has been my experience with error messages that the frameworks are trying to tell you something. Often after the problem is solved the error message completely makes sense. Here are few links you could try. http://stackoverflow.com/questions/7109880/core-data-unresolved-error-on-save http://stackoverflow.com/questions/5591301/coredata-nsobjectinaccessibleexception-coredata-could-not-fulfill-a-fault It does not make sense that such a library fails with such a trivial case. So far it has been my experience that Core Data works as advertised except for one case I found where the documentation was not updated and the actual functionality was more than advertised. I also learned the hard way that Core Data has a steep learning curve and required a lot of effort to understand what was going on. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Make Custom Struct Key-Value Coding Compliant
SOLVED - Thanks for all the comments. On Feb 11, 2012, at 11:56 PM, Graham Cox wrote: Making it an object is easy and usually it turns out that the desire to resist doing that is misguided, based on some faulty assumptions. I decided to resist no longer and make my custom strut an object. I made an object that had individual properties corresponding to the struct members. Unfortunately this created to many problems elsewhere. But the story has a happy ending. Arbitrary structs are Key-Value Coding compliant and work fine with Core Data, they do not need to be stored in the managed object as an object. The documentation is in error on this point. On Feb 12, 2012, at 2:18 AM, Joar Wingfors wrote: Please file a bug report on the documentation: Filed bug report Bug ID# 10872122. On Feb 12, 2012, at 6:50 AM, John Joyce wrote: But the best advice, don't fight the framework. Agreed. Originally I thought that custom structs were not compatible with Core Data. But this is not true. They can work very well with the framework. Thanks again. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Make Custom Struct Key-Value Coding Compliant
On Feb 12, 2012, at 1:28 AM, Kyle Sluder wrote: Hmm. The Foundation Release Notes for 10.5 indicate that KVC supports arbitrary structs (see section titled Support for Arbitrary Types in KVC and KVO) Yes I have read that several times. It seems to be at odds with the Core Data documentation. It is very confusing. I have not been able to get custom structs to work properly with Core Data. So for now I would agree with the Core Data documentation that they are somehow not KVC compliant. But the blog you linked to indicates that manually-implemented accessors aren't exactly the most efficient. If you read all the way to the bottom of the blog, he was able to substantially improve the results with manually-implemented scalar accessors. Another confusing thing is that Xcode 4.2 has a new undocumented checkbox called Use scalar properties in the class generation sheet. But this only works with iOS 5 and Mac OS X 10.7. http://subjectiveobserver.wordpress.com/ --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Make Custom Struct Key-Value Coding Compliant
Core Data Question I have a custom struct that I would like to make key-value coding compliant so it will work with Core Data as a non-standard persistent attribute. Is it possible to make a custom struct key-value coding compliant? I would rather not store it in the managed object as an object but would like to leave it as a struct and have it work just like NSPoint, NSSize, NSRect, or NSRange. Core Data Programming Guide Non-Standard Persistent Attributes Scalar Value Constraints A requirement of the accessor methods you write is that they must be key-value coding (and key-value observing) compliant. Key-value coding only supports a limited number of structures—NSPoint, NSSize, NSRect, and NSRange. If you want to use a scalar type or structure that is not one of those supported directly by Core Data and not one of the structures supported by key-value coding, you must store it in your managed object as an object-typically an NSValue instance, although you can also define your own custom class. You will then treat it as an object value as described later in this article. It is up to users of the object to extract the required structure from the NSValue (or custom) object when retrieving the value, and to transform a structure into an NSValue (or custom) object when setting the value. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Entity And Attribute Names In XML Store
On Jan 30, 2012, at 6:27 PM, Jens Alfke wrote: On Jan 30, 2012, at 1:34 PM, Richard Somers wrote: Why does Core Data change entity names to upper case and attribute names to lower case in the XML store? I don’t know; but the format of that XML is supposed to be private to CoreData, not something your app should try to read or write. (Same goes for the schema of the SQLite databases CoreData creates.) True. But the documentation states It is common, for example, to use the XML store early in a project life-cycle, since it is fairly human-readable and you can inspect a file to determine whether or not it contains the data you expect. Upon inspecting the XML store I was surprised to find that the entity and attribute names had been altered and so I was curious if there was a reason for doing this. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Data Entity And Attribute Names In XML Store
Why does Core Data change entity names to upper case and attribute names to lower case in the XML store? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Mysterious File exists message logged to console
On Dec 15, 2011, at 8:29 AM, Mike Abdullah wrote: I'm trying to track down a bug and have a copy of a customer's console log to help me. There's rather a lot of messages like this: open on /Users/foo/bar/mydocument.package/DSC_0221.jpg: File exists Searching the web has been fruitless so far, so does anybody know which Cocoa API(s) would produce such messages? This might be a digital camera picture loading error. DSC may stand for Digital Still Camera and _0221 the photo serial number. So perhaps the error is being generated by a digital camera connected to iPhoto or Aperture. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSView mouseDown truncated coordinates
On Nov 25, 2011, at 6:17 PM, Steven Spencer wrote: I'm using a NSTrackingArea in a view to receive mouseMoved events. The cursor location in the mouseMoved and mouseDragged events have non-integer coordinates (as expected). e.g. x:140.601562 y:128.082031 However, the mouseDown and mouseUp events always produce truncated coordinates. e.g. x:140.00 y:128.00 This causes inaccuracy with hit testing between mouseMoved and mouseDown. All the mouse events use the same code to convert the point for the view : NSPoint location = [self convertPoint:[theEvent locationInWindow] fromView:nil]; On Nov 26, 2011, at 10:58 AM, Ken Thomases wrote: We've seen this, too. It started happening with Lion. I filed a bug report on this. Bug 9639143 on 20-Jun-2011. I also recently filed a technical support incident asking for resolution or a workaround. The request is pending. My observations are as follows: -[NSEvent locationInWindow] can produce non-integral values in Lion with a mouse. This did not happen in previous versions of the OS. This is a Lion regression. Using floor, ceil, or round on the returned value does not work because the value can be off by as much as +-1.0. The amount of error in the value returned can be somewhat random. It is not constant. -[NSWindow mouseLocationOutsideOfEventStream] also produces non-integral values in Lion with a mouse. MacOS X 10.1 Application Framework release notes states that -[NSEvent locationInWindow] may now return NSPoints with non-integral coordinates to represent sub-pixel precision generated by some input devices, for instance tablets. However I do not think that this is relevant because this issue happens with a mouse not a tablet. This issue is not a sub-pixel precision issue. If it was then simple rounding or the like would fix it. http://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKitOlderNotes As a side note, I have also noticed that the mouse tracking speed and or acceleration curve is different (think worse) in Lion when using the same system preferences as in Snow Leopard. In closing it is great to know that others are also having difficulty with this issue. :) --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Weird NSTextField behavior on MBA.
On Nov 22, 2011, at 1:59 AM, Gustavo Pizano wrote: I will make some debugging on my friend MBA and see if something's wrong in the code, if not, then I guess I will be filling up a Bug report, because this issue makes no sense to me. Is this done completely in Interface Builder or in code. If in code perhaps you should post your code. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSTableView - preventing user moving with mouse
On Nov 21, 2011, at 5:11 AM, Peter Hudson wrote: I have an NSTableView whose position I want to control purely programatically. How do I stop the user from changing its position using the mouse - including two finger swipe gestures ? The position of the NSTableView is set with -initWithFrame: along with all of the various frame methods. Column adjustment is controlled with -setAllowsColumnReordering: and -setAllowsColumnResizing:. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Weird NSTextField behavior on MBA.
On Nov 21, 2011, at 3:08 PM, Gustavo Pizano wrote: So im wondering what its going on because I have tried the behavior on 2 iMacs, 2 MPB and 2 MBA, on the latest one is the only one that doesn't behave as expected. What can it be? Perhaps it is a graphics card issue. One way to check out the hardware differences between various Macs is with Mactracker. http://mactracker.ca/ --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: awakeFromInsert called twice with nested contexts
On Nov 16, 2011, at 6:16 PM, Tom Harrington wrote: I'm finding that if I use nested managed object contexts, awakeFromInsert will be called twice on new objects. On Mac OS X 10.7 NSManagedObjectContext can have a parentContext. Perhaps this would be applicable. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Retained Outlet
The normal pattern for Interface Builder Outlets is assign but I have an outlet that must be retained to work corectly. The outlet is not in File's Owner but is in a custom view in a window. // Interface @property (retain) IBOutlet NSArrayController *myController; // Implementation @synthesize myController = _myController The application runs fine with no memory leaks reported by Instruments so I assume that the frameworks are releasing myController. Is this ok? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Retained Outlet
On Nov 18, 2011, at 9:31 AM, Kyle Sluder wrote: On Fri, Nov 18, 2011 at 8:23 AM, Richard Somers wrote: The normal pattern for Interface Builder Outlets is assign but I have an outlet that must be retained to work corectly. The outlet is not in File's Owner but is in a custom view in a window. It is very important that you specify whether you're working on iOS or Mac OS X, and whether your outlet points to a top-level object. I am working on Mac OS X. The outlet points to a top-level object. Maybe you can answer your own question by re-reading the Resource Programming Guide: In general, you are responsible for releasing top-level objects in a nib file. But my File's Owner is an instance of NSWindowController so it will release top-level objects for me. The outlet in question is in a custom class and requires a setter with retain semantics. NSWindowController will use this setter for the outlet when loading the nib. Object ownership policy seems a little blurry here. Normally a class will initialize its ivars and then cleanup in dealloc. But the custom class never initializes the outlet. The nib loading machinery initialize the outlet. So that may mean NSWindowController knows that the outlet has retain semantics and will set the outlet to nil when releasing top-level objects. If not then the class should release the outlet in its dealloc method. I am confused, which one is it? Maybe I am looking at this wrong. If a class, any class, has an ivar with retained property semantics, it will be initialized to nil even if the class does not explicitly initialize the ivar. In the class dealloc method it should directly release the ivar regardless. If the ivar points to an object, for what ever reason, it will receive a release message. If the ivar is nil, for what ever reason, a release message will go to nil. Either way it works. It this the correct way to look at this? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Retained Outlet
On Nov 18, 2011, at 12:42 PM, Kyle Sluder wrote: It means that NSWindowController will balance NSNib's extra -retain. It doesn't balance the additional -retain from calling your setter. Consider the following case. The additional -retain from calling setter is not balanced. The outlet is not released in the class dealloc method and no additional retains or releases of the object exist in my code. But Instruments shows no leaks whatsoever. So who or what is releasing the outlet? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Retained Outlet
On Nov 18, 2011, at 1:33 PM, Corbin Dunn wrote: You are probably orphaning (which is a leak), your window controller subclass. Make sure it's dealloc is called; I'm guessing it won't be. This isn't shown in leaks, since it isn't a true leak. Good suggestion. I just checked and the window controller subclass dealloc method is being called. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Retained Outlet
On Nov 18, 2011, at 9:23 AM, Richard Somers wrote: The normal pattern for Interface Builder Outlets is assign but I have an outlet that must be retained to work corectly. The outlet is not in File's Owner but is in a custom view in a window. // Interface @property (retain) IBOutlet NSArrayController *myController; // Implementation @synthesize myController = _myController The application runs fine with no memory leaks reported by Instruments so I assume that the frameworks are releasing myController. SOLVED - Mac OS X Retained Outlet Thanks for everyones comments. Here is what I have learned. The frameworks will not release a retained outlet (assuming top-level objects are handled correctly). You are responsible for releasing it. A retained outlet is considered ownership and so you must release it. If you do not release it, it will be alive in memory even though Instruments may not report it as a leak. For my particular case the outlet was actually a subclass of NSArrayController. Instruments reports the responsible caller as -[NSClassSwapper initWithCoder:]. I am not an expert in leaks but it appears that a reference to the outlet is maintained by the frameworks until the outlet is fully released and so Instruments does not report it as a leak. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Variable window size based on screen resolution
One way would be to subclass NSWindow and override the designated initializer -initWithContentRect:styleMask:backing:defer: method. In the initializer you could query the screen resolution and set the window frame accordingly. --Richard On Nov 14, 2011, at 8:10 AM, Koen van der Drift wrote: Is there a way to a window open in a size relative to the resolution of the screen? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Implementing Full Screen for 10.7 but app should also run on 10.6
Do something like this. - (void)prepareWindowCollectionBehavior { if (MySystemVersion_10_07_OrLater()) { #ifdef MAC_OS_X_VERSION_10_7 NSWindowCollectionBehavior behavior = [_window collectionBehavior]; behavior = behavior | NSWindowCollectionBehaviorFullScreenPrimary; [_window setCollectionBehavior:behavior]; #endif } } --Richard On Nov 14, 2011, at 8:15 AM, Koen van der Drift wrote: I'd like my application to use the full screen feature on 10.7, but the app should also run on 10.6 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: About iVars declaration and property
I find that not having explicit instance variable declarations lets me focus the class interface. I think that focusing on the interface is more helpful in the long run. --Richard On Nov 13, 2011, at 12:16 AM, ico wrote: If so, is it a better approach that just declare the property and let @synthesize to generate the iVars itself. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 does LaunchServices decide which version of an app to open?
This can be very confusing but I think it goes something like this. The default application launched is the version with the highest CFBundleVersion where CFBundleVersion is a monotonically increasing string, comprised of one or more period-separated integers. In the Xcode 4 target summary CFBundleVersion is identified as Build. In the Xcode 4 target summary CFBundleShortVersionString is identified as Version. When a list of multiple versions of an application is presented to the user (right click on document then hover over Open With), the default application is shown first and then the remaining choices are sorted in alphabetical order by application bundle name or file name like this. AppFileName (default) (CFBundleShortVersionString) AppFileName1 (CFBundleShortVersionString) AppFileName2 (CFBundleShortVersionString) AppFileName3 (CFBundleShortVersionString) Note that the CFBundleVersion is not displayed in the list but it does determine which application is the default. Sometimes the user must log out and log back in again for this list to be updated properly after adding or installing another version of the application or after editing the application file name. When I tried it just now on Lion the list did not update properly but also required opening a document a few times by double clicking and then it did finally display properly. So in that respect it appears to be a slight regression for Lion over previous versions of Mac OS X. Multiple versions of the same application can more readily coexist and be distinguished in the file system by the user by appending some type of version identifier to application file name. This can also complement the application list described above which is presented to the user sorted in alphabetical order by the application bundle name or file name. The user of course can also change the default application for a particular document or all documents of that type in the document Get Info window. So as a developer you can help your beta testers out by always properly incrementing the CFBundleVersion and also by appending a version identifier to the application bundle name or file name if you wish. -- Richard On Nov 11, 2011, at 2:12 PM, Eric Wing wrote: I am trying to understand how Mac (I'm running Lion) decides which version to launch. I am puzzled because it doesn't go to the oldest, it doesn't go to the newest, and it doesn't go to the last recently used. (If it is already open, it always goes to the open one which is the only thing I've figured out.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: ObjC's flat and all-exported namespace, help!
On Nov 9, 2011, at 9:36 AM, Andy O'Meara wrote: Well, if you have a serial number/license scheme, copy-protection scheme, crypto, or payment mechanisms that use objC, then realize they're on display for everyone to see. Use functions instead of a class to restrict the amount of information exported. Here is a good article on making your application less vulnerable to attacks. http://unsanity.org/archives/000101.php --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Logging in Xcode 4.2
On Nov 10, 2011, at 9:13 AM, Matt Neuburg wrote: Sometimes it pops up a little way. Sometimes it pops up a long way. Sometimes it fails to pop. Sometimes it pops but when you stop the app it doesn't pop back down. It's non-deterministic programming! Xcode animation! I think they will eventually get it right. No way am I going back to Xcode 3. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Allocating too much memory kills my App rather than returning NULL
On Nov 9, 2011, at 12:46 AM, Greg Parker wrote: Note that Shuttle missions carried ordinary laptops running ordinary operating systems to do the science work other than flying the spacecraft. The scientists couldn't afford Shuttle-grade development costs nor Shuttle-grade development schedules. Just a bit of historical trivia. The HP-41C calculator flew on seven Space Shuttle missions. It could have been used in an emergency to calculate orbit and re-entry information if there were failure of the shuttle main computer systems. http://en.wikipedia.org/wiki/HP-41C Another source indicates that two HP-41C calculators were on board Columbia. One for Center of Gravity and another for Acquisition of Signals. http://hpinspace.wordpress.com/category/hp-41/ The HP-41C price at introduction in 1979 was $295 which is a testament to the wonders of capitalism and the free market. I wonder if the Russians are using any iPhones or iPod touches in their functioning space program? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSArrayController Update Delay
SOLVED On Oct 13, 2011, at 4:55 PM, Mike Abdullah wrote: I'm pretty sure the array controller is observing NSManagedObjectContextObjectsDidChangeNotification to arrange its objects. Normally, this doesn't fire until the end of the runloop. But you can force it to by calling -[NSManagedObjectContext processPendingChanges] Calling processPendingChanges was the key to solving the controller update delay issue. Thanks. Just curious how you came by this knowledge? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSArrayController Selection and Managed Object Context Undo
SOLVED On Oct 6, 2011, at 8:40 AM, Keary Suska wrote: AFAIK you will need to manage selection restoration semantics yourself, and it may not be easy and it may be fragile. Note also that the preserve and avoid empty selection settings will also have an effect. That being said, the approach would be--before adding/deleting outside the controller--to grab the managed object context's undo manager, open an undo group, add selection restoration operations, perform the operation, then close the group. This should cause the undo to restore selection. Of course, this is theory, as I haven't had to actually do it, and more experienced Core Data wranglers may have more to add. I feel like I have been to the North Pole and back with this issue. But this advice proved very valuable in the end. I simply wrote a pair of controller selection methods, one the inverse of the other. The first registers the second method and the second registers the first method with the managed object context's undo manager. All the code was 16 lines long. So far it works very well. On Oct 6, 2011, at 1:16 PM, Quincey Morris wrote: Bind the array controller's selectionIndexes binding to a NSIndexSet property in your data model ... My data is inherently non-ordered. But for ordered collections I think this would work well. Thanks for the comments and suggestions. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSArrayController Update Delay
Consider a NSArrayController in entity mode. When a managed object is inserted into the managed object context the controller's arrangedObjects property is not updated immediately. Calling a controller 'fetch:' immediately after inserting the managed object into the managed object context does not help. The controller's arrangedObjects property is still not updated. Perhaps there is a KVO change notification delay between the time when the managed object is inserted into the managed object context and the time when the controller finds out about the change. Does anyone have any insight into what is going or how to force the NSArrayController's arrangedObjects property to update? Thanks so much. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSArrayController Update Delay
On Oct 13, 2011, at 3:12 PM, Keary Suska wrote: How is this happening? Via code? or Via the NSArrayController (add: or insert:)? In the latter case the docs say, Beginning with Mac OS X v10.4 the result of this method is deferred until the next iteration of the runloop so that the error presentation mechanism can provide feedback as a sheet. I have been inserting objects into the managed object context in code like this. [[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:moc]; Sometime later the array controller's arrangedObjects property will be automatically updated. I have not been using NSArrayController's add: or insert: methods because at one time I was using them, in addition to initWithEntity:insertIntoManagedObjectContext:, and I was getting duplicate objects. Although I tried using both of them together just now (first initWithEntity:insertIntoManagedObjectContext: and then add:) and I am not getting any duplicates. So I am a little confused. Is it normal practice to create a managed object with the designated initializer initWithEntity:insertIntoManagedObjectContext: and also insert the object into the controller using the controller's add: or insert: method? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSTreeController with bindings and core data - still an issue?
On Oct 10, 2011, at 9:05 AM, Koen van der Drift wrote: I'm looking to implement a simple iTunes/Mail like source list in an app, and have been rummaging through the internets for some decent tutorials and sample code. I found some, but they are all a bit outdated. Basically, I want to combine my Core Data model with an NSOutlineView and NSTreeController all connected through bindings. However, I've also come accross some websites (eg http://blog.wilshipley.com/2006/04/pimp-my-code-part-10-whining-about.html or http://www.cocoadev.com/index.pl?NSTreeController) that state that NSTreeController, Core Data and bindings are not really working well together, and I should use the datasource approach. Is this still the case, or has NSTreeController improved over the years and can it be used with bindings without any problems? When Wil Shipley wrote his blog article in April 2006 the API was at the 10.4 Tiger level. Since then NSTreeController has had one method revised and six new methods have been added in the 10.5 Leopard API. The 10.5 release notes also talk about the improvements made to this class. So Apple has been working on the class. Perhaps the bindings also work better. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSArrayController Selection and Managed Object Context Undo
It is very common for Applications to update the selection during undo operations. By default NSArrayController automatically selects objects as they are inserted. This works if objects are added using one of the controller's add or insert methods. If objects are added directly to the controller content object using other means then this mechanism does not work. Take for example a NSArrayController with a managed object context for the content. If one or more objects are added to managed object context as the result of an undo, the controller's selection does not change or update. Is there an easy way to set the controller's selection when an undo operation adds objects back into a managed object context? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Writing a simple vector graphics editor - how to implement?
On Oct 5, 2011, at 1:39 PM, Nick wrote: I have a task to write a simple vector graphics editor, which has a window, a sheet (which can be bigger than the window), and some objects (triangles, rectangles) to be placed on this sheet (and then, edited, e.g. rotated, stretched) by their borders. Apple's Sketch+Accessibility sample code would be a good place to start. http://developer.apple.com/library/mac/#samplecode/Sketch+Accessibility/ Is it correct to implement all the objects as views, that are the subviews of the sheet view? No, that would be the wrong approach. If you study the Sketch sample code it will guide you in the right direction. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSDocument-oriented app and -keydown
On Sep 29, 2011, at 8:42 AM, Nick wrote: how can I get a keydown (and keyup) events in an NSDocument-oriented application for a particular document's window? I'd like to get a control activated/deactivated on the window, depending on whether the specific key is pressed or released. Key events are passed along the responder chain. The document window delegate is in the responder chain and will respond to -keyDown:, -keyUp:, and -flagsChanged: events. You could subclass NSWindowController and make it the delegate of your document window and handle the events there. NSWindowController Class Reference documentation has a nice paragraph on subclassing. http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/Reference/Reference.html Document-Based Applications Overview documentation also has a section on Should I subclass NSWindowController? http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Documents/Tasks/FAQ.html#//apple_ref/doc/uid/2954-1080900 If you need custom handling of modifier keys at the application level or absolutely need all key up events you could subclass NSApplication and override the -sendEvent: method. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Core Data : Undo Delete : Cannot fulfill a fault
On Sep 25, 2011, at 11:13 PM, Jerry Krinock wrote: I'm debugging a corner case wherein undoing a group containing deletion of a managed object causes a Core Data could not fulfill a fault exception on this object. It would help to understand exactly how managed objects are un-deleted. If I delete a managed object, and then save (or if Cocoa autosaves in place) the object is turned into a fault. Normally, Undo is still able to restore the object. As implied by the documentation [1], the restored object is the same object; it has the same address as the original. My guess is that the undo invocation contains dictionaries of deleted object properties which are used during Undo to re-populate the properties of a faulted object. Is that indeed the way it works? (Feel free to improve my wording.) Any ideas how I could be hosing those properties, other than by over-releasing the object? My rough testing of a managed object (no undo grouping) produced the following results. If I delete a managed object it is immediately turned into a fault. The managed object I get back from undo has the same address as the original. The managed object is not deallocated until the managed object context is rolled back or the document is closed. Monitoring a few methods in a document based core data application produces a trace something like this. 1. Create managed object: [NSManagedObject alloc] [NSManagedObject awakeFromInsert] 2. Delete managed object: [NSManagedObject willTurnIntoFault] [NSManagedObject didTurnIntoFault] 3. Save document: nothing 4. Undo deleted managed object: nothing 5. Delete managed object again: [NSManagedObject willTurnIntoFault] [NSManagedObject didTurnIntoFault] 6a. Rollback managed object context: [NSManagedObjectContext rollback]; [NSManagedObject dealloc]; 6b. Or close the document: [NSManagedObject dealloc]; Regarding the contents of the undo and redo stack you could inspect it's contents using something like this. http://parmanoir.com/Inspecting_NSUndoManager's_undo_stack Hope this helps. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Core Data : Undo Delete : Cannot fulfill a fault
On Sep 26, 2011, at 12:34 PM, Jerry Krinock wrote: Note: It looks like we have a private discussion going on here. I'm not sure if that was intentional. Anyhow… Another individual took it private for some reason. As I said, nothing is being fetched at this point. As I said in my other messages, I think that, when undoing object deletion, Core Data somehow un-faults the faulted object by re-populating it with properties it has stored in an argument of an invocation which it had earlier pushed onto the undo stack. Apple's official related sample code for awakeFromFetch is CoreRecipes/Sample Applications/CoreRecipesApp. But this project is broken. DepartmentAndEmployees, last updated in 2007, still works, albeit with several compiler warnings. That's what I always use to test Core Data behavior. Have you looked at Core Data Programming Guide, Troubleshooting Core Data, Fault cannot be fulfilled? This section of the documentation contains some very specific and detailed information regarding this error message. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Symbolic Breakpoints
Is there a secret to getting symbolic breakpoints to work? Set symbolic breakpoint 'keyDown:' (without the quotes) and nothing happens. Set a breakpoint in the gutter and it works fine. I am using Xcode 4.1 with the LLDB debugger. When I try to switch to the GDB debugger Xcode crashes. The project was started from a Xcode 4.0.2 template. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Symbolic Breakpoints
On Sep 21, 2011, at 9:43 AM, Jens Alfke wrote: Is there a secret to getting symbolic breakpoints to work? Set symbolic breakpoint 'keyDown:' (without the quotes) and nothing happens. The name has to be like “-[MyView keyDown:]”, otherwise it’s ambiguous which -keyDown: method you mean — there are dozens of implementations of that in classes in AppKit and your app. If you’re trying to set a breakpoint on any keyDown: call to any class, you can’t do that. Breakpoints are on code, not selectors. That works! So apparently the entire symbol including square brackets and the initial plus or minus indicating instance method versus class method is required for an Objective-C symbolic breakpoint. The Xcode 4 User Guide explicitly states You can specify the symbol as: A method name. For example, pathsMatchingExtensions:. A method of a particular class. For example, [SKTLine drawHandlesInView], people::Person::name(). A function name. For example, _objc_msgForward. So the documentation is apparently wrong or Xcode 4.1 has not caught up to the documentation. After testing various symbols this is what I found. LLDB keyDown: NOTHING [MyView keyDown:] NOTHING -[MyView keyDown:]WORKS GDB keyDown: CRASH [MyView keyDown:] WORKS -[MyView keyDown:]WORKS --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Symbolic Breakpoints
On Sep 21, 2011, at 12:10 PM, Quincey Morris wrote: I'm not seeing this behavior in gdb (with Xcode 4.2). In Xcode 3, if you tried to set a breakpoint on (say) 'keyDown:', Xcode would pop up a sheet listing all the different matching symbols (all the methods in the various classes where 'keyDown:' was defined). You could check any combination, and there was a Set All button to check them all. In Xcode 4, I just tried setting a breakpoint on 'keyDown:' -- just that with no additional punctuation or qualification. If the app isn't running yet, the symbolic breakpoint is just added to the list but isn't resolved yet. When the application runs, I get a set of nested breakpoints, one for each of the definitions, and I can enable or disable each individually. The app does stop at any of the enabled sub-breakpoints. In Xcode 4, I tried setting the same symbolic breakpoint and then running with lldb. This time the breakpoint didn't multi-resolve upon running, and the app didn't stop when a key was pressed. So, it seems like symbolic resolution isn't finished in lldb yet, and there's something else going on your project that's causing the gdb crash. I made a brand new project in Xcode 4.1 and got the same results as before. gdb crashes when just using a method name like 'keyDown:' for the symbolic breakpoint. It would appear that this has been fixed in Xcode 4.2. Also you have accurately described the breakpoint multi-resolve upon running along with the breakpoint list functionality. I would agree that it appears that symbolic resolution is not finished yet in lldb. Another question, is it possible in Xcode 4 to set a symbolic breakpoint on Apple supplied libraries or frameworks? For example in OpenGL Profiler you can set a breakpoint on a specific OpenGL symbol that is provided by an Apple library or framework. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Symbolic Breakpoints
On Sep 21, 2011, at 1:49 PM, Quincey Morris wrote: I made a brand new project in Xcode 4.1 and got the same results as before. gdb crashes when just using a method name like 'keyDown:' for the symbolic breakpoint. It would appear that this has been fixed in Xcode 4.2. Also you have accurately described the breakpoint multi-resolve upon running along with the breakpoint list functionality. I would agree that it appears that symbolic resolution is not finished yet in lldb. Does it crash when you *add* a symbolic breakpoint in gdb, or when you try to use gdb after having set a symbolic breakpoint in lldb? It's certainly possible there's an incompatibility in the saved state information. It does not crash when adding the symbolic breakpoint 'keyDown:' in gdb. It crashes when running. Another question, is it possible in Xcode 4 to set a symbolic breakpoint on Apple supplied libraries or frameworks? For example in OpenGL Profiler you can set a breakpoint on a specific OpenGL symbol that is provided by an Apple library or framework. Yes, you should be able to set a breakpoint on any symbol. Results of Xcode 4.1 symbolic breakpoint testing. lldb will not break on any Apple supplied library symbols. gdb will break on some Apple supplied library symbols but not all. [NSObject alloc]Yes [NSUndoManager alloc] No --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: SDK 10.5 on XCode 4.1
On Sep 15, 2011, at 8:13 AM, Leonardo wrote: I need to build using SDK 10.5. I work on Lion and XCode 4.1 If you need the MacOSX10.5.sdk one way to do this is to make a unix hard link to the sdk included with Xcode 3. To make a hard link use the following commands from the Terminal application. $ cd /Developer/SDKs $ sudo ln -s /Developer3/SDKs/MacOSX10.5.sdk MacOSX10.5.sdk This assumes that the current Xcode 4 is in /Developer and Xcode 3 is in /Developer3. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: SDK 10.5 on XCode 4.1
On Sep 15, 2011, at 10:40 AM, Scott Ribe wrote: Minor nit, that's a symlink, not a hard link. One important difference is that a symlink can cross volume boundaries... Correct. Second important difference is symbolic links may refer to directories which this is. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Responder-Chain question.
On Sep 13, 2011, at 6:01 AM, Motti Shneor wrote: Event Programming guide says: ... It appears that Apple's guidelines are on the safe side, something that will always work. Cocoa Design Patterns by Buck and Yacktman says: It is possible to manually manipulate the Responder Chain to insert other object. The only requirement is that inserted objects be subclasses of NSResponder. and When a view is added to another as a subview, the next responder is set automatically. Therefore, the time to alter the chain is after the view hierarchy has been created. This advice has worked well for me. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: nonatomic vs atomic assign/retain
On Sep 6, 2011, at 9:30 AM, Torsten Curdt wrote: So what should one use e.g. for normal IBOutlets with AppKit? The answer is in the 2010-12-21 revision of the Memory Management Programming Guide. It seems to be missing however from the current 2011-03-24 revision of this document. Here is the quote from the older revision. Memory Management Programming Guide, Memory Management of Nib Objects When a nib file is loaded and outlets established, the nib-loading mechanism always uses accessor methods if they are present (on both Mac OS X and iOS). Therefore, whichever platform you develop for, you should typically declare outlets using the Objective-C declared properties feature. The general form of the declaration should be: @property (attributes) IBOutlet UserInterfaceElementClass *anOutlet; The behavior of outlets depends on the platform (see “Mac OS X” (page 47) and “iOS” (page 48)), so the actual declaration differs: ● For Mac OS X, you should use: @property (assign) IBOutlet UserInterfaceElementClass *anOutlet; ● For iOS, you should use: @property (nonatomic, retain) IBOutlet UIUserInterfaceElementClass *anOutlet; You should then either synthesize the corresponding accessor methods, or implement them according to the declaration, and (in iOS) release the corresponding variable in dealloc. This pattern also works if you use the modern runtime and synthesize the instance variables, so it remains consistent across all situations. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Sample code using the new document model?
On Aug 26, 2011, at 8:55 PM, Jerry Krinock wrote: Yes, I've read those. They're pretty sketchy – mostly copied from NSDocument.h in the 10.7 SDK, which seems to be the most informative document we have at this point. I'm just surprised that, of 733 Sample Code projects available in the Mac Dev Center, none of them use either of these much-touted but quite complicated new features. Have you looked at TextEdit 1.7 (Lion) in the Examples folder? --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Sample code using the new document model?
On Aug 26, 2011, at 8:11 PM, Jerry Krinock wrote: I cannot find any sample code using the new NSDocument features in Lion, such as autosave in place and asynchronous saving. Am I searching incorrectly? Have you checked this out? Mac OS X Lion Release Notes Cocoa Foundation Framework http://developer.apple.com/library/mac/#releasenotes/Cocoa/Foundation.html Mac OS X Lion Release Notes Cocoa Application Framework http://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKit.html The Lion Application Framework release notes discuss the Modernized Document Model, NSDocument Autosaving in Place, NSDocument Autosaving Changes (Section updated since WWDC 2011), Things to Watch For When Enabling NSDocument Autosaving in Place (New since WWDC 2011), NSDocument Asynchronous Saving, NSDocument UI and File Access Serialization, and NSDocument Duplicating. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 does Apple want us to deal with custom elements in Xcode 4, with IBPlugins having been killed?
On Aug 14, 2011, at 12:36 AM, Eli Bach wrote: I wonder what the FinalCutPro and the rest of those apps guys do with all their custom UI. I have often wondered about that question myself. If you look inside the Xcode bundle you will find a single nib file (MainMenu.nib). So it would appear that the entire Xcode UI, except for the main menu, is programmatically constructed. I have taken that to mean that despite what the IB evangelists say, there is nothing wrong with doing a UI in code, custom or otherwise. Am I missing something? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Xcode 3.2.6 on Lion ?
On Jul 23, 2011, at 4:32 PM, Jerry Krinock wrote: The last time I looked at Services, it only allowed you to access the selected (highlighted) text. Is there any way to get and replace the text of an entire document? I don't know. On Jul 23, 2011, at 4:44 PM, Jerry Krinock wrote: Is there any way to get the position of the cursor in the document, for example, if you want to insert some text at the cursor position? I don't know. My scripts start with the current selection. Sorry. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Xcode 3.2.6 on Lion ?
On Jul 23, 2011, at 11:36 AM, Jerry Krinock wrote: That being said, primarily because of the lack of User Scripts support in Xcode 4 which I find intolerable, I'm using Xcode 3.2.5 for my daily work, and of course running Lion. I converted all my user scripts to automator services. It took some time but it works well in Xcode 4. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Lion changes
On Jul 21, 2011, at 11:33 AM, vincent habchi wrote: But anyhow, as somebody pointed out, there are far better ways to get the MAC address of the en0 port than executing BSD commands in a subprocess. Apple sample code GetPrimaryMACAddress works well with Lion. http://developer.apple.com/library/mac/#samplecode/GetPrimaryMACAddress/ --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
User Defaults Controller Binding
I have a binding to the User Defaults Controller in Interface Builder in Xcode 4. The binding entries look like this. Controller Key values Model Key Path MyProperty At the end of the MyProperty entry there is a round dark circle with an exclamation mark. I think this indicates an error. How do I get rid of the round dark circle with the exclamation mark? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Display Letterboxing Pillarboxing
In System Preferences a user may select a specific display resolution. Some display resolutions will stretch the visible area to fill the display as needed. But some display resolutions will pillarbox where a black bar is placed on the left and right of the visible area. Is it possible to programmatically detect when the current display resolution is letterboxing or pillarboxing? The Quartz Display Services Reference does not seem to have any functions that reveal this information. http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Event Objects Return 1-Based Y Coordinate Values
The documentation matches the behavior. Cocoa event objects do indeed return y coordinate values that are 1-based. A mouse click on the bottom left corner of a window or view yields the point (0, 1) in Cocoa and not (0, 0). I recently submitted bug 9639143 on another issue but it has a sample application that readily demonstrates this behavior. You are more than welcome to check this out yourself. Unless I am doing something horribly wrong, as far as I can tell, the documentation does indeed match the behavior so there is certainly very little to be gained in submitting a bug report. If you have not read the documentation I would suggest you do so. It is on page 49 of the Cocoa Drawing Guide under the heading Converting from Window to View Coordinates. The documentation is very clear on this behavior. The only thing that is left unsaid in the documentation is why this unusual behavior exists or what purpose it has. --Richard On Jun 27, 2011, at 11:26 AM, Raleigh Ledet wrote: Cocoa coordinates are all 0,0 based. If you have a reproducible test case that says otherwise, please file a radar and attach it. -raleigh On Jun 25, 2011, at 7:59 AM, Richard Somers wrote: The Cocoa Drawing Guide states Cocoa event objects return y coordinate values that are 1-based instead of 0-based. Thus, a mouse click on the bottom left corner of a window or view would yield the point (0, 1) in Cocoa and not (0, 0). Only y-coordinates are 1-based. Why are the y-coordianate values of Cocoa event objects 1-based? Do most developers simply subtract 1.0 from the y-coordianate value obtained from an event object to make it 0-based before using the x-y-coordinate values? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Event Objects Return 1-Based Y Coordinate Values
On Jun 27, 2011, at 1:13 PM, Jens Alfke wrote: It makes sense to me. Integer coordinates denote the grid lines between pixels, not the pixel centers. Likewise, the hot-spot of the cursor is in between pixels, not in the center of a pixel. In the case of the default arrow cursor, the hot-spot is at the tip of the arrow. Put that together, and what you get is that if the tip pixel of the arrow cursor is positioned over the bottom pixel of the view, the hot-spot is actually at y=1.0. This may seem a little unexpected, but I don’t think most programmers ever worry about it. Hit-testing shouldn’t require single-pixel accuracy anyway, so I doubt the user would notice if your calculations were a pixel off. This seems like a correct interpretation. Thanks for the insight. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Event Objects Return 1-Based Y Coordinate Values
The Cocoa Drawing Guide states Cocoa event objects return y coordinate values that are 1-based instead of 0-based. Thus, a mouse click on the bottom left corner of a window or view would yield the point (0, 1) in Cocoa and not (0, 0). Only y-coordinates are 1-based. Why are the y-coordianate values of Cocoa event objects 1-based? Do most developers simply subtract 1.0 from the y-coordianate value obtained from an event object to make it 0-based before using the x-y-coordinate values? --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Detect shift key down
On Jun 24, 2011, at 1:19 AM, Bernard Desgraupes wrote: I need to detect if the shift key is pressed by the user during the startup of my app. How would I do that in Cocoa (targetting 10.5 and greater) ? Try this. http://www.cocoabuilder.com/archive/cocoa/284356-alternative-startup-for-application.html --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Is it possible to create a Finder-like icon in Dock?
On Jun 12, 2011, at 6:22 PM, Nick wrote: Finder behaves differently... Would it be possible to create a similar icon? Probably not. At least I would hope I would be impossible or at least very difficult for a developer to do this. From a users perspective I don't think I would appreciate a third party application whose Dock icon would behave like Finder. As a user and as a developer I appreciate the consistency that Mac OS X provides. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Controller Selection Synchronization
On Apr 9, 2011, at 18:00, Richard Somers wrote: I have a primary view which displays all objects using a primary controller. Both 'A' and 'B' objects are included in the controller content. This is accomplished by using an abstract class in the managed object model that is a parent of both 'A' and 'B' objects. The primary array controller content is the abstract class, so we get all objects. On Apr 9, 2011, at 10:12 PM, Quincey Morris wrote: Are you talking about selecting rows in a table view or an outline view, or selecting objects in a custom view? The primary view is a custom view that displays objects spatially according to their position in x, y, z coordinate space. The secondary views are table type views. If you're talking about a table/outline view, I'd just use the selection did change delegate methods to propagate selections from one list to another. If not, but the selection is part of the state of a window controller, I'd make a window controller property for each list, and observe those properties, either in the window controller or the individual views. Or, if the selection is to be saved with the data model, I'd put a (probably just one) selection set property in the data model, and use the window controller (for example) as a mediating controller to propagate derived properties to the views. I currently have a transient selection property for each object in the data model which helps in restoring the selection when undoing an object delete. The primary controller (for the custom primary view) is a custom programatic subclass of NSArrayController that synchronizes the primary controller selection with the transient selection property. The secondary controllers (NSArrayController and NSObjectController) and secondary views (table views) are all standard Interface Builder objects. The problem is how to synchronizing the selection among all the various controllers. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Controller Selection Synchronization
I am having trouble wrapping my head around how to approach controller selection synchronization. I have a primary view which displays all objects using a primary controller. Both 'A' and 'B' objects are included in the controller content. This is accomplished by using an abstract class in the managed object model that is a parent of both 'A' and 'B' objects. The primary array controller content is the abstract class, so we get all objects. A secondary view shows all objects of a particular type. The secondary array controller content is connected to a specific object type. The architecture looks something like this. 1. Primary View using PrimaryController : NSArrayController Display 'A' Objects and 'B' Objects 2. Secondary View using AController : NSArrayController Display 'A' Objects Only 3. Secondary View using BController : NSArrayController Display 'B' Objects Only The problem is if the user selects an object in the primary view it also needs to be shown as selected in the appropriate secondary view. Also if the user selects an object in a secondary view it needs to shown as selected in the primary view. Does anyone have any suggestions on how to approach this issue? Thanks in advance for anyone willing to think about this. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSNotFound
On Jan 17, 2011, at 11:50 AM, Quincey Morris wrote: Yes, in one sense the actual value should be irrelevant, but in fact when NSNotFound is a possible value of a scalar that's truly numeric (such as a count or an index) you really *do* need to know what NSNotFound is. For example, you have to be careful not to increment a numeric quantity into NSNotFound. In this kind of situation (e.g. the documentation says returns a NSUInteger value representing the index of the matching item, or NSNotFound if no match is found) the usable value range is really 0 .. NSNotFound-1. That imposes a practical limit on the number of items, which the developer needs to know. In a slightly larger, conceptual sense, this means that unless you want to obsess over the specifics of *every* frameworks parameter *every* time you use one, the *practical*, everyday-use range of NSUInteger is 0 .. NSIntegerMax, not 0 .. NSUIntegerMax. In 32-bit, that's a 2 Gig item limit, not 4 Gigs. I have been implementing some code which interoperates with a NSArrayController subclass. Cognizance of the numeric value of the indexing boundary conditions was a coding requirement. I was almost on the right path but got confused with 32-bit/64-bit and NSInteger/ NSUInteger. Thanks for stating this with such clarity. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
NSNotFound
NSNotFound is formally defined as NSIntegerMax. But the framework methods returning NSNotFound are typically typed NSUInteger. Is there a technical reason why NSNotFound is not defined as NSUIntegerMax? --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: sending a message from an initializer method
On Jan 12, 2011, at 4:41 AM, Luc Van Bogaert wrote: I would like to implement that algorithm in a seperate method, instead of writing it directly in the initializer. Is that OK, and could I then message self in the initializer like: - (id) init { self = [super init]; if (self) { var1 = ...; var2 = ...; var3 = [self computerVar3With:var1:var2]; } return self; } I often will do something like this. - (id)init { self = [super init]; if (self) { [self prepare...]; [self prepare...]; [self prepare...]; // etc... } return self; } The methods 'prepare...' are all private methods. The preparation code for one of my classes is over 300 lines with five individual prepare methods. Breaking it up like this keeps it organized, understandable, and aids in debugging and refactoring. It works very well. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom View with Interface Builder Bindings
On Jan 3, 2011, at 9:27 AM, Richard Somers wrote: I would like to establish bindings in Interface Builder between the objects created by the custom view and some standard Interface Builder widgets. The problem is 'awakeFromNib' is called AFTER the bindings are established so the bindings never work. On Jan 3, 2011, at 1:32 PM, Quincey Morris wrote: If I understand your description correctly, you actually have a bug in your code. At the time 'awakeFromNib' is called, bindings (and therefore KVO observations) already exist on certain properties of your custom view (that is, on the key-paths that represent those properties) -- even though the property values are still nil, though that's not inherently a problem. My original problem consisted of several problems combined. The most obscure one was related to KVO observations as suggested by Quincey. I was trying to bind a NSTextField value property to CALayer subclass property in Interface Builder. But changes in the model were not reflected in the user interface. This is because CALayer’s implementation of automaticallyNotifiesObserversForKey: in 10.5 returns NO for all keys. In 10.6 it works as expected, returning only NO for its own properties. http://rhult.github.com/kvo-problems-with-calayer.html Debugging bindings can be a challenge. In retrospect Apple provided guidance for troubleshooting this specific issue. The 'Troubleshooting Cocoa Bindings' section of 'Cocoa Bindings Programming Topics' states If changes made to a model value programmatically are not being reflected in the user interface ... You should ensure that: The model class has automatic key-value observing enabled or implements manual key-value observing for the property. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Custom View with Interface Builder Bindings
I have a custom view in a Nib. The view programmatically creates a bunch of objects during initialization. These objects depend upon the document managed object context. Currently the objects are created in 'awakeFromNib'. It all works fine. @implementation MyCustomView - (id)initWithFrame:(NSRect)frameRect { self = [super initWithFrame:frameRect]; if (self) { // Currently do nothing here. } return self; } - (void)awakeFromNib { // Create a bunch of objects programmatically which // depend on the document managed object context (which // is reachable at this stage of initialization). } @end I would like to establish bindings in Interface Builder between the objects created by the custom view and some standard Interface Builder widgets. The problem is 'awakeFromNib' is called AFTER the bindings are established so the bindings never work. Nib loading order. 1. Load contents of Nib. 2. Custom view receives 'initWithFrame:'. 3. Establish outlets, action connections, and bindings. 4. Custom view receives 'awakeFromNib'. The problem would be solved if the objects were created in 'initWithFrame:' which happens BEFORE the bindings are established. But I can find no way to obtain the document managed object context in 'initWithFrame:' because the window controller of the view is nil at this stage of initialization. The Nib is loaded by a custom document window controller. The document managed object context is valid before the window controller is even allocated or initialized. But I can find no way to get this information to the custom view. @implementation MyDocument - (void)makeWindowControllers { // document managed object context is valid MyDocumentWindowController *windowController; windowController = [[MyDocumentWindowController alloc] init]; [self addWindowController:windowController]; [windowController release]; } @end Any suggestions? Thanks. --Richard Somers ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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