[MacRuby-devel] NSDocument problems
stephen horne
fatste at gmail.com
Thu Feb 14 17:32:15 PST 2013
I figured out my problem. I had put an object representing the document into the nib where the document was also set as the file's owner, making each document call init twice.
A hard-learned lesson. At least I won't forget it.
On 14/02/2013, at 01:39, stephen horne <fatste at gmail.com> wrote:
> I'm making a document-based application, backed by core data, but I'm having serious issues opening the documents again.
>
> I'm trying to use readFromFileWrapper(wrapper, ofType:type, error:err) in an NSDocument subclass.
>
> Through my logging, it seems that this method is doing what it should, but the document that is displayed is not the object that I query inside that method, as can be seen by the two calls to "puts self" in the snippets below.
>
>
> def readFromFileWrapper(wrapper, ofType:type, error:err)
> url = NSURL.fileURLWithPath(self.fileName).URLByAppendingPathComponent("test.storedata")
> setFileType('SQLite')
> add_persistent_store(url)
> puts crags # This is a method that fetches objects from the sqlite database,
> # and proves to me that the database has been set right. Output below:
> # #<RFCrag_RFCrag_:0x4013323c0>
> # #<RFCrag_RFCrag_:0x4013324c0>
> # #<RFCrag_RFCrag_:0x401332680>
> # #<RFCrag_RFCrag_:0x401334480>
> # #<RFCrag_RFCrag_:0x401334740>
> # #<RFCrag_RFCrag_:0x4013355c0>
> # #<RFCrag_RFCrag_:0x40132f980>
> # #<RFCrag_RFCrag_:0x40132fc80>
>
> puts self # => #<RFDocument:0x40161bfe0> # Correct I think, this is what I expect
> true
> end
>
>
>
> This one is called from a "button_press(sender)" method once the opened document is on-screen, but the tableview is not populated. I would expect this to be an RFDocument also.
>
> def button_press(sender)
> puts self # => #<#<Class:0x40049db20>:0x4013e7680> # Incorrect? Or some funny cocoa-generated subclass maybe?
> end
>
>
>
> I don't know what this object is, but it doesn't have the persistent store set. Although I can then set it by calling a method from a menu that calls the "add_persistent_store(url)" method, and make the document window display the data.
>
> Am I missing something? I've been banging my head against this one for hours now. Any help is greatly appreciated.
> --
> Stephen Horne
>
--
Stephen Horne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20130215/aa85102a/attachment.html>
More information about the MacRuby-devel
mailing list