Re: NSStackView basics
Thanks Ken. I suspected it was something like that but didn't know what to do about it. It also hadn't occurred to me that making the text field centered didn't necessarily imply anything about the size of the containing view. With no constraints on the sizes of contained view, it seems that NSStackView scaled one view down to zero size while scaling the other one up to fill the itself. Neither choice violates any constraints, though it wasn't what I expected. Adding a fixed height constraint to the subviews makes both visible. Likewise, adding other height constraints like setting the equivalent of @V:|-[subview2]- makes both visible (with different sizes). Looking at the demo project, I see now that there are constraints with similar effect, which is why it works. On Mon, Nov 11, 2013 at 6:29 PM, Ken Ferry kenfe...@gmail.com wrote: Hi Tom, I think the problem here is that if you have view A containing textField, and textField is centered in A, there's no constraint expressing anything about A's height. A can go to zero height and still have the textField centered within it. If you added something giving a height (or fastened the edges of A to the textField), that'd probably do it. -ken On Fri, Nov 8, 2013 at 5:02 PM, Tom Harrington atomicb...@gmail.comwrote: I'm trying to use NSStackView in what should be the most basic way possible. I create the stack view and add two subviews. But only one of them is ever visible. I'm creating the stack view in code (in my app delegate, for purposes of a test project): NSStackView *stackView = [NSStackView stackViewWithViews:@ [self.subview1, self.subview2]]; stackView.orientation = NSUserInterfaceLayoutOrientationVertical; stackView.alignment = NSLayoutAttributeCenterX; stackView.spacing = 0; [self.window.contentView addSubview:stackView]; [self.window.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@H:|-(50)-[stackView]-(50)-| options:0 metrics:nil views:NSDictionaryOfVariableBindings(stackView)]]; [self.window.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@V:|-(50)-[stackView]-(50)-| options:0 metrics:nil views:NSDictionaryOfVariableBindings(stackView)]]; The two subviews subview1 and subview2 are just plain NSViews, each with an NSTextField label subview constrained to be in the center. At run time, only one subview is visible-- the last one in the array. It's resized to fill the entire stack view. If I resize the window, the stack view and the one visible subview also resize, but no window size ever gets both subviews showing. Obviously I'm missing something basic about stack views, but I don't know what. I've been looking at Apple's InfoBarStackView demo app but haven't worked out which detail it has that I don't (Apple's demo: https://developer.apple.com/library/mac/samplecode/InfoBarStackView/Introduction/Intro.html ) -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/kenferry%40gmail.com This email sent to kenfe...@gmail.com -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
NSStackView basics
I'm trying to use NSStackView in what should be the most basic way possible. I create the stack view and add two subviews. But only one of them is ever visible. I'm creating the stack view in code (in my app delegate, for purposes of a test project): NSStackView *stackView = [NSStackView stackViewWithViews:@[self.subview1, self.subview2]]; stackView.orientation = NSUserInterfaceLayoutOrientationVertical; stackView.alignment = NSLayoutAttributeCenterX; stackView.spacing = 0; [self.window.contentView addSubview:stackView]; [self.window.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@H:|-(50)-[stackView]-(50)-| options:0 metrics:nil views:NSDictionaryOfVariableBindings(stackView)]]; [self.window.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@V:|-(50)-[stackView]-(50)-| options:0 metrics:nil views:NSDictionaryOfVariableBindings(stackView)]]; The two subviews subview1 and subview2 are just plain NSViews, each with an NSTextField label subview constrained to be in the center. At run time, only one subview is visible-- the last one in the array. It's resized to fill the entire stack view. If I resize the window, the stack view and the one visible subview also resize, but no window size ever gets both subviews showing. Obviously I'm missing something basic about stack views, but I don't know what. I've been looking at Apple's InfoBarStackView demo app but haven't worked out which detail it has that I don't (Apple's demo: https://developer.apple.com/library/mac/samplecode/InfoBarStackView/Introduction/Intro.html ) -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Stale URL bookmarks?
On Tue, Aug 13, 2013 at 10:08 PM, Quincey Morris quinceymor...@rivergatesoftware.com wrote: On Aug 13, 2013, at 19:20 , Tom Harrington atomicb...@gmail.com wrote: What does stale mean in this context? And if the bookmark is stale, what if anything should I do (or not do) in response to that? Stale means that the referenced file could not be found using the explicit information in the bookmark (such as the parent directory and file name), but a plausible alternative *could* be found by assuming information that's either not in the bookmark or that contradicts what's in the bookmark. For example, if the file was renamed, and the bookmark has recorded the file system node number, the original file could be be found via the file number. However, it now has a conflicting name, even though bookmark resolution has decided it's the same file. Now imagine, for example, that the file is accidentally deleted and then restored from a backup, under the newest name. It will likely have a different file number and the original bookmark will now be unresolvable. When you're told that a bookmark is stale, you're being warned that file metadata has changed, and that further metadata changes may break the bookmark. That gives you the opportunity to re-create the bookmark using the latest metadata, rendering the bookmark more tolerant to future metadata changes. You can choose to re-create the bookmark or not. The upside to doing so is that your bookmark may more robustly follow a series of file metadata changes. OTOH you may not want to have your bookmark cling to files that are moved or renamed. Thanks for the detailed explanation, just what I needed. -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Document scope security bookmark, catch 22?
I'm trying to create document scoped security URL bookmarks, for a document format that needs to refer to other documents. But it seems like the first time I save a document, there's a catch-22 in creating the bookmarks. Creating a document scoped bookmark requires my document's URL as one of the arguments. If I implement dataOfType:error:, I can't create a document-scope bookmark in my NSDocument subclass because [self fileURL] is nil. I end up creating an app-scoped bookmark instead, though it's not what I want. If I implement writeToURL:ofType:error:, I get a URL for my document as the first argument. But, I still can't create the bookmark because my document doesn't exist yet. I get an error reading 'The file “[name]” couldn’t be opened because there is no such file'. So, when am I supposed to create these bookmarks? Do I need to have the user save an empty document first just so I can create these bookmarks the next time around? -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Stale URL bookmarks?
When resolving a URL bookmark, one of the options is a BOOL * that on return tells you if the bookmark data is stale. What does stale mean in this context? And if the bookmark is stale, what if anything should I do (or not do) in response to that? -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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 ignoring validation constraint
I have a data model where one of the string attributes has both a min and max length validation requirement. At run time though, only the max length constraint seems to exist. Violating the min length constraint doesn't cause validation failures, whether using -validateForInsert: or -validateValue:forKey:error: For example: NSString *tooShortName = @a; NSError *validationError = nil; [category validateValue:tooShortName forKey:@name error:validationError]; At this point validationError is still nil. Continuing: [category setValue:tooShortName forKey:@name]; [category validateForInsert:validationError]; ...still nil. I suspected that the data model GUI might be lying to me so I looked at the model file directly (glad it's XML) and found this for the attribute: attribute name=name attributeType=String minValueString=10 maxValueString=100 syncable=YES/ So, both constraints are in the model file. They don't both get loaded at run time though: (gdb) po category entity] attributesByName] objectForKey:@name] validationPredicates] __NSArrayM 0x897bcd0( length = 100 ) I tried creating a new project to test this and got the same thing immediately. Is there some additional step I've missed? I'm using Xcode 4.2.1 on Mac OS X 10.7.2; results are the same in the simulator and on an iPhone 4s running iOS 5.0.1. -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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 Sat, Nov 19, 2011 at 6:49 PM, Roland King r...@rols.org wrote: On Nov 20, 2011, at 5:48 AM, Jerry Krinock wrote: On 2011 Nov 16, at 17:16, Tom Harrington wrote: I'm finding that if I use nested managed object contexts, awakeFromInsert will be called twice on new objects. I'm wondering if this is a Core Data bug or a documentation bug. I'd say it's a pretty serious Core Data bug. I've not had an occasion to use nested managed object contexts yet, but I put things in -awakeFromInsert that I only want to happen once. It's certainly not explicitly documented, however a quick scan of the iOS forums finds another 3 developers who've discovered the same thing. Is it really the same object however? It can't be, right, they have different addresses, so Core Data is arguably doing what the documentation says, it's calling awakeFromInsert only once in the object's lifetime, you just have two objects, one in each context. Actually I don't, so far as I can tell. As I mentioned in my previous message, I get the same managed object ID both times. I haven't checked the address, but surely if they were different objects they wouldn't have the same ID. What does the object look like when you get the second call? Has Core Data literally just created it in the second MOC and is calling awakeFromInsert on it before (I assume) populating the data on it from the original, or is it already a clone of the first, with properties and relationships set on it? If the former that seems not too inconsistent, new object in new store gets called to set up defaults before the properties you set on it are cloned over, if the second case, that's much harder to deal with (and sounds like a bug) The object appears the same both times-- a new object with no properties or relationships set. -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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 Sun, Nov 20, 2011 at 2:34 PM, Richard Somers rsomers.li...@infowest.com wrote: 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. That is specifically what I meant when I mentioned nested contexts-- one context whose parent context is another context. -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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 Sun, Nov 27, 2011 at 6:09 PM, Quincey Morris quinceymor...@rivergatesoftware.com wrote: On Nov 27, 2011, at 16:49 , Tom Harrington wrote: Actually I don't, so far as I can tell. As I mentioned in my previous message, I get the same managed object ID both times. I haven't checked the address, but surely if they were different objects they wouldn't have the same ID. You're wrong about that. Different objects will of course have different pointers, but that's the most you can say. The object, and hence the object pointer, is specific to a managed object context. The object ID is an attribute of the persistent store, and is independent of the MOC. If they're different objects then I'm getting duplicates, which is at least as much of a bug and possibly more so. What I observe is that if I add 10 objects, I get 20 calls to awakeFromInsert, 10 for the child context and 10 for the parent. But, there are only 10 unique managed object IDs. It might be that I just happen to be getting the same IDs for two completely different sets of objects, but there shouldn't be two sets in the first place. -- Tom Harrington atomicb...@gmail.com AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: [Moderator] List Guidelines - Must Read
On Fri, Jun 27, 2008 at 12:01 AM, Jens Alfke [EMAIL PROTECTED] wrote: On 26 Jun '08, at 11:36 AM, Hamish Allan wrote: What we really need is for the cocoa-dev list admin page to require new subscribers to type in the phrase I will not make posts about the iPhone or Snow Leopard :) No, you've bought into the whole reality distortion field. What we _really_ need is for Apple to allow developer discussion of NDA'ed products. If there were an *Ph*n* mailing list on this server, and if that list were mentioned in the SDK or on the *Ph*n* developer home page, people would see it and go there to post. The list could be set up to require ADC membership to subscribe, so as to preserve the airtight confidentiality of all details of the *Ph*n* SDK. Oh, they do allow it, despite what the moderators here say. You just have to use the appropriate Apple forum. Apple's support forums have a developer section with no shortage of iPhone discussion. Apple hosts it and nobody seems to mind. See http://discussions.apple.com/category.jspa?categoryID=164 for the forum. It seems kind of silly that iPhone discussion is forbidden here when Apple's apparently not concerned with hosting the discussions elsewhere, but hey, what do I know about it. -- Tom Harrington [EMAIL PROTECTED] AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSURLConnection doesn't post
On Thu, Apr 10, 2008 at 6:27 AM, Micha Fuhrmann [EMAIL PROTECTED] wrote: Now if I place a button on my interface and call test everything is fine, the post is submitted and the delegate method is called. Suffice I call the test method from another class and nothing gets posted (break points show me the sendLogs method is indeed called), the didReceiveData method is not called either. I've looked into adding the NSURLConnection into an array so it wouldn't be scraped, created a separate send class just for the post etc. to no avail, I really don't know what I'm doing wrong. When you call -sendLogs from another class, does the run loop have the chance to run, or does the code block, or busy-wait, or something else that might prevent it from running? You'll need a working run loop for NSURLConnection to successfully post the data and call its delegate methods. Also, is it possible that when -sendLogs is called from another class, it's also called from a separate thread? NSURLConnection's delegate methods are called on the same thread that initiated the connection, and if you've started a different thread, you have to create your own run loop. -- Tom Harrington [EMAIL PROTECTED] AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: System Preferences window is wider in Leopard? How do you make a Tiger compatible UI?
On Wed, Apr 9, 2008 at 11:06 AM, Dave Camp [EMAIL PROTECTED] wrote: After designing the UI for a new System Preferences pane I've discovered that the window size in Leopard is 75 pixels wider than it was in Tiger or earlier OS releases. The net result appears to be that my shiny new UI is clipped on the right side in Tiger. Ugh. I've sent feedback that the docs are incorrect here and need to be updated... In the mean time, what is the correct way to handle this? From what I've read on the net adding springs in IB doesn't help. Would it be safe for me to resize the preferences window to be 75 pixels wider on Tiger while my pane is visible (and size it back down when my pane is deselected)? Probably not a good idea. Although the window width differs from Tiger to Leopard, it's not supposed to be a resizable window. If you're going to run on Tiger you'll need to live with the narrower window. I was pretty annoyed when I found out that Leopard's System Preferences wouldn't resize the pref pane view, even if you had designed it to be resizable. But that's the way it is. Do I have to make my UI narrower and have an obnoxious amount of dead space around the edges on Leopard? Maybe. You can find out what the current window width is once your preference pane has been loaded into the window. Using something like [[[self mainView] superview] frame] would give you the current width, and if desired you could adjust mainView's frame appropriately. This would mean designing to Tiger's pref pane width, and then expanding when running on Leopard. Best to stick with looking up the size instead of the OS version, because who knows what might happen in 10.6? -- Tom Harrington [EMAIL PROTECTED] AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Adding commandline batch mode to Cocoa app
On Sat, Mar 22, 2008 at 4:26 PM, Carsten [EMAIL PROTECTED] wrote: However, image processing apps can benefit from batch modes, and although some things can be nicely handled by an in-app batch manager, the ideal would be to also allow the application to be run from the commandline, as a traditional unix utility. Given the .app bundle format of Cocoa apps, I don't quite see how I would do this. In main(), I have added an if contingent on the existence of commandline parameters (which can be refined in case Mac OS X uses these to launch drag-n-drop scenarios, something which I don't know yet), which doesn't load the GUI in case the app has been launched in commandline batch mode, but the executable is deep inside the .app bundle... What is the traditional Mac OS X/Cocoa way of handling such a scenario, or is it simply not do it like this, and to force the user to use an in-app batch manager? You could just use the executable in the .app bundle, though it would lead to some very long command lines. For example you can run TextEdit with /Applications/TextEdit.app/Contents/MacOS/TextEdit. One approach that some apps take is to have a separate command-line tool which could be installed in /usr/local/bin or some other more normal-seeming place. With this approach you'd probably have a regular drag-install app bundle with a menu item to optionally install the command-line tool. Depending on your architecture the command-line tool could be as simple as a symbolic link to the main bundle's binary. Depending on your requirements, you might consider whether the batch-mode processing would be better implemented as an Automator action. -- Tom Harrington [EMAIL PROTECTED] AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: File upload with NSURLRequest fails
On Fri, Mar 14, 2008 at 12:43 AM, Ben Lachman [EMAIL PROTECTED] wrote: I do this with a perl script on the back end. My experience was that its was more cajoling the perl script into working that the PHP side, but that may be because I'm not much of a perl wizard (maybe only level 8 or so :-). I found it was important to declare a filename if you're transferring data like this. After much close looking, someone told me to count the dashes. Turns out I was using the wrong number for my multipart boundaries. The actual boundaries need to have two more dashes than the boundary declaration in the content-type header. Once I fixed that, my code worked. -- Tom Harrington [EMAIL PROTECTED] AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: File upload with NSURLRequest fails
On Thu, Mar 13, 2008 at 2:50 PM, Tom Harrington [EMAIL PROTECTED] wrote: [postBody appendData:[[NSString stringWithString:@Content-Type: null\r\n\r\n] dataUsingEncoding:NSUTF8StringEncoding]]; Someone asked about this. FYI, null is what the other clients use, but if I use image/jpeg it fails in exactly the same way. -- Tom Harrington [EMAIL PROTECTED] AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: File upload with NSURLRequest fails
Also, for what it's worth, I can hit the server just fine at the command line with: curl -F [EMAIL PROTECTED];filename=7195554321_1_20080311132327_jpg http://server:8080/php/post.php ...yet for some reason the NSURLRequest approach fails. Any/all tips are welcome. On Thu, Mar 13, 2008 at 3:02 PM, Tom Harrington [EMAIL PROTECTED] wrote: On Thu, Mar 13, 2008 at 2:50 PM, Tom Harrington [EMAIL PROTECTED] wrote: [postBody appendData:[[NSString stringWithString:@Content-Type: null\r\n\r\n] dataUsingEncoding:NSUTF8StringEncoding]]; Someone asked about this. FYI, null is what the other clients use, but if I use image/jpeg it fails in exactly the same way. -- Tom Harrington [EMAIL PROTECTED] AIM: atomicbird1 -- Tom Harrington [EMAIL PROTECTED] AIM: atomicbird1 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]