[Openmcl-devel] interactive nib loading

Gary Byers gb at clozure.com
Wed Jan 30 18:00:09 PST 2008



On Wed, 30 Jan 2008, Osei Poku wrote:

> I could not even get past the first step.  This was the error
>
> ? (make-instance 'ns:ns-nib :with-nib-named #@"/Users/opoku/Work/
> myUI.nib" :bundle +null-ptr+)
> > Error: No applicable method for args:
> >         (#<A Null Foreign Pointer> :WITH-NIB-NAMED #<NS-CONSTANT-
> STRING "/Users/opoku/Work/myUI.nib" (#x192057C0)> :BUNDLE #<A Null
> Foreign Pointer>)
> >         to #<STANDARD-GENERIC-FUNCTION INITIALIZE-INSTANCE
> #x3000401B935F>
> > While executing: #<CCL::STANDARD-KERNEL-METHOD NO-APPLICABLE-METHOD
> (T)>, in process Listener(76).
> > Type :POP to abort, :R for a list of available restarts.
> > Type :? for other options.

If allocating an ObjC instance via an init... method fails (and
returns a NULL pointer, as happened above), it probably doesn't
make a whole lot of sense for the bridge to try to call 
INITIALIZE-INSTANCE on that null pointer.

The #/initWithNibNamed:bundle method on ns:ns-nib wants the
first argument to be a nib name (not a pathname) and the second
argument to be an NSBundle object (or a null pointer, which
denotes the main application bundle.)  If it fails to make
an NSNib out of the arguments supplied, it returns a null
pointer (which, again, we shouldn't call INITIALIZE-INSTANCE
on, unless we want to define an EQL method on INITIALIZE-INSTANCE
of a NULL pointer ... I'd rather not.)


>
>
>
> On Jan 30, 2008, at 5:49 PM, R. Matthew Emerson wrote:
>
>>
>> On Jan 30, 2008, at 3:27 PM, Osei Poku wrote:
>>
>>> This question is likely due to my lack of familiarity with Cocoa/
>>> Objective C API and/or the corresponding openmcl bridge.  But I have
>>> attempted to find help in the documentation to no avail.
>>>
>>> Essentially, I want to create an interface using Interface Builder
>>> save it and then load it interactively at the openmcl repl.  I simply
>>> do not even know which Cocoa function to use to load the nib file.
>>> This is complicated by the fact that the nib file is in the wild
>>> (some
>>> arbitrary path). I am going to go back and read some more about the
>>> interface builder but I would appreciate some help on the
>>> programmatic
>>> end.
>>>
>>> The closest matches to what I want seem to be by using the NSNib or
>>> NSBundle classes to load the nib file however, I am confused as to
>>> what arguments to give the various instantiate function on the lisp
>>> side.
>>
>> You'll probably want to use NSNib for this, since you say that your
>> nib file will be at an arbitrary location.
>>
>> See:
>>
>> http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/chapter_3_section_6.html
>>
>> Something like (untested, probably wrong, etc.)
>>
>> (let* ((nib (make-instance 'ns:ns-nib :with-nib-named #@"path/to/nib"
>> 			   :bundle +null-ptr+))
>>       (top-level-objs +null-ptr+))
>>  (rlet ((p :address top-level-objs))
>>    (#/instantiateNibWithOwner:topLevelObjects: nib owner p))
>>  (#/release nib)
>>  ;; etc., see example in docs cited above about releasing top level
>> objects
>>  ...)
>>
>> Note that the nib file path needs to be an NSString, not a lisp
>> string.
>>
>>
>>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list