iOS Library Reference

The Clutch iOS library syncs up your latest code, helps you analyze usage about your app, and provides a bi-directional bridge between your JavaScript code and your Objective-C code.

ClutchSync

- (void)sync

Intended to be called when the app finishes launching. Syncs to the latest version of the application code.

- (void)foreground

Intended to be called when the app is brought into the foreground. Syncs to the latest version of the application code.

- (void)background

Intended to be called when the app is sent to the background. Performs cleanup and sends statistics information.

+ (ClutchSync *)sharedClientForKey:(NSString *)appKey
                     tunnelURL:(NSString *)tunnelURL
                        rpcURL:(NSString *)rpcURL;

Returns a ClutchSync client instance for the given application key, tunnel URL, and RPC URL.

ClutchView

- (id)initWithFrame:(CGRect)frame andSlug:(NSString *)slug

Initializes a Clutch view instance with the given frame and screen slug.

- (id)callMethod:(NSString *)method withParams:(NSDictionary *)params

Calls a JavaScript method (that has been registered with Clutch) and returns its response. The params dictionary is the parameters you woud like to pass as an argument to the JavaScript function.

- (id)callMethod:(NSString *)method

The same as the previous call except no params.

- (void)viewDidAppear:(BOOL)animated

Should be called when its containing view controller’s viewDidAppear is called.

- (void)viewDidDisappear:(BOOL)animated

Should be called when its containing view controller’s viewDidDisappear is called.

+ (void)logDeviceIdentifier

Logs the current device’s identifier, for use on the add device page.

+ (void)prepareForAnimation:(UIViewController *)viewController success:(void(^)(void))block_

+ (void)prepareForDisplay:(UIViewController *)viewController success:(void(^)(void))block_

Prepares the given view controller subclass for animation or display (such as adding it to a navigation controller) and then calls the given success block.

+ (void)prepareForDisplay:(UIViewController *)viewController;

Prepares the given view controller subclass for display, and does not call any callback.

Properties

id delegate

You may set this property to point to any instance of ClutchViewDelegate and it will allow you to communicate between JavaScript and Objective-C.

id scrollDelegate

You may set this property to any instance of UIScrollViewDelegate, which will send updates for all of the scrolling that happens on the web view.

UIWebView *webView

The underlying webview that is the main workhorse of each ClutchView.

UIScrollView *scrollView

The webview’s scrollview. Useful for being updated as the user scrolls the webview’s contents, as in a pull-to-refresh implementation.

ClutchViewDelegate

- (void)clutchView:(ClutchView *)clutchView
      methodCalled:(NSString *)method
        withParams:(NSDictionary *)params

Called when JavaScript calls the Clutch.Core.callMethod(method, params) method, which is useful for communication between your JavaScript code and your Objective-C code.

- (void)clutchView:(ClutchView *)clutchView
      methodCalled:(NSString *)method
        withParams:(NSDictionary *)params
          callback:(void(^)(id))callback

Similar to the above method, except that this time it provides a callback that you can call. Whatever object you pass to this callback will be sent to your JavaScript callback.

ClutchConf

+ (NSDictionary *)conf

Gets the latest configuration (provided by clutch.plist).

+ (NSInteger)version

Gets the latest version of the configuration.

Contents

Previous topic

JavaScript Library Reference

Next topic

Clutch Command Client

This Page