Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As others have pointed out, what you are asking for is impossible. When you pass a variable to a method, it only sends the value, not the type. Also, the runtime has no knowledge of a variable's type within a method. Any variable type handling is done by the compiler. The runtime can only know the class of an object which a variable holds.</p> <p>As an alternative, if you can change the signature of your method, you could add a parameter which indicates the type of object to create. The calling method still doesn't need to know the exact type of the object, just whether it is a table view controller or not. Here is an example which uses an enumeration to hold the different types.</p> <pre><code>// header enum ViewControllerType { ViewControllerNormal = 0, ViewControllerTableView }; - (void)setupView:(UIViewController **)view ofType:(enum ViewControllerType)type; // implementation - (void)setupView:(UIViewController **)view ofType:(enum ViewControllerType)type { if(!view) { NSLog(@"setupView:ofType: received nil pointer"); return; } switch(type) { case ViewControllerNormal: // create normal UIViewController type break; case ViewControllerTableView: // create UITableViewController type break; default: NSLog(@"setupView:ofType: received unknown type: %i",type); return; } } </code></pre> <p>Used like:</p> <pre><code>UIViewController *view; [creatorObject setupView:&amp;view ofType:ViewControllerNormal]; // or UITableViewController *tableView; [creatorObject setupView:&amp;tableView ofType:ViewControllerTableView]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload