Skip to content

Commit 4c8241b

Browse files
committed
Prefix import functions with MR_ to avoid conflicts
Closes #722.
1 parent ef696c2 commit 4c8241b

File tree

6 files changed

+31
-35
lines changed

6 files changed

+31
-35
lines changed

MagicalRecord/Categories/DataImport/MagicalImportFunctions.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,20 @@
99
#import <Foundation/Foundation.h>
1010

1111

12-
NSDate * adjustDateForDST(NSDate *date);
13-
NSDate * dateFromString(NSString *value, NSString *format);
14-
NSDate * dateFromNumber(NSNumber *value, BOOL milliseconds);
15-
NSNumber * numberFromString(NSString *value);
16-
NSString * attributeNameFromString(NSString *value);
17-
NSString * primaryKeyNameFromString(NSString *value);
12+
NSDate * MR_adjustDateForDST(NSDate *date);
13+
NSDate * MR_dateFromString(NSString *value, NSString *format);
14+
NSDate * MR_dateFromNumber(NSNumber *value, BOOL milliseconds);
15+
NSNumber * MR_numberFromString(NSString *value);
16+
NSString * MR_attributeNameFromString(NSString *value);
17+
NSString * MR_primaryKeyNameFromString(NSString *value);
1818

1919
#if TARGET_OS_IPHONE
2020
#import <UIKit/UIKit.h>
21-
UIColor * UIColorFromString(NSString *serializedColor);
22-
21+
UIColor * MR_colorFromString(NSString *serializedColor);
2322
#else
2423
#import <AppKit/AppKit.h>
25-
NSColor * NSColorFromString(NSString *serializedColor);
26-
24+
NSColor * MR_colorFromString(NSString *serializedColor);
2725
#endif
28-
extern id (*colorFromString)(NSString *);
2926

27+
NSInteger* MR_newColorComponentsFromString(NSString *serializedColor);
28+
extern id (*colorFromString)(NSString *);

MagicalRecord/Categories/DataImport/MagicalImportFunctions.m

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111

1212
#pragma mark - Data import helper functions
1313

14-
NSString * attributeNameFromString(NSString *value)
14+
NSString * MR_attributeNameFromString(NSString *value)
1515
{
1616
NSString *firstCharacter = [[value substringToIndex:1] capitalizedString];
1717
return [firstCharacter stringByAppendingString:[value substringFromIndex:1]];
1818
}
1919

20-
NSString * primaryKeyNameFromString(NSString *value)
20+
NSString * MR_primaryKeyNameFromString(NSString *value)
2121
{
2222
NSString *firstCharacter = [[value substringToIndex:1] lowercaseString];
2323
return [firstCharacter stringByAppendingFormat:@"%@ID", [value substringFromIndex:1]];
2424
}
2525

26-
NSDate * adjustDateForDST(NSDate *date)
26+
NSDate * MR_adjustDateForDST(NSDate *date)
2727
{
2828
NSTimeInterval dstOffset = [[NSTimeZone localTimeZone] daylightSavingTimeOffsetForDate:date];
2929
NSDate *actualDate = [date dateByAddingTimeInterval:dstOffset];
3030

3131
return actualDate;
3232
}
3333

34-
NSDate * dateFromString(NSString *value, NSString *format)
34+
NSDate * MR_dateFromString(NSString *value, NSString *format)
3535
{
3636
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
3737
[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
@@ -43,7 +43,7 @@
4343
return parsedDate;
4444
}
4545

46-
NSDate * dateFromNumber(NSNumber *value, BOOL milliseconds)
46+
NSDate * MR_dateFromNumber(NSNumber *value, BOOL milliseconds)
4747
{
4848
NSTimeInterval timeInterval = [value doubleValue];
4949
if (milliseconds) {
@@ -52,12 +52,11 @@
5252
return [NSDate dateWithTimeIntervalSince1970:timeInterval];
5353
}
5454

55-
NSNumber * numberFromString(NSString *value) {
55+
NSNumber * MR_numberFromString(NSString *value) {
5656
return [NSNumber numberWithDouble:[value doubleValue]];
5757
}
5858

59-
NSInteger* newColorComponentsFromString(NSString *serializedColor);
60-
NSInteger* newColorComponentsFromString(NSString *serializedColor)
59+
NSInteger* MR_newColorComponentsFromString(NSString *serializedColor)
6160
{
6261
NSScanner *colorScanner = [NSScanner scannerWithString:serializedColor];
6362
NSString *colorType;
@@ -81,16 +80,15 @@
8180
componentValue++;
8281
}
8382
}
84-
//else if ([colorType hasPrefix:@"hsba"])
85-
//else if ([colorType hasPrefix:@""])
83+
8684
return componentValues;
8785
}
8886

8987
#if TARGET_OS_IPHONE
9088

91-
UIColor * UIColorFromString(NSString *serializedColor)
89+
UIColor * MR_colorFromString(NSString *serializedColor)
9290
{
93-
NSInteger *componentValues = newColorComponentsFromString(serializedColor);
91+
NSInteger *componentValues = MR_newColorComponentsFromString(serializedColor);
9492
if (componentValues == NULL)
9593
{
9694
return nil;
@@ -104,13 +102,12 @@
104102
free(componentValues);
105103
return color;
106104
}
107-
id (*colorFromString)(NSString *) = UIColorFromString;
108105

109106
#else
110107

111-
NSColor * NSColorFromString(NSString *serializedColor)
108+
NSColor * MR_colorFromString(NSString *serializedColor)
112109
{
113-
NSInteger *componentValues = newColorComponentsFromString(serializedColor);
110+
NSInteger *componentValues = MR_newColorComponentsFromString(serializedColor);
114111
if (componentValues == NULL)
115112
{
116113
return nil;
@@ -123,7 +120,7 @@
123120
free(componentValues);
124121
return color;
125122
}
126-
id (*colorFromString)(NSString *) = NSColorFromString;
127-
128123

129124
#endif
125+
126+
id (*colorFromString)(NSString *) = MR_colorFromString;

MagicalRecord/Categories/DataImport/NSAttributeDescription+MagicalDataImport.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ - (id) MR_valueForKeyPath:(NSString *)keyPath fromObjectData:(id)objectData;
3838
{
3939
NSString *dateFormat = [[self userInfo] valueForKey:kMagicalRecordImportCustomDateFormatKey];
4040
if ([value isKindOfClass:[NSNumber class]]) {
41-
value = dateFromNumber(value, [dateFormat isEqualToString:kMagicalRecordImportUnixDate13String]);
41+
value = MR_dateFromNumber(value, [dateFormat isEqualToString:kMagicalRecordImportUnixDate13String]);
4242
}
4343
else {
44-
value = dateFromString([value description], dateFormat ?: kMagicalRecordImportDefaultDateFormatString);
44+
value = MR_dateFromString([value description], dateFormat ?: kMagicalRecordImportDefaultDateFormatString);
4545
}
4646
}
4747
}
@@ -52,7 +52,7 @@ - (id) MR_valueForKeyPath:(NSString *)keyPath fromObjectData:(id)objectData;
5252
attributeType == NSDoubleAttributeType ||
5353
attributeType == NSFloatAttributeType) {
5454
if (![value isKindOfClass:[NSNumber class]] && value != [NSNull null]) {
55-
value = numberFromString([value description]);
55+
value = MR_numberFromString([value description]);
5656
}
5757
}
5858
else if (attributeType == NSBooleanAttributeType) {

MagicalRecord/Categories/DataImport/NSEntityDescription+MagicalDataImport.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ @implementation NSEntityDescription (MagicalRecord_DataImport)
1313

1414
- (NSAttributeDescription *) MR_primaryAttributeToRelateBy;
1515
{
16-
NSString *lookupKey = [[self userInfo] valueForKey:kMagicalRecordImportRelationshipLinkedByKey] ?: primaryKeyNameFromString([self name]);
16+
NSString *lookupKey = [[self userInfo] valueForKey:kMagicalRecordImportRelationshipLinkedByKey] ?: MR_primaryKeyNameFromString([self name]);
1717

1818
return [self MR_attributeDescriptionForName:lookupKey];
1919
}

MagicalRecord/Categories/DataImport/NSRelationshipDescription+MagicalDataImport.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ @implementation NSRelationshipDescription (MagicalRecord_DataImport)
1616
- (NSString *) MR_primaryKey;
1717
{
1818
NSString *primaryKeyName = [[self userInfo] valueForKey:kMagicalRecordImportRelationshipLinkedByKey] ?:
19-
primaryKeyNameFromString([[self destinationEntity] name]);
19+
MR_primaryKeyNameFromString([[self destinationEntity] name]);
2020

2121
return primaryKeyName;
2222
}

MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ - (void) MR_addObject:(NSManagedObject *)relatedObject forRelationship:(NSRelati
137137
}
138138
}
139139

140-
NSString *addRelatedObjectToSetMessage = [NSString stringWithFormat:addRelationMessageFormat, attributeNameFromString([relationshipInfo name])];
140+
NSString *addRelatedObjectToSetMessage = [NSString stringWithFormat:addRelationMessageFormat, MR_attributeNameFromString([relationshipInfo name])];
141141

142142
SEL selector = NSSelectorFromString(addRelatedObjectToSetMessage);
143143

@@ -264,7 +264,7 @@ - (BOOL) MR_importValuesForKeysWithObject:(id)objectData
264264

265265
if ((localObjectData) && (![localObjectData isKindOfClass:[NSDictionary class]]))
266266
{
267-
NSString * relatedByAttribute = [[relationshipInfo userInfo] objectForKey:kMagicalRecordImportRelationshipLinkedByKey] ?: primaryKeyNameFromString([[relationshipInfo destinationEntity] name]);
267+
NSString * relatedByAttribute = [[relationshipInfo userInfo] objectForKey:kMagicalRecordImportRelationshipLinkedByKey] ?: MR_primaryKeyNameFromString([[relationshipInfo destinationEntity] name]);
268268

269269
if (relatedByAttribute)
270270
{

0 commit comments

Comments
 (0)