Starter Step

Traversal API Changes in UISpec

Posted on: August 4, 2009

Over the weekend I made some small changes to the way traversals work in UISpec. As a result the following method names have changed:

  • descendants is now descendant
  • parents is now parent
  • children is now child

Calling these methods return exactly what you would except them to. The method parent finds the parent view, child gets you the first child view, and descendant retrieves the first descendant view. Of course each result is wrapped in a UIQuery object. And if you want all the views and not just the first, call the method all afterward. Here are some examples

//Finds the first child of the
//first UITableViewCell
app.tableViewCell.child;

//Finds the all child views under
//the first UITableViewCell
app.tableViewCell.child.all;

//Touches all the child views under the first UITableView
app.tableView.child.all.touch

//Both of these will find the first child UILabel
//under UITableViewCell
app.tableViewCell.child.label;
[app.tableViewCell.child view:@"UILabel"];

//Both of these will find all the child UILabels
//under UITableViewCell
app.tableViewCell.child.label.all;
[app.tableViewCell.child view:@"UILabel"].all;

//And of course the default way still works the same

//Finds the first descendant UILabel 
//under UITableViewCell
app.tableViewCell.label; 

//Finds all the descendant UILabels
//under UITableViewCell
app.tableViewCell.label.all; 

Also the documentation has been updated to reflect these changes.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


  • Dave: I can tell you're a ruby guy because you forgot the 'return' keyword. Thanks for the tip though!
  • Chandrashekhar H M: Hi, Thanks its working fine in iOS 6 but not in iOS 7.0. Any Suggestion on this.
  • Coeur: To change a rootViewController, without all this TVNavigationController : myNewRoot = [[UIViewController alloc] init]; myNavigationController.view
%d bloggers like this: