Skip to content

Commit 0d2506d

Browse files
authored
Extract classes from Leanplum.h into their own header files (#180)
These help break up the code in more logical chunks
1 parent 4b536ce commit 0d2506d

File tree

9 files changed

+350
-221
lines changed

9 files changed

+350
-221
lines changed

Leanplum-SDK/Classes/Features/Actions/LPActionArg-Internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Mayank Sanganeria on 4/24/18.
66
//
77

8-
#import "LeanplumInternal.h"
8+
#import "LPActionArg.h"
99

1010
@interface LPActionArg ()
1111

Leanplum-SDK/Classes/Internal/LeanplumCompatibility-Internal.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

Leanplum-SDK/Classes/Internal/LeanplumCompatibility.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// Created by Mayank Sanganeria on 4/24/18.
66
//
77

8-
#import "LeanplumCompatibility-Internal.h"
8+
#import "LeanplumInternal.h"
9+
#import "LeanplumCompatibility.h"
910
#import "Constants.h"
1011

1112
@implementation LeanplumCompatibility

Leanplum-SDK/Classes/LPActionArg.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
#import "LPInbox.h"
27+
28+
@interface LPActionArg : NSObject
29+
/**
30+
* @{
31+
* Defines a Leanplum Action Argument
32+
*/
33+
+ (LPActionArg *)argNamed:(NSString *)name withNumber:(NSNumber *)defaultValue;
34+
+ (LPActionArg *)argNamed:(NSString *)name withString:(NSString *)defaultValue;
35+
+ (LPActionArg *)argNamed:(NSString *)name withBool:(BOOL)defaultValue;
36+
+ (LPActionArg *)argNamed:(NSString *)name withFile:(NSString *)defaultValue;
37+
+ (LPActionArg *)argNamed:(NSString *)name withDict:(NSDictionary *)defaultValue;
38+
+ (LPActionArg *)argNamed:(NSString *)name withArray:(NSArray *)defaultValue;
39+
+ (LPActionArg *)argNamed:(NSString *)name withAction:(NSString *)defaultValue;
40+
+ (LPActionArg *)argNamed:(NSString *)name withColor:(UIColor *)defaultValue;
41+
/**@}*/
42+
- (NSString *)name;
43+
- (NSString *)kind;
44+
- (id)defaultValue;
45+
46+
@end
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
@interface LPActionContext : NSObject
28+
29+
- (NSString *)actionName;
30+
31+
- (NSString *)stringNamed:(NSString *)name;
32+
- (NSString *)fileNamed:(NSString *)name;
33+
- (NSNumber *)numberNamed:(NSString *)name;
34+
- (BOOL)boolNamed:(NSString *)name;
35+
- (NSDictionary *)dictionaryNamed:(NSString *)name;
36+
- (NSArray *)arrayNamed:(NSString *)name;
37+
- (UIColor *)colorNamed:(NSString *)name;
38+
- (NSString *)htmlWithTemplateNamed:(NSString *)templateName;
39+
40+
/**
41+
* Runs the action given by the "name" key.
42+
*/
43+
- (void)runActionNamed:(NSString *)name;
44+
45+
/**
46+
* Runs and tracks an event for the action given by the "name" key.
47+
* This will track an event if no action is set.
48+
*/
49+
- (void)runTrackedActionNamed:(NSString *)name;
50+
51+
/**
52+
* Tracks an event in the context of the current message.
53+
*/
54+
- (void)track:(NSString *)event withValue:(double)value andParameters:(NSDictionary *)params;
55+
56+
/**
57+
* Tracks an event in the conext of the current message, with any parent actions prepended to the
58+
* message event name.
59+
*/
60+
- (void)trackMessageEvent:(NSString *)event
61+
withValue:(double)value
62+
andInfo:(NSString *)info
63+
andParameters:(NSDictionary *)params;
64+
65+
/**
66+
* Prevents the currently active message from appearing again in the future.
67+
*/
68+
- (void)muteFutureMessagesOfSameKind;
69+
70+
/**
71+
* Checks if the action context has any missing files that still need to be downloaded.
72+
*/
73+
- (BOOL)hasMissingFiles;
74+
75+
@end

Leanplum-SDK/Classes/LPVar.h

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
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

Comments
 (0)