-1

my app has the navController

and at run time I have NSString *propertyName = @"navController";

and I know it is a type of UINavigationController

how can i access to UINavigationController with the string name

I might need to use https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html

ramo
  • 609
  • 2
  • 8
  • 14

2 Answers2

0

Key-Value Coding would help,

UINavigationController *navController = [self valueForKey:@"navController"];
Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
Vignesh
  • 10,205
  • 2
  • 35
  • 73
0

If you want to use runtime you can get the Ivar from whatever class navigationController is apart of by using this:

Ivar var =  class_getInstanceVariable(your class, "navController");

and then with that Ivar you call upon the instance of your class using this method to get the object navController points to

UINavigationController* controller = object_getIvar(instanceofyourclasswithnavcontroller, var)
Otium
  • 1,098
  • 8
  • 20