|
| 1 | + |
| 2 | +// Leanplum.h |
| 3 | +// Leanplum iOS SDK Version 2.0.6 |
| 4 | +// |
| 5 | +// Copyright (c) 2012 Leanplum, Inc. All rights reserved. |
| 6 | +// |
| 7 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 8 | +// or more contributor license agreements. See the NOTICE file |
| 9 | +// distributed with this work for additional information |
| 10 | +// regarding copyright ownership. The ASF licenses this file |
| 11 | +// to you under the Apache License, Version 2.0 (the "License"); |
| 12 | +// you may not use this file except in compliance with the License. |
| 13 | +// You may obtain a copy of the License at |
| 14 | +// |
| 15 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 16 | +// |
| 17 | +// Unless required by applicable law or agreed to in writing, |
| 18 | +// software distributed under the License is distributed on an |
| 19 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 20 | +// KIND, either express or implied. See the License for the |
| 21 | +// specific language governing permissions and limitations |
| 22 | +// under the License. |
| 23 | + |
| 24 | +#import <Foundation/Foundation.h> |
| 25 | +#import <UIKit/UIKit.h> |
| 26 | + |
| 27 | +typedef void (^LeanplumVariablesChangedBlock)(void); |
| 28 | + |
| 29 | +@class LPVar; |
| 30 | + |
| 31 | +/** |
| 32 | + * Receives callbacks for {@link LPVar} |
| 33 | + */ |
| 34 | +@protocol LPVarDelegate <NSObject> |
| 35 | +@optional |
| 36 | +/** |
| 37 | + * For file variables, called when the file is ready. |
| 38 | + */ |
| 39 | +- (void)fileIsReady:(LPVar *)var; |
| 40 | +/** |
| 41 | + * Called when the value of the variable changes. |
| 42 | + */ |
| 43 | +- (void)valueDidChange:(LPVar *)var; |
| 44 | +@end |
| 45 | + |
| 46 | +/** |
| 47 | + * A variable is any part of your application that can change from an experiment. |
| 48 | + * Check out {@link Macros the macros} for defining variables more easily. |
| 49 | + */ |
| 50 | +@interface LPVar : NSObject |
| 51 | +/** |
| 52 | + * @{ |
| 53 | + * Defines a {@link LPVar} |
| 54 | + */ |
| 55 | + |
| 56 | ++ (LPVar *)define:(NSString *)name; |
| 57 | ++ (LPVar *)define:(NSString *)name withInt:(int)defaultValue; |
| 58 | ++ (LPVar *)define:(NSString *)name withFloat:(float)defaultValue; |
| 59 | ++ (LPVar *)define:(NSString *)name withDouble:(double)defaultValue; |
| 60 | ++ (LPVar *)define:(NSString *)name withCGFloat:(CGFloat)cgFloatValue; |
| 61 | ++ (LPVar *)define:(NSString *)name withShort:(short)defaultValue; |
| 62 | ++ (LPVar *)define:(NSString *)name withChar:(char)defaultValue; |
| 63 | ++ (LPVar *)define:(NSString *)name withBool:(BOOL)defaultValue; |
| 64 | ++ (LPVar *)define:(NSString *)name withString:(NSString *)defaultValue; |
| 65 | ++ (LPVar *)define:(NSString *)name withNumber:(NSNumber *)defaultValue; |
| 66 | ++ (LPVar *)define:(NSString *)name withInteger:(NSInteger)defaultValue; |
| 67 | ++ (LPVar *)define:(NSString *)name withLong:(long)defaultValue; |
| 68 | ++ (LPVar *)define:(NSString *)name withLongLong:(long long)defaultValue; |
| 69 | ++ (LPVar *)define:(NSString *)name withUnsignedChar:(unsigned char)defaultValue; |
| 70 | ++ (LPVar *)define:(NSString *)name withUnsignedInt:(unsigned int)defaultValue; |
| 71 | ++ (LPVar *)define:(NSString *)name withUnsignedInteger:(NSUInteger)defaultValue; |
| 72 | ++ (LPVar *)define:(NSString *)name withUnsignedLong:(unsigned long)defaultValue; |
| 73 | ++ (LPVar *)define:(NSString *)name withUnsignedLongLong:(unsigned long long)defaultValue; |
| 74 | ++ (LPVar *)define:(NSString *)name withUnsignedShort:(unsigned short)defaultValue; |
| 75 | ++ (LPVar *)define:(NSString *)name withFile:(NSString *)defaultFilename; |
| 76 | ++ (LPVar *)define:(NSString *)name withDictionary:(NSDictionary *)defaultValue; |
| 77 | ++ (LPVar *)define:(NSString *)name withArray:(NSArray *)defaultValue; |
| 78 | ++ (LPVar *)define:(NSString *)name withColor:(UIColor *)defaultValue; |
| 79 | +/**@}*/ |
| 80 | + |
| 81 | +/** |
| 82 | + * Returns the name of the variable. |
| 83 | + */ |
| 84 | +- (NSString *)name; |
| 85 | + |
| 86 | +/** |
| 87 | + * Returns the components of the variable's name. |
| 88 | + */ |
| 89 | +- (NSArray *)nameComponents; |
| 90 | + |
| 91 | +/** |
| 92 | + * Returns the default value of a variable. |
| 93 | + */ |
| 94 | +- (id)defaultValue; |
| 95 | + |
| 96 | +/** |
| 97 | + * Returns the kind of the variable. |
| 98 | + */ |
| 99 | +- (NSString *)kind; |
| 100 | + |
| 101 | +/** |
| 102 | + * Returns whether the variable has changed since the last time the app was run. |
| 103 | + */ |
| 104 | +- (BOOL)hasChanged; |
| 105 | + |
| 106 | +/** |
| 107 | + * For file variables, called when the file is ready. |
| 108 | + */ |
| 109 | +- (void)onFileReady:(LeanplumVariablesChangedBlock)block; |
| 110 | + |
| 111 | +/** |
| 112 | + * Called when the value of the variable changes. |
| 113 | + */ |
| 114 | +- (void)onValueChanged:(LeanplumVariablesChangedBlock)block; |
| 115 | + |
| 116 | +/** |
| 117 | + * Sets the delegate of the variable in order to use |
| 118 | + * {@link LPVarDelegate::fileIsReady:} and {@link LPVarDelegate::valueDidChange:} |
| 119 | + */ |
| 120 | +- (void)setDelegate:(id <LPVarDelegate>)delegate; |
| 121 | + |
| 122 | +/** |
| 123 | + * @{ |
| 124 | + * Accessess the value(s) of the variable |
| 125 | + */ |
| 126 | +- (id)objectForKey:(NSString *)key; |
| 127 | +- (id)objectAtIndex:(NSUInteger )index; |
| 128 | +- (id)objectForKeyPath:(id)firstComponent, ... NS_REQUIRES_NIL_TERMINATION; |
| 129 | +- (id)objectForKeyPathComponents:(NSArray *)pathComponents; |
| 130 | +- (NSUInteger)count; |
| 131 | + |
| 132 | +- (NSNumber *)numberValue; |
| 133 | +- (NSString *)stringValue; |
| 134 | +- (NSString *)fileValue; |
| 135 | +- (UIImage *)imageValue; |
| 136 | +- (int)intValue; |
| 137 | +- (double)doubleValue; |
| 138 | +- (CGFloat)cgFloatValue; |
| 139 | +- (float)floatValue; |
| 140 | +- (short)shortValue; |
| 141 | +- (BOOL)boolValue; |
| 142 | +- (char)charValue; |
| 143 | +- (long)longValue; |
| 144 | +- (long long)longLongValue; |
| 145 | +- (NSInteger)integerValue; |
| 146 | +- (unsigned char)unsignedCharValue; |
| 147 | +- (unsigned short)unsignedShortValue; |
| 148 | +- (unsigned int)unsignedIntValue; |
| 149 | +- (NSUInteger)unsignedIntegerValue; |
| 150 | +- (unsigned long)unsignedLongValue; |
| 151 | +- (unsigned long long)unsignedLongLongValue; |
| 152 | +- (UIColor *)colorValue; |
| 153 | +/**@}*/ |
| 154 | +@end |
0 commit comments