Core Data : Opt Out of SQLite WAL is nullified after File > Duplicate ?
In a post today in the Developer Forums [1], developer Romain Piveteau mentioned in discussing another topic that, in a Core Data app, he “can not disable journaling mode” (by which I presume he means that setting the journaling mode to the legacy “rollback” mode [2] is ineffective) when the user duplicates the document. Since I've occasionally seen -shm and -wal files in testing my Core Data app recently, I tested his assertion and have apparently verified it. My app has opted to use the legacy “rollback” mode, and it does not ordinarily produce -shm nor -wal files. However, when I click in the menu: File > Duplicate, I get not one but three new files, including -shm and -wal files. They disappear when the document is closed and reopened, but the -shm file immediately reappears. Seems like a bug. Has anyone else looked into this yet? Thank, Jerry 1. https://devforums.apple.com/message/935226#935226 2. For Core Data apps linked with the Mac OS X 10.9, iOS 7 or later SDK, by default, SQLite stores use SQLite’s newer “write ahead log” journal mode instead of the old “rollback” journal mode. This is problematic for older Mac apps whose users expect that an unpackaged document (SQLite) file is moveable and copiable. More info, including how to opt out to the old “rollback” mode, is given here: https://developer.apple.com/library/ios/releasenotes/DataManagement/WhatsNew_CoreData_iOS/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
System fonts on iOS 7
I am trying to display font information on the user interface of my application, and have come across some hidden fonts that are obviously there in the system, but not listed in the UIFont familyNames. This can happen when the user has pasted rich text into my application and it is in a hidden system font. And I know at least some of where this comes from - for example, when I use UIFont systemFontOfSize:, the font name is ".HelveticaNeueInterface-M3” and the family name is ".Helvetica Neue Interface”. When I use [UIFont familyNames] there is nothing named ".Helvetica Neue Interface”, although there is "Helvetica Neue”. My conclusion is that this is somehow a hidden font. I have a list of all the fonts as returned by UIFont, and want to put a checkmark beside the font the user is using in the text. But of course, the hidden system fonts are not in the list, so what am I supposed to do to indicate as the selected font? We have the seemingly impossible situation where the text is drawn in a font face that is not in the list returned by [UIFont familyNames]. By looking at the UIFont preferredFontForTextStyle: return values, I can see that there are at least the following hidden fonts: ".HelveticaNeueInterface-M3” ".HelveticaNeueInterface-MediumP4” ".HelveticaNeueInterface-Bold” I wondered about using the font descriptors to turn it into a font that actually exists as far as the user is concerned, but asking for the font’s font descriptor for ".HelveticaNeueInterface-M3” and then asking for matching font descriptors only gave me a font name of ".AppleSystemUIFont”, and of course if I pass that into fontWithName, it returns the ".HelveticaNeueInterface-M3”, so that just took me in a circle back to where I started. I’m thinking that when someone pastes text into my application, I could perhaps have a check in my code that the font is in the list returned by UIFont, and if not, I could probably have a lookup for the known system hidden fonts and replace them with suitable visible alternatives, and for anything unknown, I could have a fallback to a known font. It all seems a bit messy, so any feedback would be welcome. Thanks Gideon ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: System fonts on iOS 7
On Jan 18, 2014, at 5:58 PM, Gideon King wrote: > We have the seemingly impossible situation where the text is drawn in a font > face that is not in the list returned by [UIFont familyNames]. Fonts with names prefixed with a "." or "%" are hidden from the higher-level APIs for listing fonts. It's been that way since the dawn of time (i.e. since the original Mac in 1984.) I'm not sure why iOS 7 has a separate hidden copy of Helvetica Neue that's used for the UI, though. If you want to look up these fonts, you'll probably need to drop down to the CoreText API. But in general, I think it's fine to just not check any font name in your UI in this situation. —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Binding not setting model property
I have a model object with a codeURL property which is readwrite and is an NSURL. I have an NSTextField in the NSView subclass with the value bound to the codeURL property with a custom transform which turns a URL into a string (and deals with nil and another edge case). The transform is reversible, returns YES for allowsReverseTransform and has an implemented reverseTransformedValue: method. There's a browse button on the UI which lets the user select a file and then sets the stringValue: property of the NSTextField to the url.path of the file selected. What I expected is that setting the stringValue would invoke the transformer in the reverse direction and set the codeURL property to the reverse transformed value, thus binding the codeURL property in both directions. What actually happens is nothing. The transformer reverse method isn't called and the codeURL isn't changed. It works in the forward but not the reverse direction. I have a checkbox similarly bound (with no transform) and that works fine both ways. This is my first foray into bindings .. what could I be doing wrong? Do I need to express a simple NSString property on the model object and bind that instead and do the NSString/NSURL conversion there? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Binding not setting model property
... and I tried expressing the URL as an NSString property too, with no transform. Similarly calling [ textField setStringValue: ] didn't cause the setter in the model object to be invoked. That surprised me, I thought binding an NSTextField to an NSString in the model object would be a very simple use case, set the value in the NSTextField, it would change the value in the model object. So is it possibly because I'm setting the value in code into the NSTextField (using setStringValue or setValue: forKey:@"stringValue") instead of a user-interaction version of it where the text is changed via the user typing something in? That would seem a strange distinction. I must be missing something simple. I changed the code so that the browse button changes the URL property on the model object directly and the text field just updates as a result of the underlying URL updating in the model object, but that seems wrong, I feel I should be able to just change the text on the NSTextField and that would trigger the binding to transform the value and eventually set the URL, a perfect disconnect between view and model-controller. On 19 Jan, 2014, at 10:41 am, Roland King wrote: > I have a model object with a codeURL property which is readwrite and is an > NSURL. > > I have an NSTextField in the NSView subclass with the value bound to the > codeURL property with a custom transform which turns a URL into a string (and > deals with nil and another edge case). > > The transform is reversible, returns YES for allowsReverseTransform and has > an implemented reverseTransformedValue: method. > > There's a browse button on the UI which lets the user select a file and then > sets the stringValue: property of the NSTextField to the url.path of the file > selected. > > What I expected is that setting the stringValue would invoke the transformer > in the reverse direction and set the codeURL property to the reverse > transformed value, thus binding the codeURL property in both directions. > > What actually happens is nothing. The transformer reverse method isn't called > and the codeURL isn't changed. It works in the forward but not the reverse > direction. I have a checkbox similarly bound (with no transform) and that > works fine both ways. > > This is my first foray into bindings .. what could I be doing wrong? Do I > need to express a simple NSString property on the model object and bind that > instead and do the NSString/NSURL conversion there? > > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org > > This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Binding not setting model property
How are you setting up the binding? Normally you bind to the value property of the NSTextField (not stringValue). See Cocoa Bindings Reference (NSTextField Bindings). On Jan 18, 2014, at 9:41 PM, Roland King wrote: > I have a model object with a codeURL property which is readwrite and is an > NSURL. > > I have an NSTextField in the NSView subclass with the value bound to the > codeURL property with a custom transform which turns a URL into a string (and > deals with nil and another edge case). > > The transform is reversible, returns YES for allowsReverseTransform and has > an implemented reverseTransformedValue: method. > > There's a browse button on the UI which lets the user select a file and then > sets the stringValue: property of the NSTextField to the url.path of the file > selected. > > What I expected is that setting the stringValue would invoke the transformer > in the reverse direction and set the codeURL property to the reverse > transformed value, thus binding the codeURL property in both directions. > > What actually happens is nothing. The transformer reverse method isn't called > and the codeURL isn't changed. It works in the forward but not the reverse > direction. I have a checkbox similarly bound (with no transform) and that > works fine both ways. > > This is my first foray into bindings .. what could I be doing wrong? Do I > need to express a simple NSString property on the model object and bind that > instead and do the NSString/NSURL conversion there? > > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca > > This email sent to dave.fernan...@utoronto.ca ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: System fonts on iOS 7
Ah, interesting to know that, thanks Jens. Yes, I guess I could leave it unchecked. But also my files are used cross-platform, so I would prefer to store font information for standard fonts, so will probably do the translation to standard fonts during pasting anyway. Regards Gideon > Fonts with names prefixed with a "." or "%" are hidden from the higher-level > APIs for listing fonts. It's been that way since the dawn of time (i.e. since > the original Mac in 1984.) I'm not sure why iOS 7 has a separate hidden copy > of Helvetica Neue that's used for the UI, though. > > If you want to look up these fonts, you'll probably need to drop down to the > CoreText API. But in general, I think it's fine to just not check any font > name in your UI in this situation. > > —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Binding not setting model property
Yes I've bound to the value property in IB. That gets the value from the model object into my NSTextField perfectly via the transformer. It reads the underlying NSURL property which it's bound to, applies the transformer, and sets the text into the NSTextField (presumably by setting the stringValue property). So perhaps the question is .. what property do I need to set on the NSTextField to get it to go back the other way? I've tried [ textField setValue:.. ] but that just throws an exception that setValue: isn't implemented on NSTextField, which it isn't, so I went back to setStringValue: But setting stringValue: changes the on-screen string, but doesn't trigger the binding to send the string back the other way. That was one point of confusion for me right at the start. IB binds the 'value' property but as far as I could tell, NSTextField doesn't have such a property, calling 'value' or 'valueForKey:@"value"' on it just raises as exception, so I assumed bindings was doing something clever under the hood to know that the value binding for an NSTextField actually means stringValue;, or possibly it's using another method entirely which isn't called by setStringValue:. The checkbox property I have works fine in both directions, but that's triggered by an actual mouse click which made me wonder if there's something more I have to do when setting programatically to trigger bindings to work. On 19 Jan, 2014, at 11:21 am, Dave Fernandes wrote: > How are you setting up the binding? Normally you bind to the value property > of the NSTextField (not stringValue). See Cocoa Bindings Reference > (NSTextField Bindings). > > On Jan 18, 2014, at 9:41 PM, Roland King wrote: > >> I have a model object with a codeURL property which is readwrite and is an >> NSURL. >> >> I have an NSTextField in the NSView subclass with the value bound to the >> codeURL property with a custom transform which turns a URL into a string >> (and deals with nil and another edge case). >> >> The transform is reversible, returns YES for allowsReverseTransform and has >> an implemented reverseTransformedValue: method. >> >> There's a browse button on the UI which lets the user select a file and then >> sets the stringValue: property of the NSTextField to the url.path of the >> file selected. >> >> What I expected is that setting the stringValue would invoke the transformer >> in the reverse direction and set the codeURL property to the reverse >> transformed value, thus binding the codeURL property in both directions. >> >> What actually happens is nothing. The transformer reverse method isn't >> called and the codeURL isn't changed. It works in the forward but not the >> reverse direction. I have a checkbox similarly bound (with no transform) and >> that works fine both ways. >> >> This is my first foray into bindings .. what could I be doing wrong? Do I >> need to express a simple NSString property on the model object and bind that >> instead and do the NSString/NSURL conversion there? >> >> >> >> ___ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca >> >> This email sent to dave.fernan...@utoronto.ca > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Binding not setting model property
.. right so if I actually edit the NSTextField on-screen (it wasn't editable before, I made it so) *THEN* the binding gets called in the way I expected. So it would seem that only a user-initiated change of the value fires the binding in reverse (which is what the example binding code in the Apple docs suggests) but setting the stringValue into the thing directly, doesn't. That's a surprise, I expected that either way of setting the value would result in the binding firing. I can see from the stack trace that the binding code is triggered directly from the textFieldShouldEndEditing: method. In my case the result of an NSOpenPanel, triggered by a browse button, sets the value directly into the NSTextField, it's not the user directly editing it does it. So unless there is a property on the NSTextField I can set which triggers its value binding to fire, or there's a method I can call on it like .. 'fireBindings' looks like I'm going to have to do what I eventually did and set the model property directly in code .. not great, but bindings got me 80% of the way which was good. On 19 Jan, 2014, at 11:45 am, Roland King wrote: > Yes I've bound to the value property in IB. That gets the value from the > model object into my NSTextField perfectly via the transformer. It reads the > underlying NSURL property which it's bound to, applies the transformer, and > sets the text into the NSTextField (presumably by setting the stringValue > property). > > So perhaps the question is .. what property do I need to set on the > NSTextField to get it to go back the other way? I've tried [ textField > setValue:.. ] but that just throws an exception that setValue: isn't > implemented on NSTextField, which it isn't, so I went back to setStringValue: > But setting stringValue: changes the on-screen string, but doesn't trigger > the binding to send the string back the other way. > > That was one point of confusion for me right at the start. IB binds the > 'value' property but as far as I could tell, NSTextField doesn't have such a > property, calling 'value' or 'valueForKey:@"value"' on it just raises as > exception, so I assumed bindings was doing something clever under the hood to > know that the value binding for an NSTextField actually means stringValue;, > or possibly it's using another method entirely which isn't called by > setStringValue:. > > The checkbox property I have works fine in both directions, but that's > triggered by an actual mouse click which made me wonder if there's something > more I have to do when setting programatically to trigger bindings to work. > > On 19 Jan, 2014, at 11:21 am, Dave Fernandes > wrote: > >> How are you setting up the binding? Normally you bind to the value property >> of the NSTextField (not stringValue). See Cocoa Bindings Reference >> (NSTextField Bindings). >> >> On Jan 18, 2014, at 9:41 PM, Roland King wrote: >> >>> I have a model object with a codeURL property which is readwrite and is an >>> NSURL. >>> >>> I have an NSTextField in the NSView subclass with the value bound to the >>> codeURL property with a custom transform which turns a URL into a string >>> (and deals with nil and another edge case). >>> >>> The transform is reversible, returns YES for allowsReverseTransform and has >>> an implemented reverseTransformedValue: method. >>> >>> There's a browse button on the UI which lets the user select a file and >>> then sets the stringValue: property of the NSTextField to the url.path of >>> the file selected. >>> >>> What I expected is that setting the stringValue would invoke the >>> transformer in the reverse direction and set the codeURL property to the >>> reverse transformed value, thus binding the codeURL property in both >>> directions. >>> >>> What actually happens is nothing. The transformer reverse method isn't >>> called and the codeURL isn't changed. It works in the forward but not the >>> reverse direction. I have a checkbox similarly bound (with no transform) >>> and that works fine both ways. >>> >>> This is my first foray into bindings .. what could I be doing wrong? Do I >>> need to express a simple NSString property on the model object and bind >>> that instead and do the NSString/NSURL conversion there? >>> >>> >>> >>> ___ >>> >>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >>> >>> Please do not post admin requests or moderator comments to the list. >>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >>> >>> Help/Unsubscribe/Update your Subscription: >>> https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca >>> >>> This email sent to dave.fernan...@utoronto.ca >> > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev
Re: Binding not setting model property
On Jan 18, 2014, at 19:45 , Roland King wrote: > So perhaps the question is .. what property do I need to set on the > NSTextField to get it to go back the other way? I've tried [ textField > setValue:.. ] but that just throws an exception that setValue: isn't > implemented on NSTextField, which it isn't, so I went back to setStringValue: > But setting stringValue: changes the on-screen string, but doesn't trigger > the binding to send the string back the other way. I think you need to setObjectValue, not setStringValue. “objectValue” is the underlying property that all controls have, from which “intValue”, “stringValue” etc are derived, so presumably the text field “value” binding is bound to “objectValue”. Alternatively, don’t use ‘set’ on the text field at all, but let the Browse button action method update the *data model*, and then let the binding change the text field. This may seem weird, because the button action method would have to apply the reverse transformer itself, but it’s actually cleaner, because it doesn’t make the button behavior depend on the text field. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Binding not setting model property
On 19 Jan, 2014, at 12:25 pm, Quincey Morris wrote: > On Jan 18, 2014, at 19:45 , Roland King wrote: > >> So perhaps the question is .. what property do I need to set on the >> NSTextField to get it to go back the other way? I've tried [ textField >> setValue:.. ] but that just throws an exception that setValue: isn't >> implemented on NSTextField, which it isn't, so I went back to >> setStringValue: But setting stringValue: changes the on-screen string, but >> doesn't trigger the binding to send the string back the other way. > > I think you need to setObjectValue, not setStringValue. “objectValue” is the > underlying property that all controls have, from which “intValue”, > “stringValue” etc are derived, so presumably the text field “value” binding > is bound to “objectValue”. > 'twas a good thought, and a very easy test too, but still didn't work unfortunately. Really does look like the binding code only fires for at the end of ..didFinishEditing: and not for any programatic set of any property on the object, at least not one I've been able to find. > Alternatively, don’t use ‘set’ on the text field at all, but let > the Browse button action method update the *data model*, and then let the > binding change the text field. This may seem weird, because the button action > method would have to apply the reverse transformer itself, but it’s actually > cleaner, because it doesn’t make the button behavior depend on the text field. > That's what I eventually did. It's cleaner because the Browse button (and NSOpenPanel) produce an NSURL anyway, which I set right onto the model and that then updates the text field with the string value. What I was trying, and failing, to do before would have turned the URL into a String, set that on the text field and have the transformer turn it back into a URL again, which was contorted, but felt like it ought to have worked. The only bad bit about this is I had to make the model object a property of the view so the browse button could set the URL property on it, with bindings alone everything was in IB and the view object implementation had no knowledge of the model object at all, it just set a string path onto itself and the model was supposed to pick it up, except it didn't. But it's not horrid the way it is. Thanks for all the help. I did save a bung load of boilerplate code this way, there are some things I quite like moving from iOS to OSX. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Binding not setting model property
On Jan 18, 2014, at 20:39 , Roland King wrote: > Really does look like the binding code only fires for at the end of > ..didFinishEditing: and not for any programatic set of any property on the > object, at least not one I've been able to find. That actually makes a lot of sense. It’s quite possible to change the text field *while typing is happening*, and that doesn’t end editing — and shouldn't. > The only bad bit about this is I had to make the model object a property of > the view so the browse button could set the URL property on it, with bindings > alone everything was in IB and the view object implementation had no > knowledge of the model object at all, it just set a string path onto itself > and the model was supposed to pick it up, except it didn't. I’d say it’s not bad in the way you mean. There’s nothing “bad” in views knowing about model properties. In MVC, it’s explicitly envisaged that the controller would tell the view where to find the data model. In practice, I never do it that way any more. I always create a derived property on the view or window controller that’s based on the data model property. So, from the views’ point of view, the view/window controller *is* the data model, but it’s insulated from the real data model. (Specifically, doesn’t have to #import the data model header files, which has housekeeping benefits.) The cost is writing a trivial getter and setter, and a ‘keyPathsForValuesAffecting…’ method in the controller. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
iOS 7 downloadable fonts
Hi, I am trying to use CTFontDescriptorMatchFontDescriptorsWithProgressHandler to download a font. It appears to download fine, and I can display it in my application. [UIFont familyNames] includes that font. I restart my application, and [UIFont familyNames] does not include the downloaded font, and I can’t create the font using fontWithName:size:. I have tested this on both my iPad and the simulator, and it always forgets the downloaded font on restart of the application. On the simulator, if I go to Library/Assets/com_apple_MobileAsset_Font I can see the folder with the downloaded font in it, and there is a com_apple_MobileAsset_Font.plist file which includes all the information about the downloaded font. So it knows about the font, and the font is really there, but when I try to use it in my application it isn’t there until I download it again during that session. Is there something I am doing wrong? Do I need to initialize something to get it to include the downloaded fonts in the search? Regards Gideon ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Binding not setting model property
> > In practice, I never do it that way any more. I always create a derived > property on the view or window controller that’s based on the data model > property. So, from the views’ point of view, the view/window controller *is* > the data model, but it’s insulated from the real data model. (Specifically, > doesn’t have to #import the data model header files, which has housekeeping > benefits.) > > The cost is writing a trivial getter and setter, and a > ‘keyPathsForValuesAffecting…’ method in the controller. > I've tried really hard to understand this but I'm not quite getting it, sorry, must just be a bit dense today. My model object has a property, codeURL, it's a URL. My view has an NSTextField which is bound to the codeURL via a transformer. All good thus far. The browse button pulls up an NSOpenPanel and the selected URL of that wants to be set back on the codeURL property. Currently I have the model object as a property of the view and in the NSOpenPanel callback I'm doing [ self.modelObject setCodeURL:newURL ]; which sets the URL and the change propagates back to the text view via the binding. That does indeed require importing the model object header. What derived property can I write on the view which removes that dependency? I can write a derived codeURL property on the view quite easily, the setter of which updates the NSTextField, the getter of which uses the NSTextField string, that's a setter/getter and keyPathsForValuesAffecting.. . I can then have the browse button set that property with [ self setCodeURL:newURL ] instead .. but how do I then connect/bind that codeURL property to the real one in the model object? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Binding not setting model property
On Jan 18, 2014, at 22:44 , Roland King wrote: > What derived property can I write on the view which removes that dependency? On Jan 18, 2014, at 20:54 , Quincey Morris wrote: > create a derived property on the view or window controller that’s based on > the data model property Sorry, what I wrote doesn’t perhaps read as intended. I meant: “… create a derived property on the view controller or window controller that’s based on the data model property …” Assuming the view is in a nib file, this allows you to bind the text field to File’s Owner (the view controller or window controller, almost always) with minimal fuss. In my experience, the “data model” that UI elements use is almost always a “transformed” variant of the pure data model (or an amalgamation of several pure data models), and it’s conceptually easier to retain if the entire variant is presented by the controller to the views. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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