-
Notifications
You must be signed in to change notification settings - Fork 333
/
SEGUtils.m
673 lines (559 loc) · 21.5 KB
/
SEGUtils.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
//
// SEGUtils.m
//
//
#import "SEGUtils.h"
#import "SEGAnalyticsConfiguration.h"
#import "SEGReachability.h"
#import "SEGAnalytics.h"
#include <sys/sysctl.h>
#if TARGET_OS_IOS && TARGET_OS_MACCATALYST == 0
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
static CTTelephonyNetworkInfo *_telephonyNetworkInfo;
#elif TARGET_OS_OSX
#import <Cocoa/Cocoa.h>
#endif
// BKS: This doesn't appear to be needed anymore. Will investigate.
//NSString *const SEGADClientClass = @"ADClient";
@implementation SEGUtils
+ (NSData *_Nullable)dataFromPlist:(nonnull id)plist
{
NSError *error = nil;
NSData *data = [NSPropertyListSerialization dataWithPropertyList:plist
format:NSPropertyListXMLFormat_v1_0
options:0
error:&error];
if (error) {
SEGLog(@"Unable to serialize data from plist object", error, plist);
}
return data;
}
+ (id _Nullable)plistFromData:(NSData *_Nonnull)data
{
NSError *error = nil;
id plist = [NSPropertyListSerialization propertyListWithData:data
options:0
format:nil
error:&error];
if (error) {
SEGLog(@"Unable to parse plist from data %@", error);
}
return plist;
}
+(id)traverseJSON:(id)object andReplaceWithFilters:(NSDictionary<NSString*, NSString*>*)patterns
{
if ([object isKindOfClass:NSDictionary.class]) {
NSDictionary* dict = object;
NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:dict.count];
for (NSString* key in dict.allKeys) {
newDict[key] = [self traverseJSON:dict[key] andReplaceWithFilters:patterns];
}
return newDict;
}
if ([object isKindOfClass:NSArray.class]) {
NSArray* array = object;
NSMutableArray* newArray = [NSMutableArray arrayWithCapacity:array.count];
for (int i = 0; i < array.count; i++) {
newArray[i] = [self traverseJSON:array[i] andReplaceWithFilters:patterns];
}
return newArray;
}
if ([object isKindOfClass:NSString.class]) {
NSError* error = nil;
NSMutableString* str = [object mutableCopy];
for (NSString* pattern in patterns) {
NSRegularExpression* re = [NSRegularExpression regularExpressionWithPattern:pattern
options:0
error:&error];
if (error) {
@throw error;
}
NSInteger matches = [re replaceMatchesInString:str
options:0
range:NSMakeRange(0, str.length)
withTemplate:patterns[pattern]];
if (matches > 0) {
SEGLog(@"%@ Redacted value from action: %@", self, pattern);
}
}
return str;
}
return object;
}
@end
BOOL isUnitTesting()
{
static dispatch_once_t pred = 0;
static BOOL _isUnitTesting = NO;
dispatch_once(&pred, ^{
NSDictionary *env = [NSProcessInfo processInfo].environment;
_isUnitTesting = (env[@"XCTestConfigurationFilePath"] != nil);
});
return _isUnitTesting;
}
NSString *deviceTokenToString(NSData *deviceToken)
{
if (!deviceToken) return nil;
const unsigned char *buffer = (const unsigned char *)[deviceToken bytes];
if (!buffer) {
return nil;
}
NSMutableString *token = [NSMutableString stringWithCapacity:(deviceToken.length * 2)];
for (NSUInteger i = 0; i < deviceToken.length; i++) {
[token appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)buffer[i]]];
}
return token;
}
NSString *getDeviceModel()
{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char result[size];
sysctlbyname("hw.machine", result, &size, NULL, 0);
NSString *results = [NSString stringWithCString:result encoding:NSUTF8StringEncoding];
return results;
}
BOOL getAdTrackingEnabled(SEGAnalyticsConfiguration *configuration)
{
BOOL result = NO;
if ((configuration.adSupportBlock != nil) && (configuration.enableAdvertisingTracking)) {
result = YES;
}
return result;
}
NSDictionary *getStaticContext(SEGAnalyticsConfiguration *configuration, NSString *deviceToken)
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
dict[@"library"] = @{
@"name" : @"analytics-ios",
@"version" : [SEGAnalytics version]
};
NSMutableDictionary *infoDictionary = [[[NSBundle mainBundle] infoDictionary] mutableCopy];
[infoDictionary addEntriesFromDictionary:[[NSBundle mainBundle] localizedInfoDictionary]];
if (infoDictionary.count) {
dict[@"app"] = @{
@"name" : infoDictionary[@"CFBundleDisplayName"] ?: @"",
@"version" : infoDictionary[@"CFBundleShortVersionString"] ?: @"",
@"build" : infoDictionary[@"CFBundleVersion"] ?: @"",
@"namespace" : [[NSBundle mainBundle] bundleIdentifier] ?: @"",
};
}
NSDictionary *settingsDictionary = nil;
#if TARGET_OS_IPHONE
settingsDictionary = mobileSpecifications(configuration, deviceToken);
#elif TARGET_OS_OSX
settingsDictionary = desktopSpecifications(configuration, deviceToken);
#endif
if (settingsDictionary != nil) {
dict[@"device"] = settingsDictionary[@"device"];
dict[@"os"] = settingsDictionary[@"os"];
dict[@"screen"] = settingsDictionary[@"screen"];
}
return dict;
}
#if TARGET_OS_IPHONE
NSDictionary *mobileSpecifications(SEGAnalyticsConfiguration *configuration, NSString *deviceToken)
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
UIDevice *device = [UIDevice currentDevice];
dict[@"device"] = ({
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
dict[@"manufacturer"] = @"Apple";
#if TARGET_OS_MACCATALYST
dict[@"type"] = @"macos";
dict[@"name"] = @"Macintosh";
#else
dict[@"type"] = @"ios";
dict[@"name"] = [device model];
#endif
dict[@"model"] = getDeviceModel();
dict[@"id"] = [[device identifierForVendor] UUIDString];
if (getAdTrackingEnabled(configuration)) {
NSString *idfa = configuration.adSupportBlock();
// This isn't ideal. We're doing this because we can't actually check if IDFA is enabled on
// the customer device. Apple docs and tests show that if it is disabled, one gets back all 0's.
BOOL adTrackingEnabled = (![idfa isEqualToString:@"00000000-0000-0000-0000-000000000000"]);
dict[@"adTrackingEnabled"] = @(adTrackingEnabled);
if (adTrackingEnabled) {
dict[@"advertisingId"] = idfa;
}
}
if (deviceToken && deviceToken.length > 0) {
dict[@"token"] = deviceToken;
}
dict;
});
dict[@"os"] = @{
@"name" : device.systemName,
@"version" : device.systemVersion
};
CGSize screenSize = [UIScreen mainScreen].bounds.size;
dict[@"screen"] = @{
@"width" : @(screenSize.width),
@"height" : @(screenSize.height)
};
// BKS: This bit below doesn't seem to be effective anymore. Will investigate later.
/*#if !(TARGET_IPHONE_SIMULATOR)
Class adClient = NSClassFromString(SEGADClientClass);
if (adClient) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
id sharedClient = [adClient performSelector:NSSelectorFromString(@"sharedClient")];
#pragma clang diagnostic pop
void (^completionHandler)(BOOL iad) = ^(BOOL iad) {
if (iad) {
dict[@"referrer"] = @{ @"type" : @"iad" };
}
};
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[sharedClient performSelector:NSSelectorFromString(@"determineAppInstallationAttributionWithCompletionHandler:")
withObject:completionHandler];
#pragma clang diagnostic pop
}
#endif*/
return dict;
}
#endif
#if TARGET_OS_OSX
NSString *getMacUUID()
{
char buf[512] = { 0 };
int bufSize = sizeof(buf);
io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
IOObjectRelease(ioRegistryRoot);
CFStringGetCString(uuidCf, buf, bufSize, kCFStringEncodingMacRoman);
CFRelease(uuidCf);
return [NSString stringWithUTF8String:buf];
}
NSDictionary *desktopSpecifications(SEGAnalyticsConfiguration *configuration, NSString *deviceToken)
{
NSProcessInfo *deviceInfo = [NSProcessInfo processInfo];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
dict[@"device"] = ({
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
dict[@"manufacturer"] = @"Apple";
dict[@"type"] = @"macos";
dict[@"model"] = getDeviceModel();
dict[@"id"] = getMacUUID();
dict[@"name"] = [deviceInfo hostName];
if (getAdTrackingEnabled(configuration)) {
NSString *idfa = configuration.adSupportBlock();
// This isn't ideal. We're doing this because we can't actually check if IDFA is enabled on
// the customer device. Apple docs and tests show that if it is disabled, one gets back all 0's.
BOOL adTrackingEnabled = (![idfa isEqualToString:@"00000000-0000-0000-0000-000000000000"]);
dict[@"adTrackingEnabled"] = @(adTrackingEnabled);
if (adTrackingEnabled) {
dict[@"advertisingId"] = idfa;
}
}
if (deviceToken && deviceToken.length > 0) {
dict[@"token"] = deviceToken;
}
dict;
});
dict[@"os"] = @{
@"name" : deviceInfo.operatingSystemVersionString,
@"version" : [NSString stringWithFormat:@"%ld.%ld.%ld",
deviceInfo.operatingSystemVersion.majorVersion,
deviceInfo.operatingSystemVersion.minorVersion,
deviceInfo.operatingSystemVersion.patchVersion]
};
CGSize screenSize = [NSScreen mainScreen].frame.size;
dict[@"screen"] = @{
@"width" : @(screenSize.width),
@"height" : @(screenSize.height)
};
return dict;
}
#endif
NSDictionary *getLiveContext(SEGReachability *reachability, NSDictionary *referrer, NSDictionary *traits)
{
NSMutableDictionary *context = [[NSMutableDictionary alloc] init];
context[@"locale"] = [NSString stringWithFormat:
@"%@-%@",
[NSLocale.currentLocale objectForKey:NSLocaleLanguageCode],
[NSLocale.currentLocale objectForKey:NSLocaleCountryCode]];
context[@"timezone"] = [[NSTimeZone localTimeZone] name];
context[@"network"] = ({
NSMutableDictionary *network = [[NSMutableDictionary alloc] init];
if (reachability.isReachable) {
network[@"wifi"] = @(reachability.isReachableViaWiFi);
network[@"cellular"] = @(reachability.isReachableViaWWAN);
}
#if TARGET_OS_IOS && TARGET_OS_MACCATALYST == 0
static dispatch_once_t networkInfoOnceToken;
dispatch_once(&networkInfoOnceToken, ^{
_telephonyNetworkInfo = [[CTTelephonyNetworkInfo alloc] init];
});
CTCarrier *carrier = [_telephonyNetworkInfo subscriberCellularProvider];
if (carrier.carrierName.length)
network[@"carrier"] = carrier.carrierName;
#endif
network;
});
context[@"traits"] = [traits copy];
if (referrer) {
context[@"referrer"] = [referrer copy];
}
return [context copy];
}
@interface SEGISO8601NanosecondDateFormatter: NSDateFormatter
@end
@implementation SEGISO8601NanosecondDateFormatter
- (id)init
{
self = [super init];
self.dateFormat = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSS:'Z'";
self.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
self.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
return self;
}
const NSInteger __SEG_NANO_MAX_LENGTH = 9;
- (NSString * _Nonnull)stringFromDate:(NSDate *)date
{
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dateComponents = [calendar components:NSCalendarUnitSecond | NSCalendarUnitNanosecond fromDate:date];
NSString *genericDateString = [super stringFromDate:date];
NSMutableArray *stringComponents = [[genericDateString componentsSeparatedByString:@"."] mutableCopy];
NSString *nanoSeconds = [NSString stringWithFormat:@"%li", (long)dateComponents.nanosecond];
if (nanoSeconds.length > __SEG_NANO_MAX_LENGTH) {
nanoSeconds = [nanoSeconds substringToIndex:__SEG_NANO_MAX_LENGTH];
} else {
nanoSeconds = [nanoSeconds stringByPaddingToLength:__SEG_NANO_MAX_LENGTH withString:@"0" startingAtIndex:0];
}
NSString *result = [NSString stringWithFormat:@"%@.%@Z", stringComponents[0], nanoSeconds];
return result;
}
@end
NSString *GenerateUUIDString()
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
NSString *UUIDString = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return UUIDString;
}
// Date Utils
NSString *iso8601NanoFormattedString(NSDate *date)
{
static NSDateFormatter *dateFormatter;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dateFormatter = [[SEGISO8601NanosecondDateFormatter alloc] init];
});
return [dateFormatter stringFromDate:date];
}
NSString *iso8601FormattedString(NSDate *date)
{
static NSDateFormatter *dateFormatter;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
dateFormatter.dateFormat = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSS'Z'";
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
});
return [dateFormatter stringFromDate:date];
}
/** trim the queue so that it contains only upto `max` number of elements. */
void trimQueue(NSMutableArray *queue, NSUInteger max)
{
if (queue.count < max) {
return;
}
// Previously we didn't cap the queue. Hence there are cases where
// the queue may already be larger than 1000 events. Delete as many
// events as required to trim the queue size.
NSRange range = NSMakeRange(0, queue.count - max);
[queue removeObjectsInRange:range];
}
// Async Utils
dispatch_queue_t
seg_dispatch_queue_create_specific(const char *label,
dispatch_queue_attr_t attr)
{
dispatch_queue_t queue = dispatch_queue_create(label, attr);
dispatch_queue_set_specific(queue, (__bridge const void *)queue,
(__bridge void *)queue, NULL);
return queue;
}
BOOL seg_dispatch_is_on_specific_queue(dispatch_queue_t queue)
{
return dispatch_get_specific((__bridge const void *)queue) != NULL;
}
void seg_dispatch_specific(dispatch_queue_t queue, dispatch_block_t block,
BOOL waitForCompletion)
{
dispatch_block_t autoreleasing_block = ^{
@autoreleasepool
{
block();
}
};
if (dispatch_get_specific((__bridge const void *)queue)) {
autoreleasing_block();
} else if (waitForCompletion) {
dispatch_sync(queue, autoreleasing_block);
} else {
dispatch_async(queue, autoreleasing_block);
}
}
void seg_dispatch_specific_async(dispatch_queue_t queue,
dispatch_block_t block)
{
seg_dispatch_specific(queue, block, NO);
}
void seg_dispatch_specific_sync(dispatch_queue_t queue,
dispatch_block_t block)
{
seg_dispatch_specific(queue, block, YES);
}
// JSON Utils
static id SEGCoerceJSONObject(id obj)
{
// if the object is a NSString, NSNumber
// then we're good
if ([obj isKindOfClass:[NSString class]] ||
[obj isKindOfClass:[NSNumber class]] ||
[obj isKindOfClass:[NSNull class]]) {
return obj;
}
if ([obj isKindOfClass:[NSArray class]]) {
NSMutableArray *array = [NSMutableArray array];
for (id i in obj) {
NSObject *value = i;
// Hotfix: Storage format should support NSNull instead
if ([value isKindOfClass:[NSNull class]]) {
value = [NSData data];
}
[array addObject:SEGCoerceJSONObject(value)];
}
return array;
}
if ([obj isKindOfClass:[NSDictionary class]]) {
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
for (NSString *key in obj) {
NSObject *value = obj[key];
if (![key isKindOfClass:[NSString class]])
SEGLog(@"warning: dictionary keys should be strings. got: %@. coercing "
@"to: %@",
[key class], [key description]);
dict[key.description] = SEGCoerceJSONObject(value);
}
return dict;
}
if ([obj isKindOfClass:[NSDate class]])
return iso8601FormattedString(obj);
if ([obj isKindOfClass:[NSURL class]])
return [obj absoluteString];
// default to sending the object's description
SEGLog(@"warning: dictionary values should be valid json types. got: %@. "
@"coercing to: %@",
[obj class], [obj description]);
return [obj description];
}
NSDictionary *SEGCoerceDictionary(NSDictionary *dict)
{
// make sure that a new dictionary exists even if the input is null
dict = dict ?: @{};
// assert that the proper types are in the dictionary
dict = [dict serializableDeepCopy];
// coerce urls, and dates to the proper format
return SEGCoerceJSONObject(dict);
}
NSString *SEGEventNameForScreenTitle(NSString *title)
{
return [[NSString alloc] initWithFormat:@"Viewed %@ Screen", title];
}
@implementation NSJSONSerialization(Serializable)
+ (BOOL)isOfSerializableType:(id)obj
{
if ([obj isKindOfClass:[NSArray class]] ||
[obj isKindOfClass:[NSDictionary class]] ||
[obj isKindOfClass:[NSString class]] ||
[obj isKindOfClass:[NSNumber class]] ||
[obj isKindOfClass:[NSNull class]])
return YES;
return NO;
}
@end
@implementation NSDictionary(SerializableDeepCopy)
- (id)serializableDeepCopy:(BOOL)mutable
{
NSMutableDictionary *result = [[NSMutableDictionary alloc] initWithCapacity:self.count];
NSArray *keys = [self allKeys];
for (id key in keys) {
id aValue = [self objectForKey:key];
id theCopy = nil;
if (![NSJSONSerialization isOfSerializableType:aValue]) {
NSString *className = NSStringFromClass([aValue class]);
#ifdef DEBUG
NSAssert(FALSE, @"key `%@` is a %@ and can't be serialized for delivery.", key, className);
#else
SEGLog(@"key `%@` is a %@ and can't be serializaed for delivery.", key, className);
// simply leave it out since we can't encode it anyway.
continue;
#endif
}
if ([aValue conformsToProtocol:@protocol(SEGSerializableDeepCopy)]) {
theCopy = [aValue serializableDeepCopy:mutable];
} else if ([aValue conformsToProtocol:@protocol(NSCopying)]) {
theCopy = [aValue copy];
} else {
theCopy = aValue;
}
[result setValue:theCopy forKey:key];
}
if (mutable) {
return result;
} else {
return [result copy];
}
}
- (NSDictionary *)serializableDeepCopy {
return [self serializableDeepCopy:NO];
}
- (NSMutableDictionary *)serializableMutableDeepCopy {
return [self serializableDeepCopy:YES];
}
@end
@implementation NSArray(SerializableDeepCopy)
-(id)serializableDeepCopy:(BOOL)mutable
{
NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:self.count];
for (id aValue in self) {
id theCopy = nil;
if (![NSJSONSerialization isOfSerializableType:aValue]) {
NSString *className = NSStringFromClass([aValue class]);
#ifdef DEBUG
NSAssert(FALSE, @"found a %@ which can't be serialized for delivery.", className);
#else
SEGLog(@"found a %@ which can't be serializaed for delivery.", className);
// simply leave it out since we can't encode it anyway.
continue;
#endif
}
if ([aValue conformsToProtocol:@protocol(SEGSerializableDeepCopy)]) {
theCopy = [aValue serializableDeepCopy:mutable];
} else if ([aValue conformsToProtocol:@protocol(NSCopying)]) {
theCopy = [aValue copy];
} else {
theCopy = aValue;
}
[result addObject:theCopy];
}
if (mutable) {
return result;
} else {
return [result copy];
}
}
- (NSArray *)serializableDeepCopy {
return [self serializableDeepCopy:NO];
}
- (NSMutableArray *)serializableMutableDeepCopy {
return [self serializableDeepCopy:YES];
}
@end