ios - "type of expression is ambiguous without more context" - Referencing appDelegate -


i have appdelegate written in obj-c. i'm trying access in new swift class, strange error think misleading, , i'm trying root.

in swift file, i've set breakpoint after:

var appdelegate = uiapplication.sharedapplication().delegate 

if po:

po appdelegate 

i get:

printing description of appdelegate: optional(<appdelegate: 0x7f81a2d1cc40>) 

everything fine.

however, when try to:

po appdelegate.navigationcontroller 

in debug console get:

error: <expr>:1:13: error: type of expression ambiguous without more context 

and navigationcontroller property of appdelegate, declared in original obj-c appdelegate.h file.


here's original question: cannot invoke '...' argument list of type '...'


edit

based on @martin's comment, changed code to:

  var appdelegate = uiapplication.sharedapplication().delegate!   appdelegate.navigationcontroller.popviewcontrollerisanimated(true) 

which brings error:

'uiapplicationdelegate' not have member named 'navigationcontroller' 

however, here's obj-c appdelegate.h:

@interface appdelegate : uiresponder <uiapplicationdelegate>  @property (nonatomic,strong) vunavigationcontroller *navigationcontroller;  @property (nonatomic,strong) uiwindow *window;  @end 

the delegate method of uiapplication declared as

unowned(unsafe) var delegate: uiapplicationdelegate? 

you have cast return value concrete type of application delegate:

let appdelegate = uiapplication.sharedapplication().delegate as! appdelegate 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -