Permalink
Browse files

initial commit

  • Loading branch information...
1 parent c4047e1 commit 72a825fdfbd687090066ef0cf88b3c8fa186bc5f @shahruz committed May 20, 2014
Showing with 12,265 additions and 364 deletions.
  1. +16 −0 .gitignore
  2. +9 −0 Readme.md
  3. +303 −150 Sketch Toolbox.xcodeproj/project.pbxproj
  4. +95 −6 Sketch Toolbox/Base.lproj/MainMenu.xib
  5. BIN Sketch Toolbox/Images.xcassets/Cloud_Download.imageset/Cloud_Download.png
  6. BIN Sketch Toolbox/Images.xcassets/Cloud_Download.imageset/Cloud_Download@2x.png
  7. +18 −0 Sketch Toolbox/Images.xcassets/Cloud_Download.imageset/Contents.json
  8. +28 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/MagicalImportFunctions.h
  9. +126 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/MagicalImportFunctions.m
  10. +16 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSAttributeDescription+MagicalDataImport.h
  11. +73 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSAttributeDescription+MagicalDataImport.m
  12. +26 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSEntityDescription+MagicalDataImport.h
  13. +50 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSEntityDescription+MagicalDataImport.m
  14. +17 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSNumber+MagicalDataImport.h
  15. +25 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSNumber+MagicalDataImport.m
  16. +20 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSObject+MagicalDataImport.h
  17. +76 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSObject+MagicalDataImport.m
  18. +15 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSRelationshipDescription+MagicalDataImport.h
  19. +24 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSRelationshipDescription+MagicalDataImport.m
  20. +16 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.h
  21. +35 −0 Sketch Toolbox/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m
  22. +68 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalAggregation.h
  23. +199 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalAggregation.m
  24. +38 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.h
  25. +356 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m
  26. +64 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalFinders.h
  27. +425 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalFinders.m
  28. +76 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.h
  29. +316 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.m
  30. +32 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRequests.h
  31. +173 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRequests.m
  32. +23 −0 ...Toolbox/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalObserving.h
  33. +109 −0 ...Toolbox/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalObserving.m
  34. +130 −0 ...ch Toolbox/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalRecord.h
  35. +298 −0 ...ch Toolbox/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalRecord.m
  36. +91 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalSaves.h
  37. +194 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalSaves.m
  38. +18 −0 ...Toolbox/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalThreading.h
  39. +69 −0 ...Toolbox/MagicalRecord/Categories/NSManagedObjectContext/NSManagedObjectContext+MagicalThreading.m
  40. +24 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObjectModel+MagicalRecord.h
  41. +74 −0 Sketch Toolbox/MagicalRecord/Categories/NSManagedObjectModel+MagicalRecord.m
  42. +28 −0 Sketch Toolbox/MagicalRecord/Categories/NSPersistentStore+MagicalRecord.h
  43. +79 −0 Sketch Toolbox/MagicalRecord/Categories/NSPersistentStore+MagicalRecord.m
  44. +42 −0 Sketch Toolbox/MagicalRecord/Categories/NSPersistentStoreCoordinator+MagicalRecord.h
  45. +328 −0 Sketch Toolbox/MagicalRecord/Categories/NSPersistentStoreCoordinator+MagicalRecord.m
  46. +33 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+Actions.h
  47. +143 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+Actions.m
  48. +20 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+ErrorHandling.h
  49. +95 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+ErrorHandling.m
  50. +148 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+Options.h
  51. +60 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+Options.m
  52. +21 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+Setup.h
  53. +56 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+Setup.m
  54. +17 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+ShorthandSupport.h
  55. +147 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+ShorthandSupport.m
  56. +19 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+iCloud.h
  57. +61 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord+iCloud.m
  58. +41 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord.h
  59. +116 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecord.m
  60. +7 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecordDeprecated.h
  61. +69 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecordLogging.h
  62. +192 −0 Sketch Toolbox/MagicalRecord/Core/MagicalRecordShorthand.h
  63. +60 −0 Sketch Toolbox/MagicalRecord/CoreData+MagicalRecord.h
  64. +22 −0 Sketch Toolbox/Plugin.h
  65. +76 −0 Sketch Toolbox/Plugin.m
  66. +21 −0 Sketch Toolbox/PluginManager.h
  67. +58 −0 Sketch Toolbox/PluginManager.m
  68. +52 −0 Sketch Toolbox/SSZipArchive/SSZipArchive.h
  69. +538 −0 Sketch Toolbox/SSZipArchive/SSZipArchive.m
  70. +131 −0 Sketch Toolbox/SSZipArchive/minizip/crypt.h
  71. +239 −0 Sketch Toolbox/SSZipArchive/minizip/ioapi.c
  72. +201 −0 Sketch Toolbox/SSZipArchive/minizip/ioapi.h
  73. +284 −0 Sketch Toolbox/SSZipArchive/minizip/mztools.c
  74. +31 −0 Sketch Toolbox/SSZipArchive/minizip/mztools.h
  75. +2,153 −0 Sketch Toolbox/SSZipArchive/minizip/unzip.c
  76. +437 −0 Sketch Toolbox/SSZipArchive/minizip/unzip.h
  77. +2,022 −0 Sketch Toolbox/SSZipArchive/minizip/zip.c
  78. +362 −0 Sketch Toolbox/SSZipArchive/minizip/zip.h
  79. +4 −1 Sketch Toolbox/STAppDelegate.h
  80. +34 −146 Sketch Toolbox/STAppDelegate.m
  81. +21 −0 Sketch Toolbox/STPluginCellView.h
  82. +18 −0 Sketch Toolbox/STPluginCellView.m
  83. +1 −1 Sketch Toolbox/Sketch Toolbox-Info.plist
  84. +3 −0 Sketch Toolbox/Sketch Toolbox-Prefix.pch
  85. +10 −2 Sketch Toolbox/Sketch_Toolbox.xcdatamodeld/Sketch_Toolbox.xcdatamodel/contents
  86. +0 −22 Sketch ToolboxTests/Sketch ToolboxTests-Info.plist
  87. +0 −34 Sketch ToolboxTests/Sketch_ToolboxTests.m
  88. +0 −2 Sketch ToolboxTests/en.lproj/InfoPlist.strings
View
@@ -0,0 +1,16 @@
+build/
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+xcuserdata
+*.xccheckout
+*.moved-aside
+DerivedData
+*.hmap
+*.ipa
+*.xcuserstate
View
@@ -0,0 +1,9 @@
+# Sketch Toolbox
+
+An *extremely early* prototype of a package manager for Sketch.app. Currently, the app will download packages to Sketch.
+
+Over the next few days, I'll be adding in auto-updating functionality, along with a more polished interface (with the ability to search, organize by plugins already downloaded, etc.)
+
+I'll also likely be refactoring much of the code into something more easily maintainable if there's interest. (It's fairly rough right now.)
+
+Please feel free to get involved if you're interested! You can email me at me @ shahr.uz or find me on [Twitter])(http://twitter.com/shahruz)
Oops, something went wrong.
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5023" systemVersion="13A603" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13D65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5023"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -13,6 +13,7 @@
<customObject id="-3" userLabel="Application"/>
<customObject id="Voe-Tx-rLC" customClass="STAppDelegate">
<connections>
+ <outlet property="tableView" destination="tll-qL-Al8" id="cSX-Sr-v5d"/>
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
</connections>
</customObject>
@@ -667,14 +668,102 @@
</items>
</menu>
<window title="Sketch Toolbox" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
- <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+ <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" texturedBackground="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
- <rect key="contentRect" x="335" y="390" width="480" height="360"/>
- <rect key="screenRect" x="0.0" y="0.0" width="1680" height="1028"/>
+ <rect key="contentRect" x="335" y="390" width="500" height="488"/>
+ <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1178"/>
<view key="contentView" id="EiT-Mj-1SZ">
- <rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
+ <rect key="frame" x="0.0" y="0.0" width="500" height="488"/>
<autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <scrollView autohidesScrollers="YES" horizontalLineScroll="78" horizontalPageScroll="10" verticalLineScroll="78" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="wZh-Yh-EYf">
+ <rect key="frame" x="-1" y="-1" width="502" height="475"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <clipView key="contentView" id="0Qv-vq-Aez">
+ <rect key="frame" x="1" y="1" width="500" height="473"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <subviews>
+ <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="76" rowSizeStyle="automatic" viewBased="YES" id="tll-qL-Al8">
+ <rect key="frame" x="0.0" y="0.0" width="500" height="473"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <size key="intercellSpacing" width="3" height="2"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+ <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
+ <tableColumns>
+ <tableColumn editable="NO" width="497" minWidth="40" maxWidth="1000" id="Kma-mf-RaI">
+ <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
+ <font key="font" metaFont="smallSystem"/>
+ <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
+ </tableHeaderCell>
+ <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="Nfw-W0-1Rr">
+ <font key="font" metaFont="system"/>
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+ <prototypeCellViews>
+ <tableCellView id="C1z-dv-ClF" customClass="STPluginCellView">
+ <rect key="frame" x="1" y="1" width="497" height="76"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <subviews>
+ <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="4Sc-HC-EKv">
+ <rect key="frame" x="10" y="44" width="384" height="23"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+ <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="hYg-uF-51G">
+ <font key="font" metaFont="systemBold"/>
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
+ <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" id="E2A-WJ-dae">
+ <rect key="frame" x="10" y="9" width="384" height="37"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+ <textFieldCell key="cell" truncatesLastVisibleLine="YES" sendsActionOnEndEditing="YES" id="cid-nH-aGY">
+ <font key="font" metaFont="system"/>
+ <string key="title">Table View CellTable View CellTable View CellTable View ellTable View CellTable View CellTable View Cell Table View CellTable View CellTable View CellTable View CellTable View CellTable View CellTable View Cell Table View CellTable View CellTable View CellTable View CellTable View CellTable View CellTable View Cell</string>
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
+ <button verticalHuggingPriority="750" id="vYL-pv-Cug">
+ <rect key="frame" x="440" y="25" width="39" height="21"/>
+ <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
+ <buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="Cloud_Download" imagePosition="only" alignment="center" state="on" imageScaling="proportionallyDown" inset="2" id="knQ-U3-fkP">
+ <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+ <font key="font" metaFont="system"/>
+ </buttonCell>
+ <connections>
+ <action selector="downloadButtonPressed:" target="C1z-dv-ClF" id="MJf-pL-VX0"/>
+ </connections>
+ </button>
+ </subviews>
+ <connections>
+ <outlet property="description" destination="E2A-WJ-dae" id="sx2-ox-sPC"/>
+ <outlet property="name" destination="4Sc-HC-EKv" id="565-96-Iyr"/>
+ </connections>
+ </tableCellView>
+ </prototypeCellViews>
+ </tableColumn>
+ </tableColumns>
+ </tableView>
+ </subviews>
+ <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+ </clipView>
+ <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="qUY-QL-Z1q">
+ <rect key="frame" x="1" y="119" width="223" height="15"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </scroller>
+ <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="oh5-nn-U9Q">
+ <rect key="frame" x="224" y="17" width="15" height="102"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </scroller>
+ </scrollView>
+ </subviews>
</view>
</window>
</objects>
+ <resources>
+ <image name="Cloud_Download" width="29" height="27"/>
+ </resources>
</document>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,18 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "Cloud_Download.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "Cloud_Download@2x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
@@ -0,0 +1,28 @@
+//
+// MagicalImportFunctions.h
+// Magical Record
+//
+// Created by Saul Mora on 3/7/12.
+// Copyright (c) 2012 Magical Panda Software LLC. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+NSDate * MR_adjustDateForDST(NSDate *date);
+NSDate * MR_dateFromString(NSString *value, NSString *format);
+NSDate * MR_dateFromNumber(NSNumber *value, BOOL milliseconds);
+NSNumber * MR_numberFromString(NSString *value);
+NSString * MR_attributeNameFromString(NSString *value);
+NSString * MR_primaryKeyNameFromString(NSString *value);
+
+#if TARGET_OS_IPHONE
+#import <UIKit/UIKit.h>
+UIColor * MR_colorFromString(NSString *serializedColor);
+#else
+#import <AppKit/AppKit.h>
+NSColor * MR_colorFromString(NSString *serializedColor);
+#endif
+
+NSInteger* MR_newColorComponentsFromString(NSString *serializedColor);
+extern id (*colorFromString)(NSString *);
@@ -0,0 +1,126 @@
+//
+// MagicalImportFunctions.m
+// Magical Record
+//
+// Created by Saul Mora on 3/7/12.
+// Copyright (c) 2012 Magical Panda Software LLC. All rights reserved.
+//
+
+#import "MagicalImportFunctions.h"
+
+
+#pragma mark - Data import helper functions
+
+NSString * MR_attributeNameFromString(NSString *value)
+{
+ NSString *firstCharacter = [[value substringToIndex:1] capitalizedString];
+ return [firstCharacter stringByAppendingString:[value substringFromIndex:1]];
+}
+
+NSString * MR_primaryKeyNameFromString(NSString *value)
+{
+ NSString *firstCharacter = [[value substringToIndex:1] lowercaseString];
+ return [firstCharacter stringByAppendingFormat:@"%@ID", [value substringFromIndex:1]];
+}
+
+NSDate * MR_adjustDateForDST(NSDate *date)
+{
+ NSTimeInterval dstOffset = [[NSTimeZone localTimeZone] daylightSavingTimeOffsetForDate:date];
+ NSDate *actualDate = [date dateByAddingTimeInterval:dstOffset];
+
+ return actualDate;
+}
+
+NSDate * MR_dateFromString(NSString *value, NSString *format)
+{
+ NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
+ [formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
+ [formatter setLocale:[NSLocale currentLocale]];
+ [formatter setDateFormat:format];
+
+ NSDate *parsedDate = [formatter dateFromString:value];
+
+ return parsedDate;
+}
+
+NSDate * MR_dateFromNumber(NSNumber *value, BOOL milliseconds)
+{
+ NSTimeInterval timeInterval = [value doubleValue];
+ if (milliseconds) {
+ timeInterval = timeInterval / 1000.00;
+ }
+ return [NSDate dateWithTimeIntervalSince1970:timeInterval];
+}
+
+NSNumber * MR_numberFromString(NSString *value) {
+ return [NSNumber numberWithDouble:[value doubleValue]];
+}
+
+NSInteger* MR_newColorComponentsFromString(NSString *serializedColor)
+{
+ NSScanner *colorScanner = [NSScanner scannerWithString:serializedColor];
+ NSString *colorType;
+ [colorScanner scanUpToString:@"(" intoString:&colorType];
+
+ NSInteger *componentValues = malloc(4 * sizeof(NSInteger));
+ if (componentValues == NULL)
+ {
+ return NULL;
+ }
+
+ if ([colorType hasPrefix:@"rgba"])
+ {
+ NSCharacterSet *rgbaCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"(,)"];
+
+ NSInteger *componentValue = componentValues;
+ while (![colorScanner isAtEnd])
+ {
+ [colorScanner scanCharactersFromSet:rgbaCharacterSet intoString:nil];
+ [colorScanner scanInteger:componentValue];
+ componentValue++;
+ }
+ }
+
+ return componentValues;
+}
+
+#if TARGET_OS_IPHONE
+
+UIColor * MR_colorFromString(NSString *serializedColor)
+{
+ NSInteger *componentValues = MR_newColorComponentsFromString(serializedColor);
+ if (componentValues == NULL)
+ {
+ return nil;
+ }
+
+ UIColor *color = [UIColor colorWithRed:(componentValues[0] / 255.0f)
+ green:(componentValues[1] / 255.0f)
+ blue:(componentValues[2] / 255.0f)
+ alpha:componentValues[3]];
+
+ free(componentValues);
+ return color;
+}
+
+#else
+
+NSColor * MR_colorFromString(NSString *serializedColor)
+{
+ NSInteger *componentValues = MR_newColorComponentsFromString(serializedColor);
+ if (componentValues == NULL)
+ {
+ return nil;
+ }
+
+ NSColor *color = [NSColor colorWithDeviceRed:(componentValues[0] / 255.0f)
+ green:(componentValues[1] / 255.0f)
+ blue:(componentValues[2] / 255.0f)
+ alpha:componentValues[3]];
+ free(componentValues);
+ return color;
+}
+
+#endif
+
+id (*colorFromString)(NSString *) = MR_colorFromString;
@@ -0,0 +1,16 @@
+//
+// NSAttributeDescription+MagicalDataImport.h
+// Magical Record
+//
+// Created by Saul Mora on 9/4/11.
+// Copyright 2011 Magical Panda Software LLC. All rights reserved.
+//
+
+#import <CoreData/CoreData.h>
+
+@interface NSAttributeDescription (MagicalRecord_DataImport)
+
+- (NSString *) MR_primaryKey;
+- (id) MR_valueForKeyPath:(NSString *)keyPath fromObjectData:(id)objectData;
+
+@end
Oops, something went wrong.

0 comments on commit 72a825f

Please sign in to comment.