[MacRuby-devel] windowControllerDidLoadNib strangeness

Laurent Sansonetti lsansonetti at apple.com
Fri Nov 26 12:42:44 PST 2010


Hi Tom,

I just created a sample NSDocument-based project, and added a windowControllerDidLoadNib: method to the NSDocument class, calling super as you do, and everything worked as expected.

Could you try that and see if you still see the problem? Also, do you run a 32-bit machine?

Laurent 

On Nov 25, 2010, at 10:07 PM, Tom Jordan wrote:

> Hello,
> 
> I'm encountering some weird behavior when trying to update a view using  
> When I provide windowControllerDidLoadNib a single argument, as shown below (and required by the NSDocument class definition and in every example I've seen),
> Xcode says: `windowControllerDidLoadNib:': wrong number of arguments (1 for 0) (ArgumentError)
> If I don't provide any argument, it says: undefined method `windowControllerDidLoadNib' for #<MyDocument:0x200646660> (NoMethodError)
> I've tried every combination of one or no args for both the method signature and "super" call on the next line, and I can't seem to get any different results.
> This is my first time trying to get persistence going, but I've read a lot about it, and everything else is working well.. it saves and loads, but I can't seem to get this hook 
> working to update the GUI upon loading.  
> 
> 
> class MyDocument < NSDocument
> 
> 	attr_accessor :loadedmodel, :root #outlet to model field of controller
> 	
> 	# Name of nib containing document window
> 	def windowNibName
> 		'MyDocument'
> 	end
> 	
> 	# Document data representation for saving (return NSData)
> 	def dataOfType(type, error:outError)
> 		outError.assign(NSError.errorWithDomain(NSOSStatusErrorDomain, code:-4, userInfo:nil))
> 		NSKeyedArchiver.archivedDataWithRootObject(@root.model)
> 	end
> 
> 	# Read document from data (return non-nil on success)
> 	def readFromData(data, ofType:type, error:outError)
> 		outError.assign(NSError.errorWithDomain(NSOSStatusErrorDomain, code:-4, userInfo:nil))
> 		@loadedmodel = NSKeyedUnarchiver.unarchiveObjectWithData(data)
> 	end
> 
> 	# Return lowercase 'untitled', to comply with HIG
> 	def displayName
> 		fileURL ? super : super.sub(/^[[:upper:]]/) {|s| s.downcase}
> 	end
> 
> 	def windowControllerDidLoadNib(aController) 
> 		super(aController)
> 		@root.model = @loadedmodel
> 		NSLog("model loaded")
> 	end
> 
> end
> 
> Regards, 
>  
>     Tom Jordan 
>     
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101126/005da13b/attachment.html>


More information about the MacRuby-devel mailing list