├── .gitignore ├── Classes ├── JSON │ ├── JSON.h │ ├── NSObject+SKJSON.h │ ├── NSObject+SKJSON.m │ ├── NSString+SKJSON.h │ ├── NSString+SKJSON.m │ ├── SKJSON.h │ ├── SKJSON.m │ ├── SKJsonBase.h │ ├── SKJsonBase.m │ ├── SKJsonParser.h │ ├── SKJsonParser.m │ ├── SKJsonWriter.h │ └── SKJsonWriter.m ├── NSDate+SKAdditions.h ├── NSDate+SKAdditions.m ├── NSDictionary+SKAdditions.h ├── NSDictionary+SKAdditions.m ├── NSNumber+SKAdditions.h ├── NSNumber+SKAdditions.m ├── NSNumberFormatter+SKAdditions.h ├── NSNumberFormatter+SKAdditions.m ├── NSPredicate+SKAdditions.h ├── NSPredicate+SKAdditions.m ├── NSString+SKAdditions.h ├── NSString+SKAdditions.m ├── SKAnswer.h ├── SKAnswer.m ├── SKBadge.h ├── SKBadge.m ├── SKCallback.h ├── SKCallback.m ├── SKComment.h ├── SKComment.m ├── SKConstants.h ├── SKConstants.m ├── SKConstants_Internal.h ├── SKDefinitions.h ├── SKDefinitions.m ├── SKFetchRequest+Private.h ├── SKFetchRequest.h ├── SKFetchRequest.m ├── SKFetchRequestDelegate.h ├── SKFunctions.h ├── SKFunctions.m ├── SKObject+Private.h ├── SKObject.h ├── SKObject.m ├── SKPost.h ├── SKPost.m ├── SKQAPost.h ├── SKQAPost.m ├── SKQuestion.h ├── SKQuestion.m ├── SKRequestBuilder.h ├── SKRequestBuilder.m ├── SKSite+Private.h ├── SKSite.h ├── SKSite.m ├── SKSiteDelegate.h ├── SKTag.h ├── SKTag.m ├── SKUser.h ├── SKUser.m ├── SKUserActivity.h ├── SKUserActivity.m ├── StackKit.h ├── StackKit_Internal.h ├── _SKConcreteRequestBuilder.h ├── _SKConcreteRequestBuilder.m ├── _SKRequestBuilderAllBadges.h ├── _SKRequestBuilderAllBadges.m ├── _SKRequestBuilderAnswersByID.h ├── _SKRequestBuilderAnswersByID.m ├── _SKRequestBuilderAnswersForQuestion.h ├── _SKRequestBuilderAnswersForQuestion.m ├── _SKRequestBuilderAnswersForUser.h ├── _SKRequestBuilderAnswersForUser.m ├── _SKRequestBuilderBadgesForUser.h ├── _SKRequestBuilderBadgesForUser.m ├── _SKRequestBuilderCommentsByID.h ├── _SKRequestBuilderCommentsByID.m ├── _SKRequestBuilderCommentsByUser.h ├── _SKRequestBuilderCommentsByUser.m ├── _SKRequestBuilderCommentsForAnswer.h ├── _SKRequestBuilderCommentsForAnswer.m ├── _SKRequestBuilderCommentsForQuestion.h ├── _SKRequestBuilderCommentsForQuestion.m ├── _SKRequestBuilderCommentsFromUserToUser.h ├── _SKRequestBuilderCommentsFromUserToUser.m ├── _SKRequestBuilderCommentsToUser.h ├── _SKRequestBuilderCommentsToUser.m ├── _SKRequestBuilderFavoritedQuestions.h ├── _SKRequestBuilderFavoritedQuestions.m ├── _SKRequestBuilderNameBadges.h ├── _SKRequestBuilderNameBadges.m ├── _SKRequestBuilderQuestionSearch.h ├── _SKRequestBuilderQuestionSearch.m ├── _SKRequestBuilderQuestions.h ├── _SKRequestBuilderQuestions.m ├── _SKRequestBuilderQuestionsByID.h ├── _SKRequestBuilderQuestionsByID.m ├── _SKRequestBuilderQuestionsByUser.h ├── _SKRequestBuilderQuestionsByUser.m ├── _SKRequestBuilderTagBadges.h ├── _SKRequestBuilderTagBadges.m ├── _SKRequestBuilderTags.h ├── _SKRequestBuilderTags.m ├── _SKRequestBuilderUnansweredQuestions.h ├── _SKRequestBuilderUnansweredQuestions.m ├── _SKRequestBuilderUserModerators.h ├── _SKRequestBuilderUserModerators.m ├── _SKRequestBuilderUserTags.h ├── _SKRequestBuilderUserTags.m ├── _SKRequestBuilderUsers.h ├── _SKRequestBuilderUsers.m ├── _SKRequestBuilderUsersByID.h ├── _SKRequestBuilderUsersByID.m ├── _SKRequestBuilderUsersWithBadge.h └── _SKRequestBuilderUsersWithBadge.m ├── English.lproj └── InfoPlist.strings ├── LICENSE ├── Other Sources ├── Dummy.m ├── Info.plist ├── StackKit_Prefix.pch └── version.plist ├── README.markdown ├── StackKit.xcodeproj └── project.pbxproj ├── StackKitMobile.xcodeproj └── project.pbxproj └── Unit Tests ├── NSPredicate_SKAdditionsTest.h ├── NSPredicate_SKAdditionsTest.m ├── SKBadgeTest.h ├── SKBadgeTest.m ├── SKCommentTest.h ├── SKCommentTest.m ├── SKQuestionTest.h ├── SKQuestionTest.m ├── SKSiteTest.h ├── SKSiteTest.m ├── SKTagTest.h ├── SKTagTest.m ├── SKTestConstants.h ├── SKTestConstants.m ├── SKUserActivityTest.h ├── SKUserActivityTest.m ├── SKUserTest.h ├── SKUserTest.m └── Unit Tests-Info.plist /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | consumerKey.txt 3 | **/*.mode1v3 4 | **/*.perspectivev3 5 | **/*.pbxuser 6 | **/*.xcworkspace 7 | **/xcuserdata -------------------------------------------------------------------------------- /Classes/JSON/JSON.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /** 31 | @mainpage A strict JSON parser and generator for Objective-C 32 | 33 | JSON (JavaScript Object Notation) is a lightweight data-interchange 34 | format. This framework provides two apis for parsing and generating 35 | JSON. One standard object-based and a higher level api consisting of 36 | categories added to existing Objective-C classes. 37 | 38 | Learn more on the http://code.google.com/p/json-framework project site. 39 | 40 | This framework does its best to be as strict as possible, both in what it 41 | accepts and what it generates. For example, it does not support trailing commas 42 | in arrays or objects. Nor does it support embedded comments, or 43 | anything else not in the JSON specification. This is considered a feature. 44 | 45 | */ 46 | 47 | #import "SKJSON.h" 48 | #import "NSObject+SKJSON.h" 49 | #import "NSString+SKJSON.h" 50 | 51 | -------------------------------------------------------------------------------- /Classes/JSON/NSObject+SKJSON.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import 31 | 32 | 33 | /** 34 | @brief Adds JSON generation to Foundation classes 35 | 36 | This is a category on NSObject that adds methods for returning JSON representations 37 | of standard objects to the objects themselves. This means you can call the 38 | -JSONRepresentation method on an NSArray object and it'll do what you want. 39 | */ 40 | @interface NSObject (NSObject_SKJSON) 41 | 42 | /** 43 | @brief Returns a string containing the receiver encoded as a JSON fragment. 44 | 45 | This method is added as a category on NSObject but is only actually 46 | supported for the following objects: 47 | @li NSDictionary 48 | @li NSArray 49 | @li NSString 50 | @li NSNumber (also used for booleans) 51 | @li NSNull 52 | 53 | @deprecated Given we bill ourselves as a "strict" JSON library, this method should be removed. 54 | */ 55 | - (NSString *)JSONFragment; 56 | 57 | /** 58 | @brief Returns a string containing the receiver encoded in JSON. 59 | 60 | This method is added as a category on NSObject but is only actually 61 | supported for the following objects: 62 | @li NSDictionary 63 | @li NSArray 64 | */ 65 | - (NSString *)JSONRepresentation; 66 | 67 | @end 68 | 69 | -------------------------------------------------------------------------------- /Classes/JSON/NSObject+SKJSON.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import "NSObject+SKJSON.h" 31 | #import "SKJsonWriter.h" 32 | 33 | @implementation NSObject (NSObject_SKJSON) 34 | 35 | - (NSString *)JSONFragment { 36 | SKJsonWriter *jsonWriter = [SKJsonWriter new]; 37 | NSString *json = [jsonWriter stringWithFragment:self]; 38 | if (!json) 39 | NSLog(@"-JSONFragment failed. Error trace is: %@", [jsonWriter errorTrace]); 40 | [jsonWriter release]; 41 | return json; 42 | } 43 | 44 | - (NSString *)JSONRepresentation { 45 | SKJsonWriter *jsonWriter = [SKJsonWriter new]; 46 | NSString *json = [jsonWriter stringWithObject:self]; 47 | if (!json) 48 | NSLog(@"-JSONRepresentation failed. Error trace is: %@", [jsonWriter errorTrace]); 49 | [jsonWriter release]; 50 | return json; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Classes/JSON/NSString+SKJSON.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import 31 | 32 | /** 33 | @brief Adds JSON parsing methods to NSString 34 | 35 | This is a category on NSString that adds methods for parsing the target string. 36 | */ 37 | @interface NSString (NSString_SKJSON) 38 | 39 | 40 | /** 41 | @brief Returns the object represented in the receiver, or nil on error. 42 | 43 | Returns a a scalar object represented by the string's JSON fragment representation. 44 | 45 | @deprecated Given we bill ourselves as a "strict" JSON library, this method should be removed. 46 | */ 47 | - (id)JSONFragmentValue; 48 | 49 | /** 50 | @brief Returns the NSDictionary or NSArray represented by the current string's JSON representation. 51 | 52 | Returns the dictionary or array represented in the receiver, or nil on error. 53 | 54 | Returns the NSDictionary or NSArray represented by the current string's JSON representation. 55 | */ 56 | - (id)JSONValue; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /Classes/JSON/NSString+SKJSON.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2007-2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import "NSString+SKJSON.h" 31 | #import "SKJsonParser.h" 32 | 33 | @implementation NSString (NSString_SKJSON) 34 | 35 | - (id)JSONFragmentValue 36 | { 37 | SKJsonParser *jsonParser = [SKJsonParser new]; 38 | id repr = [jsonParser fragmentWithString:self]; 39 | if (!repr) 40 | NSLog(@"-JSONFragmentValue failed. Error trace is: %@", [jsonParser errorTrace]); 41 | [jsonParser release]; 42 | return repr; 43 | } 44 | 45 | - (id)JSONValue 46 | { 47 | SKJsonParser *jsonParser = [SKJsonParser new]; 48 | id repr = [jsonParser objectWithString:self]; 49 | if (!repr) 50 | NSLog(@"-JSONValue failed. Error trace is: %@", [jsonParser errorTrace]); 51 | [jsonParser release]; 52 | return repr; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Classes/JSON/SKJSON.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2007-2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import 31 | #import "SKJsonParser.h" 32 | #import "SKJsonWriter.h" 33 | 34 | /** 35 | @brief Facade for SBJsonWriter/SBJsonParser. 36 | 37 | Requests are forwarded to instances of SBJsonWriter and SBJsonParser. 38 | */ 39 | @interface SKJSON : SKJsonBase { 40 | 41 | @private 42 | SKJsonParser *jsonParser; 43 | SKJsonWriter *jsonWriter; 44 | } 45 | 46 | 47 | /// Return the fragment represented by the given string 48 | - (id)fragmentWithString:(NSString*)jsonrep 49 | error:(NSError**)error; 50 | 51 | /// Return the object represented by the given string 52 | - (id)objectWithString:(NSString*)jsonrep 53 | error:(NSError**)error; 54 | 55 | /// Parse the string and return the represented object (or scalar) 56 | - (id)objectWithString:(id)value 57 | allowScalar:(BOOL)x 58 | error:(NSError**)error; 59 | 60 | 61 | /// Return JSON representation of an array or dictionary 62 | - (NSString*)stringWithObject:(id)value 63 | error:(NSError**)error; 64 | 65 | /// Return JSON representation of any legal JSON value 66 | - (NSString*)stringWithFragment:(id)value 67 | error:(NSError**)error; 68 | 69 | /// Return JSON representation (or fragment) for the given object 70 | - (NSString*)stringWithObject:(id)value 71 | allowScalar:(BOOL)x 72 | error:(NSError**)error; 73 | 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /Classes/JSON/SKJsonBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import 31 | 32 | extern NSString * SKJSONErrorDomain; 33 | 34 | 35 | enum { 36 | EUNSUPPORTED = 1, 37 | EPARSENUM, 38 | EPARSE, 39 | EFRAGMENT, 40 | ECTRL, 41 | EUNICODE, 42 | EDEPTH, 43 | EESCAPE, 44 | ETRAILCOMMA, 45 | ETRAILGARBAGE, 46 | EEOF, 47 | EINPUT 48 | }; 49 | 50 | /** 51 | @brief Common base class for parsing & writing. 52 | 53 | This class contains the common error-handling code and option between the parser/writer. 54 | */ 55 | @interface SKJsonBase : NSObject { 56 | NSMutableArray *errorTrace; 57 | 58 | @protected 59 | NSUInteger depth, maxDepth; 60 | } 61 | 62 | /** 63 | @brief The maximum recursing depth. 64 | 65 | Defaults to 512. If the input is nested deeper than this the input will be deemed to be 66 | malicious and the parser returns nil, signalling an error. ("Nested too deep".) You can 67 | turn off this security feature by setting the maxDepth value to 0. 68 | */ 69 | @property NSUInteger maxDepth; 70 | 71 | /** 72 | @brief Return an error trace, or nil if there was no errors. 73 | 74 | Note that this method returns the trace of the last method that failed. 75 | You need to check the return value of the call you're making to figure out 76 | if the call actually failed, before you know call this method. 77 | */ 78 | @property(copy,readonly) NSArray* errorTrace; 79 | 80 | /// @internal for use in subclasses to add errors to the stack trace 81 | - (void)addErrorWithCode:(NSUInteger)code description:(NSString*)str; 82 | 83 | /// @internal for use in subclasess to clear the error before a new parsing attempt 84 | - (void)clearErrorTrace; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Classes/JSON/SKJsonBase.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import "SKJsonBase.h" 31 | NSString * SKJSONErrorDomain = @"org.brautaset.JSON.ErrorDomain"; 32 | 33 | 34 | @implementation SKJsonBase 35 | 36 | @synthesize errorTrace; 37 | @synthesize maxDepth; 38 | 39 | - (id)init { 40 | self = [super init]; 41 | if (self) 42 | self.maxDepth = 512; 43 | return self; 44 | } 45 | 46 | - (void)dealloc { 47 | [errorTrace release]; 48 | [super dealloc]; 49 | } 50 | 51 | - (void)addErrorWithCode:(NSUInteger)code description:(NSString*)str { 52 | NSDictionary *userInfo; 53 | if (!errorTrace) { 54 | errorTrace = [NSMutableArray new]; 55 | userInfo = [NSDictionary dictionaryWithObject:str forKey:NSLocalizedDescriptionKey]; 56 | 57 | } else { 58 | userInfo = [NSDictionary dictionaryWithObjectsAndKeys: 59 | str, NSLocalizedDescriptionKey, 60 | [errorTrace lastObject], NSUnderlyingErrorKey, 61 | nil]; 62 | } 63 | 64 | NSError *error = [NSError errorWithDomain:SKJSONErrorDomain code:code userInfo:userInfo]; 65 | 66 | [self willChangeValueForKey:@"errorTrace"]; 67 | [errorTrace addObject:error]; 68 | [self didChangeValueForKey:@"errorTrace"]; 69 | } 70 | 71 | - (void)clearErrorTrace { 72 | [self willChangeValueForKey:@"errorTrace"]; 73 | [errorTrace release]; 74 | errorTrace = nil; 75 | [self didChangeValueForKey:@"errorTrace"]; 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Classes/JSON/SKJsonParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of its contributors may be used 15 | to endorse or promote products derived from this software without specific 16 | prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #import 31 | #import "SKJsonBase.h" 32 | 33 | /** 34 | @brief Options for the parser class. 35 | 36 | This exists so the SBJSON facade can implement the options in the parser without having to re-declare them. 37 | */ 38 | @protocol SKJsonParser 39 | 40 | /** 41 | @brief Return the object represented by the given string. 42 | 43 | Returns the object represented by the passed-in string or nil on error. The returned object can be 44 | a string, number, boolean, null, array or dictionary. 45 | 46 | @param repr the json string to parse 47 | */ 48 | - (id)objectWithString:(NSString *)repr; 49 | 50 | @end 51 | 52 | 53 | /** 54 | @brief The JSON parser class. 55 | 56 | JSON is mapped to Objective-C types in the following way: 57 | 58 | @li Null -> NSNull 59 | @li String -> NSMutableString 60 | @li Array -> NSMutableArray 61 | @li Object -> NSMutableDictionary 62 | @li Boolean -> NSNumber (initialised with -initWithBool:) 63 | @li Number -> NSDecimalNumber 64 | 65 | Since Objective-C doesn't have a dedicated class for boolean values, these turns into NSNumber 66 | instances. These are initialised with the -initWithBool: method, and 67 | round-trip back to JSON properly. (They won't silently suddenly become 0 or 1; they'll be 68 | represented as 'true' and 'false' again.) 69 | 70 | JSON numbers turn into NSDecimalNumber instances, 71 | as we can thus avoid any loss of precision. (JSON allows ridiculously large numbers.) 72 | 73 | */ 74 | @interface SKJsonParser : SKJsonBase { 75 | 76 | @private 77 | const char *c; 78 | } 79 | 80 | @end 81 | 82 | // don't use - exists for backwards compatibility with 2.1.x only. Will be removed in 2.3. 83 | @interface SKJsonParser (Private) 84 | - (id)fragmentWithString:(id)repr; 85 | @end 86 | 87 | 88 | -------------------------------------------------------------------------------- /Classes/NSDate+SKAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+SKAdditions.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | @interface NSDate (SKAdditions) 30 | 31 | + (NSDate *) dateWithJSONString:(NSString *)json; 32 | - (NSString *) sk_queryString; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Classes/NSDate+SKAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+SKAdditions.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "StackKit_Internal.h" 27 | 28 | 29 | @implementation NSDate (SKAdditions) 30 | 31 | + (NSDate *) dateWithJSONString:(NSString *)json { 32 | //assumes the string is in the format /Date(####)/ 33 | if ([json isKindOfClass:[NSNull class]]) { 34 | return nil; 35 | } 36 | NSString * substring = [json substringWithRange:NSMakeRange(6, [json length] - 8)]; 37 | NSNumber * n = [[NSNumberFormatter basicFormatter] numberFromString:substring]; 38 | 39 | NSTimeInterval secondsSince1970 = [n floatValue]/1000; 40 | 41 | return [NSDate dateWithTimeIntervalSince1970:secondsSince1970]; 42 | } 43 | 44 | - (NSString *) sk_queryString { 45 | NSNumber * n = [NSNumber numberWithDouble:[self timeIntervalSince1970]]; 46 | return [n sk_queryString]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Classes/NSDictionary+SKAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+SKAdditions.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | @interface NSDictionary (SKAdditions) 30 | 31 | - (NSString *) queryString; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/NSDictionary+SKAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+SKAdditions.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "NSDictionary+SKAdditions.h" 27 | #import "NSDate+SKAdditions.h" 28 | #import "NSNumber+SKAdditions.h" 29 | #import "NSString+SKAdditions.h" 30 | 31 | @implementation NSDictionary (SKAdditions) 32 | 33 | - (NSString *) queryString { 34 | if ([[self allKeys] count] == 0) { return @""; } 35 | NSMutableArray * queryArray = [NSMutableArray array]; 36 | for (NSString * key in self) { 37 | id object = [self objectForKey:key]; 38 | NSString * value = [object description]; 39 | if ([object respondsToSelector:@selector(sk_queryString)]) { 40 | value = [object sk_queryString]; 41 | } 42 | [queryArray addObject:[NSString stringWithFormat:@"%@=%@", 43 | [key sk_URLEncodedString], 44 | [value sk_URLEncodedString]]]; 45 | } 46 | 47 | return [queryArray componentsJoinedByString:@"&"]; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Classes/NSNumber+SKAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber+SKAdditions.h 3 | // StackKit 4 | // 5 | // Created by Dave DeLong on 1/16/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSNumber (SKAdditions) 13 | 14 | - (NSString *) sk_queryString; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Classes/NSNumber+SKAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber+SKAdditions.m 3 | // StackKit 4 | // 5 | // Created by Dave DeLong on 1/16/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "NSNumber+SKAdditions.h" 10 | 11 | 12 | @implementation NSNumber (SKAdditions) 13 | 14 | - (NSString *) sk_queryString { 15 | return [NSString stringWithFormat:@"%ld", [self integerValue]]; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Classes/NSNumberFormatter+SKAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumberFormatter+SKAdditions.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | @interface NSNumberFormatter (SKAdditions) 30 | 31 | + (NSNumberFormatter *) basicFormatter; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/NSNumberFormatter+SKAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumberFormatter+SKAdditions.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "NSNumberFormatter+SKAdditions.h" 27 | 28 | 29 | @implementation NSNumberFormatter (SKAdditions) 30 | 31 | + (NSNumberFormatter *) basicFormatter { 32 | static NSNumberFormatter * basicFormatter = nil; 33 | if (basicFormatter == nil) { 34 | basicFormatter = [[NSNumberFormatter alloc] init]; 35 | [basicFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; 36 | } 37 | return basicFormatter; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Classes/NSPredicate+SKAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSPredicate+SKAdditions.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKDefinitions.h" 28 | 29 | enum { 30 | SKAnyPredicateOperator = NSUIntegerMax 31 | }; 32 | 33 | @interface NSPredicate (SKAdditions) 34 | 35 | - (NSPredicate *) subPredicateForLeftExpression:(NSExpression *)left; 36 | - (NSPredicate *) subPredicateForLeftKeyPath:(NSString *)left; 37 | 38 | - (NSArray *) subPredicatesWithLeftExpression:(NSExpression *)left; 39 | - (NSArray *) subPredicatesWithLeftKeyPath:(NSString *)left; 40 | 41 | - (id) constantValueForLeftExpression:(NSExpression *)left; 42 | - (id) constantValueForLeftKeyPath:(NSString *)left; 43 | 44 | - (id) constantValueForOperator:(NSPredicateOperatorType)operator; 45 | - (id) constantValueForOneOfOperators:(NSArray *)operators; 46 | 47 | - (NSPredicate *) predicateByRemovingSubPredicateWithLeftExpression:(NSExpression *)left; 48 | - (NSPredicate *) predicateByReplacingLeftKeyPathsFromMapping:(NSDictionary *)mapping; 49 | 50 | - (BOOL) isComparisonPredicateWithLeftKeyPaths:(NSArray *)leftKeyPaths operator:(NSPredicateOperatorType)operator rightExpressionType:(NSExpressionType)rightType; 51 | - (BOOL) isPredicateWithConstantValueEqualToLeftKeyPath:(NSString *)leftKeyPath; 52 | - (BOOL) isSimpleAndPredicate; 53 | 54 | - (SKRange) rangeOfConstantValuesForLeftKeyPath:(NSString *)left; 55 | 56 | - (NSSet *) leftKeyPaths; 57 | 58 | - (NSNumber *) sk_matchesRecognizedKeyPathsAndOperators:(NSDictionary *)keyPaths; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Classes/NSString+SKAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+SKAdditions.h 3 | // StackKit 4 | // 5 | // Created by Dave DeLong on 1/16/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSString (SKAdditions) 13 | 14 | - (NSString *) sk_URLEncodedString; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Classes/NSString+SKAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+SKAdditions.m 3 | // StackKit 4 | // 5 | // Created by Dave DeLong on 1/16/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "NSString+SKAdditions.h" 10 | 11 | 12 | @implementation NSString (SKAdditions) 13 | 14 | - (NSString *) sk_URLEncodedString { 15 | NSMutableString * output = [NSMutableString string]; 16 | const unsigned char * source = (const unsigned char *)[self UTF8String]; 17 | int sourceLen = strlen((const char *)source); 18 | for (int i = 0; i < sourceLen; ++i) { 19 | const unsigned char thisChar = source[i]; 20 | if (thisChar == ' '){ 21 | [output appendString:@"+"]; 22 | } else if (thisChar == '.' || thisChar == '-' || thisChar == '_' || thisChar == '~' || 23 | (thisChar >= 'a' && thisChar <= 'z') || 24 | (thisChar >= 'A' && thisChar <= 'Z') || 25 | (thisChar >= '0' && thisChar <= '9')) { 26 | [output appendFormat:@"%c", thisChar]; 27 | } else { 28 | [output appendFormat:@"%%%02X", thisChar]; 29 | } 30 | } 31 | return output; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Classes/SKAnswer.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKAnswer.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKAnswer.h" 28 | 29 | //inherited 30 | extern NSString * const SKAnswerCreationDate; 31 | extern NSString * const SKAnswerOwner; 32 | extern NSString * const SKAnswerBody; 33 | extern NSString * const SKAnswerScore; 34 | extern NSString * const SKAnswerLockedDate; 35 | extern NSString * const SKAnswerLastEditDate; 36 | extern NSString * const SKAnswerLastActivityDate; 37 | extern NSString * const SKAnswerUpVotes; 38 | extern NSString * const SKAnswerDownVotes; 39 | extern NSString * const SKAnswerViewCount; 40 | extern NSString * const SKAnswerCommunityOwned; 41 | extern NSString * const SKAnswerTitle; 42 | 43 | extern NSString * const SKAnswerID; 44 | extern NSString * const SKAnswerQuestion; 45 | extern NSString * const SKAnswerIsAccepted; 46 | extern NSString * const SKAnswerCommentsURL; 47 | 48 | @class SKQuestion; 49 | 50 | @interface SKAnswer : SKQAPost { 51 | NSNumber * answerID; 52 | NSNumber * questionID; 53 | NSNumber * accepted; 54 | NSURL * commentsURL; 55 | } 56 | 57 | @property (readonly) NSNumber * answerID; 58 | @property (readonly) NSNumber * questionID; 59 | @property (readonly) NSNumber * accepted; 60 | @property (readonly) NSURL * commentsURL; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /Classes/SKAnswer.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKAnswer.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "StackKit_Internal.h" 27 | 28 | //inherited 29 | NSString * const SKAnswerCreationDate = __SKPostCreationDate; 30 | NSString * const SKAnswerOwner = __SKPostOwner; 31 | NSString * const SKAnswerBody = __SKPostBody; 32 | NSString * const SKAnswerScore = __SKPostScore; 33 | NSString * const SKAnswerLockedDate = __SKQAPostLockedDate; 34 | NSString * const SKAnswerLastEditDate = __SKQAPostLastEditDate; 35 | NSString * const SKAnswerLastActivityDate = __SKQAPostLastActivityDate; 36 | NSString * const SKAnswerUpVotes = __SKQAPostUpVotes; 37 | NSString * const SKAnswerDownVotes = __SKQAPostDownVotes; 38 | NSString * const SKAnswerViewCount = __SKQAPostViewCount; 39 | NSString * const SKAnswerCommunityOwned = __SKQAPostCommunityOwned; 40 | NSString * const SKAnswerTitle = __SKQAPostTitle; 41 | 42 | NSString * const SKAnswerID = __SKAnswerID; 43 | NSString * const SKAnswerQuestion = __SKAnswerQuestion; 44 | NSString * const SKAnswerIsAccepted = __SKAnswerIsAccepted; 45 | NSString * const SKAnswerCommentsURL = __SKAnswerCommentsURL; 46 | 47 | @implementation SKAnswer 48 | 49 | @synthesize answerID, questionID, accepted, commentsURL; 50 | 51 | + (NSString *) dataKey { 52 | return @"answers"; 53 | } 54 | 55 | - (id) initWithSite:(SKSite *)aSite dictionaryRepresentation:(NSDictionary *)dictionary { 56 | if (self = [super initWithSite:aSite dictionaryRepresentation:dictionary]) { 57 | answerID = [[dictionary objectForKey:SKAnswerID] retain]; 58 | questionID = [[dictionary objectForKey:SKAnswerQuestion] retain]; 59 | accepted = [[dictionary objectForKey:SKAnswerIsAccepted] retain]; 60 | commentsURL = [[NSURL alloc] initWithString:[dictionary objectForKey:SKAnswerCommentsURL]]; 61 | } 62 | return self; 63 | } 64 | 65 | - (void) dealloc { 66 | [answerID release]; 67 | [questionID release]; 68 | [accepted release]; 69 | [commentsURL release]; 70 | [super dealloc]; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /Classes/SKBadge.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKBadge.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKObject.h" 28 | 29 | //Enumeration for badge "levels" – bronze, silver or gold 30 | typedef enum { 31 | SKBadgeRankBronze = 0, 32 | SKBadgeRankSilver = 1, 33 | SKBadgeRankGold = 2 34 | } SKBadgeRank_t; 35 | 36 | extern NSString * const SKBadgeID; 37 | extern NSString * const SKBadgeRank; 38 | extern NSString * const SKBadgeName; 39 | extern NSString * const SKBadgeDescription; 40 | extern NSString * const SKBadgeAwardCount; 41 | extern NSString * const SKBadgeTagBased; 42 | extern NSString * const SKBadgesAwardedToUser; 43 | 44 | @interface SKBadge : SKObject { 45 | NSNumber *badgeID; 46 | 47 | NSString *name; 48 | NSString *description; 49 | 50 | SKBadgeRank_t rank; 51 | 52 | BOOL tagBased; 53 | NSNumber * numberAwarded; 54 | } 55 | 56 | @property (readonly) NSNumber *badgeID; 57 | @property (readonly) NSString *name; 58 | @property (readonly) NSString *description; 59 | @property (readonly) SKBadgeRank_t rank; 60 | 61 | @property (readonly) NSNumber * numberAwarded; 62 | @property (readonly, getter=isTagBased) BOOL tagBased; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /Classes/SKCallback.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKCallback.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Alex Rozanski 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKDefinitions.h" 28 | 29 | @class SKFetchRequest; 30 | 31 | @interface SKCallback : NSObject { 32 | #ifdef NS_BLOCKS_AVAILABLE 33 | SKFetchRequestCompletionHandler completionHandler; 34 | #endif 35 | 36 | id _target; 37 | 38 | SEL _successSelector; 39 | SEL _failureSelector; 40 | } 41 | 42 | @property (readonly) SEL successSelector; 43 | @property (readonly) SEL failureSelector; 44 | 45 | + (id)callbackWithTarget:(id)target successSelector:(SEL)onSuccess failureSelector:(SEL)onFailure; 46 | - (id)initWithTarget:(id)target successSelector:(SEL)onSuccess failureSelector:(SEL)onFailure; 47 | 48 | #ifdef NS_BLOCKS_AVAILABLE 49 | + (id) callbackWithCompletionHandler:(SKFetchRequestCompletionHandler)handler; 50 | - (id) initWithCompletionHandler:(SKFetchRequestCompletionHandler)handler; 51 | #endif 52 | 53 | - (void) fetchRequest:(SKFetchRequest *)fetchRequest failedWithError:(NSError *)argument; 54 | - (void) fetchRequest:(SKFetchRequest *)fetchRequest succeededWithResults:(NSArray *)argument; 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Classes/SKComment.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKComment.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKPost.h" 28 | 29 | //inherited 30 | extern NSString * const SKCommentCreationDate; 31 | extern NSString * const SKCommentOwner; 32 | extern NSString * const SKCommentBody; 33 | extern NSString * const SKCommentScore; 34 | 35 | extern NSString * const SKCommentID; 36 | extern NSString * const SKCommentInReplyToUser; 37 | extern NSString * const SKCommentPost; 38 | extern NSString * const SKCommentEditCount; 39 | 40 | @class SKPost; 41 | @class SKUser; 42 | 43 | @interface SKComment : SKPost { 44 | NSNumber * commentID; 45 | NSNumber * replyToUserID; 46 | NSNumber * postID; 47 | SKPostType_t postType; 48 | NSNumber * editCount; 49 | } 50 | 51 | @property (readonly) NSNumber * commentID; 52 | @property (readonly) NSNumber * replyToUserID; 53 | @property (readonly) NSNumber * postID; 54 | @property (readonly) SKPostType_t postType; 55 | @property (readonly) NSNumber * editCount; 56 | 57 | - (SKUser *) replyToUser; 58 | - (SKPost *) post; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Classes/SKConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKConstants.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | extern NSString * const SKAPIKey; 29 | extern NSString * const SKAPIVersion; 30 | 31 | #pragma mark - 32 | #pragma mark Statistics Keys 33 | extern NSString * const SKStatsTotalQuestions; 34 | extern NSString * const SKStatsTotalUnansweredQuestions; 35 | extern NSString * const SKStatsTotalAnswers; 36 | extern NSString * const SKStatsTotalComments; 37 | extern NSString * const SKStatsTotalVotes; 38 | extern NSString * const SKStatsTotalBadges; 39 | extern NSString * const SKStatsTotalUsers; 40 | extern NSString * const SKStatsQuestionsPerMinute; 41 | extern NSString * const SKStatsAnswersPerMinutes; 42 | extern NSString * const SKStatsBadgesPerMinute; 43 | 44 | extern NSString * const SKStatsAPIInfo; 45 | extern NSString * const SKStatsAPIInfoVersion; 46 | extern NSString * const SKStatsAPIInfoRevision; 47 | 48 | extern NSString * const SKStateSiteInfo; 49 | extern NSString * const SKStatsSiteInfoName; 50 | extern NSString * const SKStatsSiteInfoLogoURL; 51 | extern NSString * const SKStatsSiteInfoAPIURL; 52 | extern NSString * const SKStatsSiteInfoSiteURL; 53 | extern NSString * const SKStatsSiteInfoDescription; 54 | extern NSString * const SKStatsSiteInfoIconURL; 55 | 56 | #pragma mark - 57 | #pragma mark Error Constants 58 | extern NSString * const SKErrorDomain; 59 | extern NSString * const SKExceptionInvalidHandler; 60 | extern NSString * const SKExceptionInvalidRequest; 61 | 62 | #pragma mark Error codes 63 | extern NSUInteger const SKErrorCodeNotImplemented; 64 | extern NSUInteger const SKErrorCodeInvalidEntity; 65 | extern NSUInteger const SKErrorCodeInvalidPredicate; 66 | extern NSUInteger const SKErrorCodeUnknownError; 67 | 68 | extern NSInteger const SKErrorCodeNotFound; 69 | extern NSInteger const SKErrorCodeInternalServerError; 70 | extern NSInteger const SKErrorCodeInvalidApplicationPublicKey; 71 | extern NSInteger const SKErrorCodeInvalidPageSize; 72 | extern NSInteger const SKErrorCodeInvalidSort; 73 | extern NSInteger const SKErrorCodeInvalidOrder; 74 | extern NSInteger const SKErrorCodeRequestRateExceeded; 75 | extern NSInteger const SKErrorCodeInvalidVectorFormat; 76 | extern NSInteger const SKErrorCodeTooManyIds; 77 | extern NSInteger const SKErrorCodeUnconstrainedSearch; 78 | extern NSInteger const SKErrorCodeInvalidTags; -------------------------------------------------------------------------------- /Classes/SKDefinitions.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKDefinitions.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | #ifdef NS_BLOCKS_AVAILABLE 30 | typedef void(^SKFetchRequestCompletionHandler)(NSArray *,NSError *); 31 | #endif 32 | 33 | typedef id (*SKExtractor)(id); 34 | 35 | typedef struct _SKRange { 36 | id lower; 37 | id upper; 38 | } SKRange; 39 | 40 | #define SKNotFound nil 41 | 42 | extern SKRange const SKRangeNotFound; 43 | 44 | 45 | #ifndef SK_BOX 46 | #define SK_BOX(o,...) _sk_boxOperators(o, ##__VA_ARGS__, NSNotFound) 47 | #endif 48 | 49 | #ifndef SK_EREASON 50 | #define SK_EREASON(o,...) [NSDictionary dictionaryWithObject:[NSString stringWithFormat:(o), ##__VA_ARGS__] forKey:NSLocalizedDescriptionKey] 51 | #endif 52 | 53 | #ifndef SK_SORTERROR 54 | #define SK_SORTERROR(o,...) [NSError errorWithDomain:SKErrorDomain code:SKErrorCodeInvalidSort userInfo:SK_EREASON(o, ##__VA_ARGS__)] 55 | #endif 56 | 57 | #ifndef SK_PREDERROR 58 | #define SK_PREDERROR(o,...) [NSError errorWithDomain:SKErrorDomain code:SKErrorCodeInvalidPredicate userInfo:SK_EREASON(o, ##__VA_ARGS__)] 59 | #endif 60 | 61 | #ifndef SK_ENTERROR 62 | #define SK_ENTERROR(o,...) [NSError errorWithDomain:SKErrorDomain code:SKErrorCodeInvalidEntity userInfo:SK_EREASON(o, ##__VA_ARGS__)] 63 | #endif -------------------------------------------------------------------------------- /Classes/SKDefinitions.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKDefinitions.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "SKDefinitions.h" 27 | 28 | SKRange const SKRangeNotFound = {SKNotFound, SKNotFound}; -------------------------------------------------------------------------------- /Classes/SKFetchRequest+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKFetchRequest+Private.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | @interface SKFetchRequest () 29 | @property (retain) NSError * error; 30 | @property (retain) NSURL * fetchURL; 31 | 32 | - (NSMutableDictionary *) defaultQueryDictionary; 33 | 34 | - (NSArray *) execute; 35 | - (void) executeAsynchronously; 36 | 37 | - (NSArray *) executeFetchRequest; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Classes/SKFetchRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKFetchRequest.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKObject.h" 28 | #import "SKFetchRequestDelegate.h" 29 | 30 | @class SKCallback; 31 | 32 | @interface SKFetchRequest : SKObject { 33 | Class entity; 34 | NSSortDescriptor * sortDescriptor; 35 | NSUInteger fetchLimit; 36 | NSUInteger fetchOffset; 37 | NSNumber * fetchTotal; 38 | NSPredicate * predicate; 39 | 40 | NSError * error; 41 | id delegate; 42 | NSURL * fetchURL; 43 | 44 | SKCallback *callback; 45 | } 46 | 47 | @property Class entity; 48 | @property (retain) NSSortDescriptor * sortDescriptor; 49 | @property NSUInteger fetchLimit; 50 | @property NSUInteger fetchOffset; 51 | @property (readonly) NSNumber * fetchTotal; 52 | @property (retain) NSPredicate * predicate; 53 | @property (readonly, retain) NSError * error; 54 | @property (assign) id delegate; 55 | @property (retain) SKCallback *callback; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Classes/SKFetchRequestDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKFetchRequestDelegate.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | @class SKFetchRequest; 29 | 30 | @protocol SKFetchRequestDelegate 31 | 32 | @optional 33 | - (void) fetchRequestWillBeginExecuting:(SKFetchRequest *)request; 34 | - (void) fetchRequestDidFinishExecuting:(SKFetchRequest *)request; 35 | 36 | @required 37 | - (void) fetchRequest:(SKFetchRequest *)request didReturnResults:(NSArray *)results; 38 | - (void) fetchRequest:(SKFetchRequest *)request didFailWithError:(NSError *)error; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Classes/SKFunctions.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKFunctions.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #ifdef StackKitMobile 27 | #import 28 | #else 29 | #import 30 | #endif 31 | 32 | #import "SKDefinitions.h" 33 | 34 | @class SKFetchRequest; 35 | 36 | BOOL sk_classIsSubclassOfClass(Class aClass, Class targetSuper); 37 | NSArray* _sk_boxOperators(NSUInteger operator, ...); 38 | 39 | void SKQLog(NSString *format, ...); 40 | 41 | id SKInvalidPredicateErrorForFetchRequest(SKFetchRequest * request, NSDictionary * userInfo); 42 | 43 | BOOL SKIsVectorClass(id value); 44 | NSString * SKExtractVector(id value, SKExtractor extractor); 45 | NSString * SKVectorizedCollection(id value); 46 | 47 | id SKExtractPostID(id value); 48 | id SKExtractCommentID(id value); 49 | id SKExtractQuestionID(id value); 50 | id SKExtractAnswerID(id value); 51 | id SKExtractUserID(id value); 52 | id SKExtractBadgeID(id value); 53 | id SKExtractTagName(id value); 54 | 55 | NSDate * SKExtractDate(id value); 56 | NSUInteger SKExtractInteger(id value); 57 | 58 | #ifdef StackKitMobile 59 | UIColor * SKColorFromHexString(NSString * hexString); 60 | #else 61 | NSColor * SKColorFromHexString(NSString * hexString); 62 | #endif 63 | -------------------------------------------------------------------------------- /Classes/SKObject+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKObject+Private.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKObject.h" 28 | 29 | @class SKSite; 30 | @class SKFetchRequest; 31 | 32 | @interface SKObject () 33 | 34 | - (void) setSite:(SKSite *)newSite; 35 | 36 | //the designated initializers for SKObject SUBCLASSES 37 | + (id) objectWithSite:(SKSite *)aSite dictionaryRepresentation:(NSDictionary *)dictionary; 38 | - (id) initWithSite:(SKSite *)aSite dictionaryRepresentation:(NSDictionary *)dictionary; 39 | 40 | #pragma mark Class methods implemented by SKObject 41 | // used in valueForKey: 42 | + (NSString *) propertyKeyFromAPIAttributeKey:(NSString *)key; 43 | 44 | #pragma mark Class methods that should be overriden by subclasses 45 | // used to help valueForKey: out so that we can request properties via the constants (SKQuestionID vs @"questionID", for example) 46 | + (NSDictionary *) APIAttributeToPropertyMapping; 47 | // the key used to extract information from the JSON response 48 | + (NSString *) dataKey; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Classes/SKObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKObject.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKConstants.h" 28 | 29 | @class SKSite; 30 | 31 | @interface SKObject : NSObject { 32 | __weak SKSite * site; 33 | } 34 | 35 | @property (readonly) __weak SKSite * site; 36 | 37 | - (id) initWithSite:(SKSite *)aSite; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Classes/SKPost.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKPost.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKObject.h" 28 | 29 | extern NSString * const SKPostCreationDate; 30 | extern NSString * const SKPostOwner; 31 | extern NSString * const SKPostBody; 32 | extern NSString * const SKPostScore; 33 | 34 | typedef enum { 35 | SKPostTypeQuestion = 0, 36 | SKPostTypeAnswer = 1 37 | } SKPostType_t; 38 | 39 | @class SKUser; 40 | 41 | @interface SKPost : SKObject { 42 | NSNumber * ownerID; 43 | NSDate * creationDate; 44 | NSString * body; 45 | NSNumber * score; 46 | } 47 | 48 | @property (readonly) NSDate * creationDate; 49 | @property (readonly) NSNumber * ownerID; 50 | @property (readonly) NSString * body; 51 | @property (readonly) NSNumber * score; 52 | 53 | - (SKUser *)owner; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Classes/SKPost.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKPost.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "StackKit_Internal.h" 27 | 28 | NSString * const SKPostCreationDate = __SKPostCreationDate; 29 | NSString * const SKPostOwner = __SKPostOwner; 30 | NSString * const SKPostBody = __SKPostBody; 31 | NSString * const SKPostScore = __SKPostScore; 32 | 33 | @implementation SKPost 34 | 35 | @synthesize creationDate, ownerID, body, score; 36 | 37 | + (NSDictionary *) APIAttributeToPropertyMapping { 38 | return [NSDictionary dictionaryWithObjectsAndKeys: 39 | @"ownerID", SKPostOwner, 40 | @"creationDate", SKPostCreationDate, 41 | nil]; 42 | } 43 | 44 | - (id) initWithSite:(SKSite *)aSite dictionaryRepresentation:(NSDictionary *)dictionary { 45 | if (self = [super initWithSite:aSite]) { 46 | creationDate = [[NSDate dateWithTimeIntervalSince1970:[[dictionary objectForKey:SKPostCreationDate] doubleValue]] retain]; 47 | 48 | NSDictionary * ownerDictionary = [dictionary objectForKey:SKPostOwner]; 49 | ownerID = [[ownerDictionary objectForKey:SKUserID] retain]; 50 | 51 | body = [[dictionary objectForKey:SKPostBody] retain]; 52 | score = [[dictionary objectForKey:SKPostScore] retain]; 53 | } 54 | return self; 55 | } 56 | 57 | - (void) dealloc { 58 | [creationDate release]; 59 | [ownerID release]; 60 | [body release]; 61 | [score release]; 62 | [super dealloc]; 63 | } 64 | 65 | - (SKUser *)owner { 66 | return [[self site] userWithID:[self ownerID]]; 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /Classes/SKQAPost.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKQAPost.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKPost.h" 28 | 29 | //inherited 30 | extern NSString * const SKQAPostCreationDate; 31 | extern NSString * const SKQAPostOwner; 32 | extern NSString * const SKQAPostBody; 33 | extern NSString * const SKQAPostScore; 34 | 35 | extern NSString * const SKQAPostLockedDate; 36 | extern NSString * const SKQAPostLastEditDate; 37 | extern NSString * const SKQAPostLastActivityDate; 38 | extern NSString * const SKQAPostUpVotes; 39 | extern NSString * const SKQAPostDownVotes; 40 | extern NSString * const SKQAPostViewCount; 41 | extern NSString * const SKQAPostCommunityOwned; 42 | extern NSString * const SKQAPostTitle; 43 | 44 | @interface SKQAPost : SKPost { 45 | NSDate * lockedDate; 46 | NSDate * lastEditDate; 47 | NSDate * lastActivityDate; 48 | NSNumber * upVotes; 49 | NSNumber * downVotes; 50 | NSNumber * viewCount; 51 | NSNumber * communityOwned; 52 | NSString * title; 53 | } 54 | 55 | @property (readonly) NSDate * lockedDate; 56 | @property (readonly) NSDate * lastEditDate; 57 | @property (readonly) NSDate * lastActivityDate; 58 | @property (readonly) NSNumber * upVotes; 59 | @property (readonly) NSNumber * downVotes; 60 | @property (readonly) NSNumber * viewCount; 61 | @property (readonly) NSNumber * communityOwned; 62 | @property (readonly) NSString * title; 63 | 64 | @property (readonly) NSURL * commentsURL; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Classes/SKQuestion.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKQuestion.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKQuestion.h" 28 | 29 | //inherited 30 | extern NSString * const SKQuestionCreationDate; 31 | extern NSString * const SKQuestionOwner; 32 | extern NSString * const SKQuestionBody; 33 | extern NSString * const SKQuestionScore; 34 | extern NSString * const SKQuestionLockedDate; 35 | extern NSString * const SKQuestionLastEditDate; 36 | extern NSString * const SKQuestionLastActivityDate; 37 | extern NSString * const SKQuestionUpVotes; 38 | extern NSString * const SKQuestionDownVotes; 39 | extern NSString * const SKQuestionViewCount; 40 | extern NSString * const SKQuestionCommunityOwned; 41 | extern NSString * const SKQuestionTitle; 42 | 43 | extern NSString * const SKQuestionID; 44 | extern NSString * const SKQuestionTags; 45 | extern NSString * const SKQuestionAnswerCount; 46 | extern NSString * const SKQuestionAcceptedAnswer; 47 | extern NSString * const SKQuestionFavoriteCount; 48 | extern NSString * const SKQuestionBountyCloseDate; 49 | extern NSString * const SKQuestionBountyAmount; 50 | extern NSString * const SKQuestionCloseDate; 51 | extern NSString * const SKQuestionCloseReason; 52 | extern NSString * const SKQuestionTimelineURL; 53 | extern NSString * const SKQuestionCommentsURL; 54 | extern NSString * const SKQuestionAnswersURL; 55 | 56 | extern NSString * const SKQuestionsFavoritedByUser; 57 | extern NSString * const SKQuestionFavoritedDate; 58 | 59 | @interface SKQuestion : SKQAPost { 60 | NSNumber * questionID; 61 | 62 | NSArray * tags; 63 | NSNumber * answerCount; 64 | NSNumber * acceptedAnswerID; 65 | NSNumber * favoriteCount; 66 | NSDate * bountyCloseDate; 67 | NSNumber * bountyAmount; 68 | NSDate * closeDate; 69 | NSString * closeReason; 70 | 71 | NSURL * timelineURL; 72 | NSURL * commentsURL; 73 | NSURL * answersURL; 74 | } 75 | 76 | @property (readonly) NSNumber * questionID; 77 | @property (readonly) NSArray * tags; 78 | @property (readonly) NSNumber * answerCount; 79 | @property (readonly) NSNumber * acceptedAnswerID; 80 | @property (readonly) NSNumber * favoriteCount; 81 | @property (readonly) NSDate * bountyCloseDate; 82 | @property (readonly) NSNumber * bountyAmount; 83 | @property (readonly) NSDate * closeDate; 84 | @property (readonly) NSString * closeReason; 85 | @property (readonly) NSURL * timelineURL; 86 | @property (readonly) NSURL * commentsURL; 87 | @property (readonly) NSURL * answersURL; 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /Classes/SKRequestBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKRequestBuilder.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "StackKit_Internal.h" 28 | 29 | @interface SKRequestBuilder : NSObject { 30 | 31 | } 32 | 33 | + (NSURL *) URLForFetchRequest:(SKFetchRequest *)fetchRequest error:(NSError **)error; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Classes/SKSite+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKSite+Private.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKSite.h" 28 | #import "SKUser.h" 29 | #import "SKTag.h" 30 | #import "SKPost.h" 31 | 32 | @interface SKSite () 33 | 34 | @property (readwrite, retain) NSURL * apiURL; 35 | 36 | @property (readwrite, copy) NSString * name; 37 | @property (readwrite, retain) NSURL * siteURL; 38 | @property (readwrite, retain) NSURL * logoURL; 39 | @property (readwrite, retain) NSURL * iconURL; 40 | @property (readwrite, copy) NSString * summary; 41 | @property (readwrite) SKSiteState state; 42 | @property (readwrite, retain) NSDictionary * stylingInformation; 43 | 44 | /**- (void) cacheUser:(SKUser *)newUser; 45 | - (void) cacheTag:(SKTag *)newTag; 46 | - (void) cachePost:(SKPost *)newPost; 47 | - (void) cacheBadge:(SKBadge *)newBadge;**/ 48 | 49 | - (void) asynchronousStatistics; 50 | - (NSDictionary *) statisticsWithError:(NSError **)error; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /Classes/SKSiteDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKSiteDelegate.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | @class SKSite; 29 | 30 | @protocol SKSiteDelegate 31 | 32 | @required 33 | - (void) site:(SKSite *)site didRetrieveStatistics:(NSDictionary *)statistics error:(NSError *)error; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Classes/SKTag.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKTag.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKObject.h" 28 | 29 | extern NSString * const SKTagName; 30 | extern NSString * const SKTagCount; 31 | extern NSString * const SKTagsParticipatedInByUser; 32 | 33 | extern NSString * const SKTagNumberOfTaggedQuestions; 34 | extern NSString * const SKTagLastUsedDate; 35 | 36 | @interface SKTag : SKObject { 37 | NSString *name; 38 | 39 | NSNumber * numberOfTaggedQuestions; 40 | } 41 | 42 | @property (readonly) NSString *name; 43 | @property (readonly) NSNumber * numberOfTaggedQuestions; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Classes/SKTag.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKTag.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "StackKit_Internal.h" 27 | 28 | NSString * const SKTagName = @"name"; 29 | NSString * const SKTagCount = @"count"; 30 | NSString * const SKTagsParticipatedInByUser = __SKUserID; 31 | 32 | NSString * const SKTagNumberOfTaggedQuestions = @"tag_popular"; 33 | NSString * const SKTagLastUsedDate = @"tag_activity"; 34 | 35 | NSUInteger SKTagDefaultPageSize = 70; 36 | 37 | @implementation SKTag 38 | 39 | @synthesize name; 40 | @synthesize numberOfTaggedQuestions; 41 | 42 | + (NSDictionary *) APIAttributeToPropertyMapping { 43 | static NSDictionary * _kSKTagMappings = nil; 44 | if (_kSKTagMappings == nil) { 45 | _kSKTagMappings = [[NSDictionary alloc] initWithObjectsAndKeys: 46 | @"name", SKTagName, 47 | @"numberOfTaggedQuestions", SKTagCount, 48 | nil]; 49 | } 50 | return _kSKTagMappings; 51 | } 52 | 53 | + (NSString *) dataKey { 54 | return @"tags"; 55 | } 56 | 57 | - (id) initWithSite:(SKSite *)aSite dictionaryRepresentation:(NSDictionary *)dictionary { 58 | if (self = [super initWithSite:aSite]) { 59 | name = [[dictionary objectForKey:SKTagName] retain]; 60 | numberOfTaggedQuestions = [[dictionary objectForKey:SKTagCount] retain]; 61 | } 62 | return self; 63 | } 64 | 65 | - (BOOL) isEqual:(id)object { 66 | if ([object isKindOfClass:[self class]] == NO) { 67 | return NO; 68 | } 69 | 70 | return ([[self name] isEqual:[object name]]&&[[self site] isEqual:[object site]]); 71 | } 72 | 73 | - (void) dealloc { 74 | [name release]; 75 | [numberOfTaggedQuestions release]; 76 | [super dealloc]; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Classes/SKUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKUser.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKObject.h" 28 | 29 | extern NSString * const SKUserID; 30 | 31 | extern NSString * const SKUserReputation; 32 | extern NSString * const SKUserCreationDate; 33 | extern NSString * const SKUserDisplayName; 34 | extern NSString * const SKUserEmailHash; 35 | extern NSString * const SKUserAge; 36 | extern NSString * const SKUserLastAccessDate; 37 | extern NSString * const SKUserWebsiteURL; 38 | extern NSString * const SKUserLocation; 39 | extern NSString * const SKUserAboutMe; 40 | extern NSString * const SKUserViews; 41 | extern NSString * const SKUserUpVotes; 42 | extern NSString * const SKUserDownVotes; 43 | extern NSString * const SKUserType; 44 | extern NSString * const SKUserAcceptRate; 45 | 46 | extern NSString * const SKUserBadges; 47 | 48 | typedef enum { 49 | SKUserTypeAnonymous = 0, 50 | SKUserTypeUnregistered = 1, 51 | SKUserTypeRegistered = 2, 52 | SKUserTypeModerator = 3 53 | } SKUserType_t; 54 | 55 | @class SKSite; 56 | 57 | @interface SKUser : SKObject { 58 | 59 | NSNumber * userID; 60 | NSNumber * reputation; 61 | NSDate * creationDate; 62 | NSString * displayName; 63 | NSString * emailHash; 64 | NSNumber * age; 65 | NSDate * lastAccessDate; 66 | NSURL * websiteURL; 67 | NSString * location; 68 | NSString * aboutMe; 69 | NSNumber * views; 70 | NSNumber * upVotes; 71 | NSNumber * downVotes; 72 | SKUserType_t userType; 73 | NSNumber * acceptRate; 74 | } 75 | 76 | @property (readonly) NSNumber * userID; 77 | @property (readonly) NSNumber * reputation; 78 | @property (readonly) NSDate * creationDate; 79 | @property (readonly) NSString * displayName; 80 | @property (readonly) NSString * emailHash; 81 | @property (readonly) NSNumber * age; 82 | @property (readonly) NSDate * lastAccessDate; 83 | @property (readonly) NSURL * websiteURL; 84 | @property (readonly) NSString * location; 85 | @property (readonly) NSString * aboutMe; 86 | @property (readonly) NSNumber * views; 87 | @property (readonly) NSNumber * upVotes; 88 | @property (readonly) NSNumber * downVotes; 89 | @property (readonly) SKUserType_t userType; 90 | @property (readonly) NSNumber * acceptRate; 91 | 92 | - (NSArray *) badges; 93 | - (NSArray *) tags; 94 | 95 | - (NSURL *) gravatarIconURL; 96 | - (NSURL *) gravatarIconURLForSize:(CGSize)size; 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /Classes/SKUserActivity.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKUserActivity.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "SKObject.h" 28 | #import "SKPost.h" 29 | 30 | typedef enum { 31 | SKUserActivityTypeComment = 0, 32 | SKUserActivityTypeRevision = 1, 33 | SKUserActivityTypeBadge = 2, 34 | SKUserActivityTypeAskOrAnswered = 3, 35 | SKUserActivityTypeAccepted = 4 36 | } SKUserActivityType_t; 37 | 38 | typedef enum { 39 | SKUserActivityActionTypeComment = 0, 40 | SKUserActivityActionTypeRevised = 1, 41 | SKUserActivityActionTypeAwarded = 2, 42 | SKUserActivityActionTypeAnswered = 3 43 | } SKUserActivityActionType_t; 44 | 45 | extern NSString * const SKUserActivityType; 46 | extern NSString * const SKUserActivityPostID; 47 | extern NSString * const SKUserActivityPostType; 48 | extern NSString * const SKUserActivityCommentID; 49 | extern NSString * const SKUserActivityAction; 50 | extern NSString * const SKUserActivityCreationDate; 51 | extern NSString * const SKUserActivityDescription; 52 | extern NSString * const SKUserActivityDetail; 53 | 54 | @interface SKUserActivity : SKObject { 55 | SKUserActivityType_t type; 56 | 57 | NSNumber * postID; 58 | SKPostType_t postType; 59 | 60 | NSNumber * commentID; 61 | 62 | SKUserActivityActionType_t action; 63 | 64 | NSDate * creationDate; 65 | 66 | NSString * activityDescription; 67 | NSString * activityDetail; 68 | } 69 | 70 | @property (readonly) SKUserActivityType_t type; 71 | @property (readonly) NSNumber * postID; 72 | @property (readonly) SKPostType_t postType; 73 | @property (readonly) NSNumber * commentID; 74 | @property (readonly) SKUserActivityActionType_t action; 75 | @property (readonly) NSDate * creationDate; 76 | @property (readonly) NSString * activityDescription; 77 | @property (readonly) NSString * activityDetail; 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Classes/StackKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // StackKit.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR 27 | #define StackKitMobile 1 28 | #else 29 | #define StackKitMac 1 30 | #endif 31 | 32 | #if StackKitMobile 33 | #import 34 | #else 35 | #import 36 | #endif 37 | 38 | #import "SKObject.h" 39 | 40 | #import "SKFetchRequest.h" 41 | #import "SKFetchRequestDelegate.h" 42 | #import "SKCallback.h" 43 | 44 | #import "SKSite.h" 45 | #import "SKSiteDelegate.h" 46 | 47 | #import "SKUser.h" 48 | #import "SKTag.h" 49 | #import "SKBadge.h" 50 | #import "SKUserActivity.h" 51 | 52 | #import "SKPost.h" 53 | #import "SKQAPost.h" 54 | #import "SKQuestion.h" 55 | #import "SKAnswer.h" 56 | #import "SKComment.h" 57 | 58 | #import "SKConstants.h" 59 | #import "SKDefinitions.h" 60 | -------------------------------------------------------------------------------- /Classes/StackKit_Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // StackKit_Internal.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "StackKit.h" 27 | #import "SKConstants_Internal.h" 28 | #import "SKFunctions.h" 29 | 30 | #import "SKObject+Private.h" 31 | #import "SKSite+Private.h" 32 | #import "SKFetchRequest+Private.h" 33 | 34 | #import "NSNumberFormatter+SKAdditions.h" 35 | #import "NSDate+SKAdditions.h" 36 | #import "NSPredicate+SKAdditions.h" 37 | #import "NSDictionary+SKAdditions.h" 38 | #import "NSString+SKAdditions.h" 39 | #import "NSNumber+SKAdditions.h" 40 | #import "JSON.h" 41 | 42 | #import "SKRequestBuilder.h" -------------------------------------------------------------------------------- /Classes/_SKConcreteRequestBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKConcreteRequestBuilder.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "StackKit_Internal.h" 28 | 29 | @interface _SKConcreteRequestBuilder : NSObject { 30 | @private 31 | SKFetchRequest * fetchRequest; 32 | NSError * error; 33 | NSURL * URL; 34 | NSMutableDictionary * query; 35 | NSString * path; 36 | } 37 | 38 | @property (nonatomic, readonly) SKFetchRequest * fetchRequest; 39 | @property (nonatomic, retain) NSError * error; 40 | @property (nonatomic, readonly, retain) NSURL * URL; 41 | @property (nonatomic, readonly) NSMutableDictionary * query; 42 | @property (nonatomic, copy) NSString * path; 43 | 44 | + (Class) recognizedFetchEntity; 45 | + (BOOL) recognizesAPredicate; 46 | + (NSDictionary *) recognizedPredicateKeyPaths; 47 | + (NSSet *) requiredPredicateKeyPaths; 48 | + (BOOL) recognizesASortDescriptor; 49 | + (NSDictionary *) recognizedSortDescriptorKeys; 50 | 51 | - (id) initWithFetchRequest:(SKFetchRequest *)request; 52 | 53 | @end 54 | 55 | @interface _SKConcreteRequestBuilder (SubclassMethods) 56 | 57 | - (void) buildURL; 58 | - (NSPredicate *) requestPredicate; 59 | - (NSSortDescriptor *) requestSortDescriptor; 60 | 61 | @end -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderAllBadges.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderAllBadges.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderAllBadges : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderAllBadges.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderAllBadges.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderAllBadges.h" 27 | 28 | 29 | @implementation _SKRequestBuilderAllBadges 30 | 31 | + (BOOL) recognizesAPredicate { 32 | return NO; 33 | } 34 | 35 | + (Class) recognizedFetchEntity { 36 | return [SKBadge class]; 37 | } 38 | 39 | + (NSDictionary *) recognizedSortDescriptorKeys { 40 | return [NSDictionary dictionaryWithObjectsAndKeys: 41 | SKSortName, SKBadgeName, 42 | nil]; 43 | } 44 | 45 | - (void) buildURL { 46 | if ([[self requestSortDescriptor] ascending] == NO) { 47 | [self setError:SK_SORTERROR(@"Badges can only be requested in ascending order")]; 48 | } else { 49 | [self setPath:@"/badges"]; 50 | [super buildURL]; 51 | } 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderAnswersByID.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderAnswersByID.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderAnswersByID : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderAnswersByID.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderAnswersByID.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderAnswersByID.h" 27 | 28 | 29 | @implementation _SKRequestBuilderAnswersByID 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKAnswer class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKAnswerID, 38 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKAnswerCreationDate, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKAnswerLastActivityDate, 40 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKAnswerViewCount, 41 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKAnswerScore, 42 | nil]; 43 | } 44 | 45 | + (NSSet *) requiredPredicateKeyPaths { 46 | return [NSSet setWithObjects: 47 | SKAnswerID, 48 | nil]; 49 | } 50 | 51 | + (NSDictionary *) recognizedSortDescriptorKeys { 52 | return [NSDictionary dictionaryWithObjectsAndKeys: 53 | SKSortActivity, SKAnswerLastActivityDate, 54 | SKSortViews, SKAnswerViewCount, 55 | SKSortCreation, SKAnswerCreationDate, 56 | SKSortVotes, SKAnswerScore, 57 | nil]; 58 | } 59 | 60 | - (void) buildURL { 61 | NSPredicate * p = [self requestPredicate]; 62 | id answerIDs = [p constantValueForLeftKeyPath:SKAnswerID]; 63 | [self setPath:[NSString stringWithFormat:@"/answers/%@", SKExtractAnswerID(answerIDs)]]; 64 | 65 | SKRange dateRange = [p rangeOfConstantValuesForLeftKeyPath:SKAnswerCreationDate]; 66 | if (dateRange.lower != SKNotFound) { 67 | [[self query] setObject:dateRange.lower forKey:SKQueryFromDate]; 68 | } 69 | if (dateRange.upper != SKNotFound) { 70 | [[self query] setObject:dateRange.upper forKey:SKQueryToDate]; 71 | } 72 | 73 | if ([self requestSortDescriptor] != nil && ![[[self requestSortDescriptor] key] isEqual:SKAnswerCreationDate]) { 74 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 75 | if (sortRange.lower != SKNotFound) { 76 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 77 | } 78 | if (sortRange.upper != SKNotFound) { 79 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 80 | } 81 | } 82 | 83 | [super buildURL]; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderAnswersForQuestion.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderAnswersForQuestion.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderAnswersForQuestion : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderAnswersForUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderAnswersForUser.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderAnswersForUser : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderBadgesForUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderBadgesForUser.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderBadgesForUser : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderBadgesForUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderBadgesForUser.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderBadgesForUser.h" 27 | 28 | 29 | @implementation _SKRequestBuilderBadgesForUser 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKBadge class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKBadgesAwardedToUser, 38 | nil]; 39 | } 40 | 41 | + (NSSet *) requiredPredicateKeyPaths { 42 | return [NSSet setWithObjects: 43 | SKBadgesAwardedToUser, 44 | nil]; 45 | } 46 | 47 | + (BOOL) recognizesASortDescriptor { 48 | return NO; 49 | } 50 | 51 | - (void) buildURL { 52 | NSPredicate * p = [self requestPredicate]; 53 | 54 | id users = [p constantValueForLeftKeyPath:SKBadgesAwardedToUser]; 55 | [self setPath:[NSString stringWithFormat:@"/users/%@/badges", SKExtractUserID(users)]]; 56 | 57 | [super buildURL]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsByID.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsByID.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderCommentsByID : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsByID.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsByID.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderCommentsByID.h" 27 | 28 | 29 | @implementation _SKRequestBuilderCommentsByID 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKComment class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKCommentID, 38 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentCreationDate, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentScore, 40 | nil]; 41 | } 42 | 43 | + (NSSet *) requiredPredicateKeyPaths { 44 | return [NSSet setWithObjects: 45 | SKCommentID, 46 | nil]; 47 | } 48 | 49 | + (NSDictionary *) recognizedSortDescriptorKeys { 50 | return [NSDictionary dictionaryWithObjectsAndKeys: 51 | SKSortCreation, SKCommentCreationDate, 52 | SKSortVotes, SKCommentScore, 53 | nil]; 54 | } 55 | 56 | - (void) buildURL { 57 | NSPredicate * p = [self requestPredicate]; 58 | id commentIDs = [p constantValueForLeftKeyPath:SKCommentID]; 59 | [self setPath:[NSString stringWithFormat:@"/comments/%@", SKExtractCommentID(commentIDs)]]; 60 | 61 | SKRange dateRange = [p rangeOfConstantValuesForLeftKeyPath:SKCommentCreationDate]; 62 | if (dateRange.lower != SKNotFound) { 63 | [[self query] setObject:dateRange.lower forKey:SKQueryFromDate]; 64 | } 65 | if (dateRange.upper != SKNotFound) { 66 | [[self query] setObject:dateRange.upper forKey:SKQueryToDate]; 67 | } 68 | 69 | if ([self requestSortDescriptor] != nil && ![[[self requestSortDescriptor] key] isEqual:SKCommentCreationDate]) { 70 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 71 | if (sortRange.lower != SKNotFound) { 72 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 73 | } 74 | if (sortRange.upper != SKNotFound) { 75 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 76 | } 77 | } 78 | 79 | [super buildURL]; 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsByUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsByUser.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderCommentsByUser : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsByUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsByUser.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderCommentsByUser.h" 27 | 28 | 29 | @implementation _SKRequestBuilderCommentsByUser 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKComment class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKCommentOwner, 38 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentCreationDate, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentScore, 40 | nil]; 41 | } 42 | 43 | + (NSSet *) requiredPredicateKeyPaths { 44 | return [NSSet setWithObjects: 45 | SKCommentOwner, 46 | nil]; 47 | } 48 | 49 | + (NSDictionary *) recognizedSortDescriptorKeys { 50 | return [NSDictionary dictionaryWithObjectsAndKeys: 51 | SKSortCreation, SKCommentCreationDate, 52 | SKSortVotes, SKCommentScore, 53 | nil]; 54 | } 55 | 56 | - (void) buildURL { 57 | NSPredicate * p = [self requestPredicate]; 58 | 59 | id users = [p constantValueForLeftKeyPath:SKCommentOwner]; 60 | [self setPath:[NSString stringWithFormat:@"/users/%@/comments", SKExtractUserID(users)]]; 61 | 62 | SKRange dateRange = [p rangeOfConstantValuesForLeftKeyPath:SKCommentCreationDate]; 63 | if (dateRange.lower != SKNotFound) { 64 | [[self query] setObject:dateRange.lower forKey:SKQueryFromDate]; 65 | } 66 | if (dateRange.upper != SKNotFound) { 67 | [[self query] setObject:dateRange.upper forKey:SKQueryToDate]; 68 | } 69 | 70 | if ([self requestSortDescriptor] != nil && ![[[self requestSortDescriptor] key] isEqual:SKCommentCreationDate]) { 71 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 72 | if (sortRange.lower != SKNotFound) { 73 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 74 | } 75 | if (sortRange.upper != SKNotFound) { 76 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 77 | } 78 | } 79 | 80 | [super buildURL]; 81 | } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsForAnswer.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderAnswerComments.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderCommentsForAnswer : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsForAnswer.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderAnswerComments.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderCommentsForAnswer.h" 27 | 28 | 29 | @implementation _SKRequestBuilderCommentsForAnswer 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKComment class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKAnswerID, 38 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentCreationDate, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentScore, 40 | nil]; 41 | } 42 | 43 | // Either SKAnswerID or SKCommentAnswer are required, but SKAnswerID has the same value as SKCommentAnswer 44 | + (NSSet *) requiredPredicateKeyPaths { 45 | return [NSSet setWithObjects: 46 | SKAnswerID, 47 | nil]; 48 | } 49 | 50 | + (NSDictionary *) recognizedSortDescriptorKeys { 51 | return [NSDictionary dictionaryWithObjectsAndKeys: 52 | SKSortCreation, SKCommentCreationDate, 53 | SKSortVotes, SKCommentScore, 54 | nil]; 55 | } 56 | 57 | - (void) buildURL { 58 | NSPredicate * p = [self requestPredicate]; 59 | id answerIDs = [p constantValueForLeftKeyPath:SKAnswerID]; 60 | [self setPath:[NSString stringWithFormat:@"/answers/%@/comments", SKExtractAnswerID(answerIDs)]]; 61 | 62 | SKRange dateRange = [p rangeOfConstantValuesForLeftKeyPath:SKCommentCreationDate]; 63 | if (dateRange.lower != SKNotFound) { 64 | [[self query] setObject:dateRange.lower forKey:SKQueryFromDate]; 65 | } 66 | if (dateRange.upper != SKNotFound) { 67 | [[self query] setObject:dateRange.upper forKey:SKQueryToDate]; 68 | } 69 | 70 | if ([self requestSortDescriptor] != nil && ![[[self requestSortDescriptor] key] isEqual:SKCommentCreationDate]) { 71 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 72 | if (sortRange.lower != SKNotFound) { 73 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 74 | } 75 | if (sortRange.upper != SKNotFound) { 76 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 77 | } 78 | } 79 | 80 | [super buildURL]; 81 | } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsForQuestion.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsForQuestion.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderCommentsForQuestion : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsForQuestion.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsForQuestion.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderCommentsForQuestion.h" 27 | 28 | 29 | @implementation _SKRequestBuilderCommentsForQuestion 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKComment class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKQuestionID, 38 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentCreationDate, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentScore, 40 | nil]; 41 | } 42 | 43 | + (NSSet *) requiredPredicateKeyPaths { 44 | return [NSSet setWithObjects: 45 | SKQuestionID, 46 | nil]; 47 | } 48 | 49 | + (NSDictionary *) recognizedSortDescriptorKeys { 50 | return [NSDictionary dictionaryWithObjectsAndKeys: 51 | SKSortCreation, SKCommentCreationDate, 52 | SKSortVotes, SKCommentScore, 53 | nil]; 54 | } 55 | 56 | - (void) buildURL { 57 | NSPredicate * p = [self requestPredicate]; 58 | [[self query] setObject:SKQueryTrue forKey:SKQueryBody]; 59 | 60 | id questionIDs = [p constantValueForLeftKeyPath:SKQuestionID]; 61 | [self setPath:[NSString stringWithFormat:@"/questions/%@/comments", SKExtractQuestionID(questionIDs)]]; 62 | 63 | SKRange dateRange = [p rangeOfConstantValuesForLeftKeyPath:SKCommentCreationDate]; 64 | if (dateRange.lower != SKNotFound) { 65 | [[self query] setObject:dateRange.lower forKey:SKQueryFromDate]; 66 | } 67 | if (dateRange.upper != SKNotFound) { 68 | [[self query] setObject:dateRange.upper forKey:SKQueryToDate]; 69 | } 70 | 71 | if ([self requestSortDescriptor] != nil && ![[[self requestSortDescriptor] key] isEqual:SKCommentCreationDate]) { 72 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 73 | if (sortRange.lower != SKNotFound) { 74 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 75 | } 76 | if (sortRange.upper != SKNotFound) { 77 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 78 | } 79 | } 80 | 81 | [super buildURL]; 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsFromUserToUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsFromUserToUser.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderCommentsFromUserToUser : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsFromUserToUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsFromUserToUser.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderCommentsFromUserToUser.h" 27 | 28 | 29 | @implementation _SKRequestBuilderCommentsFromUserToUser 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKComment class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKCommentOwner, 38 | SK_BOX(NSEqualToPredicateOperatorType), SKCommentInReplyToUser, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentCreationDate, 40 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentScore, 41 | nil]; 42 | } 43 | 44 | + (NSSet *) requiredPredicateKeyPaths { 45 | return [NSSet setWithObjects: 46 | SKCommentOwner, 47 | SKCommentInReplyToUser, 48 | nil]; 49 | } 50 | 51 | + (NSDictionary *) recognizedSortDescriptorKeys { 52 | return [NSDictionary dictionaryWithObjectsAndKeys: 53 | SKSortCreation, SKCommentCreationDate, 54 | SKSortVotes, SKCommentScore, 55 | nil]; 56 | } 57 | 58 | - (void) buildURL { 59 | NSPredicate * p = [self requestPredicate]; 60 | 61 | id users = [p constantValueForLeftKeyPath:SKCommentOwner]; 62 | id touser = [p constantValueForLeftKeyPath:SKCommentInReplyToUser]; 63 | [self setPath:[NSString stringWithFormat:@"/users/%@/comments/%@", SKExtractUserID(users), SKExtractUserID(touser)]]; 64 | [[self query] setObject:SKQueryTrue forKey:SKQueryBody]; 65 | 66 | SKRange dateRange = [p rangeOfConstantValuesForLeftKeyPath:SKCommentCreationDate]; 67 | if (dateRange.lower != SKNotFound) { 68 | [[self query] setObject:dateRange.lower forKey:SKQueryFromDate]; 69 | } 70 | if (dateRange.upper != SKNotFound) { 71 | [[self query] setObject:dateRange.upper forKey:SKQueryToDate]; 72 | } 73 | 74 | if ([self requestSortDescriptor] != nil && ![[[self requestSortDescriptor] key] isEqual:SKCommentCreationDate]) { 75 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 76 | if (sortRange.lower != SKNotFound) { 77 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 78 | } 79 | if (sortRange.upper != SKNotFound) { 80 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 81 | } 82 | } 83 | 84 | [super buildURL]; 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsToUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsToUser.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderCommentsToUser : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderCommentsToUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderCommentsToUser.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderCommentsToUser.h" 27 | 28 | 29 | @implementation _SKRequestBuilderCommentsToUser 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKComment class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKCommentInReplyToUser, 38 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentCreationDate, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKCommentScore, 40 | nil]; 41 | } 42 | 43 | + (NSSet *) requiredPredicateKeyPaths { 44 | return [NSSet setWithObjects: 45 | SKCommentInReplyToUser, 46 | nil]; 47 | } 48 | 49 | + (NSDictionary *) recognizedSortDescriptorKeys { 50 | return [NSDictionary dictionaryWithObjectsAndKeys: 51 | SKSortCreation, SKCommentCreationDate, 52 | SKSortVotes, SKCommentScore, 53 | nil]; 54 | } 55 | 56 | - (void) buildURL { 57 | NSPredicate * p = [self requestPredicate]; 58 | 59 | id users = [p constantValueForLeftKeyPath:SKCommentInReplyToUser]; 60 | [self setPath:[NSString stringWithFormat:@"/users/%@/mentioned", SKExtractUserID(users)]]; 61 | [[self query] setObject:SKQueryTrue forKey:SKQueryBody]; 62 | 63 | SKRange dateRange = [p rangeOfConstantValuesForLeftKeyPath:SKCommentCreationDate]; 64 | if (dateRange.lower != SKNotFound) { 65 | [[self query] setObject:dateRange.lower forKey:SKQueryFromDate]; 66 | } 67 | if (dateRange.upper != SKNotFound) { 68 | [[self query] setObject:dateRange.upper forKey:SKQueryToDate]; 69 | } 70 | 71 | if ([self requestSortDescriptor] != nil && ![[[self requestSortDescriptor] key] isEqual:SKCommentCreationDate]) { 72 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 73 | if (sortRange.lower != SKNotFound) { 74 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 75 | } 76 | if (sortRange.upper != SKNotFound) { 77 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 78 | } 79 | } 80 | 81 | [super buildURL]; 82 | } 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderFavoritedQuestions.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderFavoritedQuestions.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderFavoritedQuestions : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderNameBadges.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderNameBadges.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderNameBadges : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderNameBadges.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderNameBadges.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderNameBadges.h" 27 | 28 | 29 | @implementation _SKRequestBuilderNameBadges 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKBadge class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType), SKBadgeTagBased, 38 | nil]; 39 | } 40 | 41 | + (NSSet *) requiredPredicateKeyPaths { 42 | return [NSSet setWithObjects: 43 | SKBadgeTagBased, 44 | nil]; 45 | } 46 | 47 | + (NSDictionary *) recognizedSortDescriptorKeys { 48 | return [NSDictionary dictionaryWithObjectsAndKeys: 49 | SKSortName, SKBadgeName, 50 | nil]; 51 | } 52 | 53 | - (void) buildURL { 54 | if ([self requestSortDescriptor] != nil && [[self requestSortDescriptor] ascending] == NO) { 55 | [self setError:SK_SORTERROR(@"badges can only be requested in ascending order")]; 56 | } 57 | 58 | id tagBased = [[self requestPredicate] constantValueForLeftKeyPath:SKBadgeTagBased]; 59 | if ([tagBased isKindOfClass:[NSNumber class]] == NO || [tagBased boolValue] == YES) { 60 | [self setError:SK_PREDERROR(@"Invalid predicate for fetching named badges")]; 61 | } 62 | 63 | [self setPath:@"/badges/name"]; 64 | [super buildURL]; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderQuestionSearch.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderQuestionSearch.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderQuestionSearch : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderQuestions.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderQuestions.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderQuestions : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderQuestionsByID.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderQuestionsByID.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderQuestionsByID : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderQuestionsByUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderQuestionsByUser.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderQuestionsByUser : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderTagBadges.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderTagBadges.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderTagBadges : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderTagBadges.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderTagBadges.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderTagBadges.h" 27 | 28 | 29 | @implementation _SKRequestBuilderTagBadges 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKBadge class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType), SKBadgeTagBased, 38 | nil]; 39 | } 40 | 41 | + (NSSet *) requiredPredicateKeyPaths { 42 | return [NSSet setWithObjects: 43 | SKBadgeTagBased, 44 | nil]; 45 | } 46 | 47 | + (NSDictionary *) recognizedSortDescriptorKeys { 48 | return [NSDictionary dictionaryWithObjectsAndKeys: 49 | SKSortName, SKBadgeName, 50 | nil]; 51 | } 52 | 53 | - (void) buildURL { 54 | if ([self requestSortDescriptor] != nil && [[self requestSortDescriptor] ascending] == NO) { 55 | [self setError:SK_SORTERROR(@"badges can only be requested in ascending order")]; 56 | } 57 | 58 | id tagBased = [[self requestPredicate] constantValueForLeftKeyPath:SKBadgeTagBased]; 59 | if ([tagBased isKindOfClass:[NSNumber class]] == NO || [tagBased boolValue] == NO) { 60 | [self setError:SK_PREDERROR(@"Invalid predicate for fetching tag badges")]; 61 | } 62 | 63 | [self setPath:@"/badges/tags"]; 64 | [super buildURL]; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderTags.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderTags.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderTags : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderTags.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderTags.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderTags.h" 27 | 28 | @implementation _SKRequestBuilderTags 29 | 30 | + (Class) recognizedFetchEntity { 31 | return [SKTag class]; 32 | } 33 | 34 | + (NSDictionary *) recognizedPredicateKeyPaths { 35 | return [NSDictionary dictionaryWithObjectsAndKeys: 36 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKTagCount, 37 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKTagLastUsedDate, 38 | SK_BOX(NSContainsPredicateOperatorType), SKTagName, 39 | nil]; 40 | } 41 | 42 | + (NSDictionary *) recognizedSortDescriptorKeys { 43 | return [NSDictionary dictionaryWithObjectsAndKeys: 44 | SKSortPopular, SKTagCount, 45 | SKSortActivity, SKTagLastUsedDate, 46 | SKSortName, SKTagName, 47 | nil]; 48 | } 49 | 50 | - (void) buildURL { 51 | NSPredicate *p = [self requestPredicate]; 52 | [self setPath:@"/tags"]; 53 | 54 | id filter = [p constantValueForLeftKeyPath:SKTagName]; 55 | if (filter) { 56 | [[self query] setObject:filter forKey:SKQueryFilter]; 57 | } 58 | 59 | if ([self requestSortDescriptor] != nil) { 60 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 61 | if (sortRange.lower != SKNotFound) { 62 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 63 | } 64 | if (sortRange.upper != SKNotFound) { 65 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 66 | } 67 | } 68 | 69 | [super buildURL]; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUnansweredQuestions.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUnansweredQuestions.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderUnansweredQuestions : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUserModerators.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUserModerators.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderUserModerators : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUserTags.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUserTags.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderUserTags : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUserTags.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUserTags.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderUserTags.h" 27 | 28 | 29 | @implementation _SKRequestBuilderUserTags 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKTag class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKTagsParticipatedInByUser, 38 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKTagNumberOfTaggedQuestions, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKTagLastUsedDate, 40 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKTagName, 41 | nil]; 42 | } 43 | 44 | + (NSSet *) requiredPredicateKeyPaths { 45 | return [NSSet setWithObjects: 46 | SKTagsParticipatedInByUser, 47 | nil]; 48 | } 49 | 50 | + (NSDictionary *) recognizedSortDescriptorKeys { 51 | return [NSDictionary dictionaryWithObjectsAndKeys: 52 | SKSortPopular, SKTagNumberOfTaggedQuestions, 53 | SKSortActivity, SKTagLastUsedDate, 54 | SKSortName, SKTagName, 55 | nil]; 56 | } 57 | 58 | - (void) buildURL { 59 | NSPredicate *p = [self requestPredicate]; 60 | 61 | id questionIDs = [p constantValueForLeftKeyPath:SKTagsParticipatedInByUser]; 62 | [self setPath:[NSString stringWithFormat:@"/users/%@/tags", SKExtractQuestionID(questionIDs)]]; 63 | 64 | id filter = [p constantValueForLeftKeyPath:SKTagName]; 65 | if (filter) { 66 | [[self query] setObject:filter forKey:SKQueryFilter]; 67 | } 68 | 69 | if ([self requestSortDescriptor] != nil) { 70 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 71 | if (sortRange.lower != SKNotFound) { 72 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 73 | } 74 | if (sortRange.upper != SKNotFound) { 75 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 76 | } 77 | } 78 | 79 | [super buildURL]; 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUsers.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUsers.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderUsers : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUsers.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUsers.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderUsers.h" 27 | 28 | 29 | @implementation _SKRequestBuilderUsers 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKUser class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSContainsPredicateOperatorType), SKUserDisplayName, 38 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKUserCreationDate, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKUserReputation, 40 | nil]; 41 | } 42 | 43 | + (NSDictionary *) recognizedSortDescriptorKeys { 44 | return [NSDictionary dictionaryWithObjectsAndKeys: 45 | SKSortName, SKUserDisplayName, 46 | SKSortCreation, SKUserCreationDate, 47 | SKSortReputation, SKUserReputation, 48 | nil]; 49 | } 50 | 51 | - (void) buildURL { 52 | NSPredicate * p = [self requestPredicate]; 53 | 54 | [self setPath:@"/users"]; 55 | 56 | SKRange dateRange = [p rangeOfConstantValuesForLeftKeyPath:SKUserCreationDate]; 57 | if (dateRange.lower != SKNotFound) { 58 | [[self query] setObject:dateRange.lower forKey:SKQueryFromDate]; 59 | } 60 | if (dateRange.upper != SKNotFound) { 61 | [[self query] setObject:dateRange.upper forKey:SKQueryToDate]; 62 | } 63 | 64 | if ([self requestSortDescriptor] != nil && ![[[self requestSortDescriptor] key] isEqual:SKUserCreationDate]) { 65 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 66 | if (sortRange.lower != SKNotFound) { 67 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 68 | } 69 | if (sortRange.upper != SKNotFound) { 70 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 71 | } 72 | } 73 | 74 | id filter = [p constantValueForLeftKeyPath:SKUserDisplayName]; 75 | if (filter != nil) { 76 | [[self query] setObject:filter forKey:SKQueryFilter]; 77 | } 78 | 79 | [super buildURL]; 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUsersByID.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUsersByID.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderUsersByID : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUsersByID.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUsersByID.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderUsersByID.h" 27 | 28 | 29 | @implementation _SKRequestBuilderUsersByID 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKUser class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSEqualToPredicateOperatorType, NSInPredicateOperatorType), SKUserID, 38 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKUserCreationDate, 39 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKUserReputation, 40 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKUserDisplayName, 41 | nil]; 42 | } 43 | 44 | + (NSSet *) requiredPredicateKeyPaths { 45 | return [NSSet setWithObjects: 46 | SKUserID, 47 | nil]; 48 | } 49 | 50 | + (NSDictionary *) recognizedSortDescriptorKeys { 51 | return [NSDictionary dictionaryWithObjectsAndKeys: 52 | SKSortCreation, SKUserCreationDate, 53 | SKSortReputation, SKUserReputation, 54 | SKSortName, SKUserDisplayName, 55 | nil]; 56 | } 57 | 58 | - (void) buildURL { 59 | NSPredicate * p = [self requestPredicate]; 60 | 61 | id users = [p constantValueForLeftKeyPath:SKUserID]; 62 | [self setPath:[NSString stringWithFormat:@"/users/%@", SKExtractUserID(users)]]; 63 | 64 | SKRange dateRange = [p rangeOfConstantValuesForLeftKeyPath:SKUserCreationDate]; 65 | if (dateRange.lower != SKNotFound) { 66 | [[self query] setObject:dateRange.lower forKey:SKQueryFromDate]; 67 | } 68 | if (dateRange.upper != SKNotFound) { 69 | [[self query] setObject:dateRange.upper forKey:SKQueryToDate]; 70 | } 71 | 72 | if ([self requestSortDescriptor] != nil && ![[[self requestSortDescriptor] key] isEqual:SKUserCreationDate]) { 73 | SKRange sortRange = [p rangeOfConstantValuesForLeftKeyPath:[[self requestSortDescriptor] key]]; 74 | if (sortRange.lower != SKNotFound) { 75 | [[self query] setObject:sortRange.lower forKey:SKQueryMinSort]; 76 | } 77 | if (sortRange.upper != SKNotFound) { 78 | [[self query] setObject:sortRange.upper forKey:SKQueryMaxSort]; 79 | } 80 | } 81 | 82 | id filter = [p constantValueForLeftKeyPath:SKUserDisplayName]; 83 | if (filter != nil) { 84 | [[self query] setObject:filter forKey:SKQueryFilter]; 85 | } 86 | 87 | [super buildURL]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUsersWithBadge.h: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUsersWithBadge.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import "_SKConcreteRequestBuilder.h" 28 | 29 | @interface _SKRequestBuilderUsersWithBadge : _SKConcreteRequestBuilder { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Classes/_SKRequestBuilderUsersWithBadge.m: -------------------------------------------------------------------------------- 1 | // 2 | // _SKRequestBuilderUsersWithBadge.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "_SKRequestBuilderUsersWithBadge.h" 27 | 28 | 29 | @implementation _SKRequestBuilderUsersWithBadge 30 | 31 | + (Class) recognizedFetchEntity { 32 | return [SKUser class]; 33 | } 34 | 35 | + (NSDictionary *) recognizedPredicateKeyPaths { 36 | return [NSDictionary dictionaryWithObjectsAndKeys: 37 | SK_BOX(NSGreaterThanOrEqualToPredicateOperatorType, NSLessThanOrEqualToPredicateOperatorType), SKUserCreationDate, 38 | SK_BOX(NSContainsPredicateOperatorType), SKUserBadges, 39 | nil]; 40 | } 41 | 42 | + (NSSet *) requiredPredicateKeyPaths { 43 | return [NSSet setWithObjects: 44 | SKUserBadges, 45 | nil]; 46 | } 47 | 48 | + (BOOL) recognizesASortDescriptor { 49 | return NO; 50 | } 51 | 52 | - (void) buildURL { 53 | NSPredicate * p = [self requestPredicate]; 54 | id badges = [p constantValueForLeftKeyPath:SKUserBadges]; 55 | [self setPath:[NSString stringWithFormat:@"/badges/%@", SKExtractBadgeID(badges)]]; 56 | 57 | SKRange r = [p rangeOfConstantValuesForLeftKeyPath:SKUserCreationDate]; 58 | if (r.lower != SKNotFound) { 59 | [[self query] setObject:r.lower forKey:SKQueryFromDate]; 60 | } 61 | if (r.upper != SKNotFound) { 62 | [[self query] setObject:r.upper forKey:SKQueryToDate]; 63 | } 64 | [super buildURL]; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | StackKit 2 | 3 | Copyright (c) 2010 Dave DeLong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | In addition, StackKit uses other code, whose licenses appear below: 24 | 25 | json-framework 26 | Copyright (C) 2009 Stig Brautaset. All rights reserved. 27 | 28 | Redistribution and use in source and binary forms, with or without 29 | modification, are permitted provided that the following conditions are met: 30 | 31 | * Redistributions of source code must retain the above copyright notice, this 32 | list of conditions and the following disclaimer. 33 | 34 | * Redistributions in binary form must reproduce the above copyright notice, 35 | this list of conditions and the following disclaimer in the documentation 36 | and/or other materials provided with the distribution. 37 | 38 | * Neither the name of the author nor the names of its contributors may be used 39 | to endorse or promote products derived from this software without specific 40 | prior written permission. 41 | 42 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 43 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 44 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 45 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 46 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 47 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 48 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 49 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 50 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 51 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Other Sources/Dummy.m: -------------------------------------------------------------------------------- 1 | // 2 | // Dummy.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import 28 | 29 | int main(int argc, char* argv[]) { 30 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 31 | 32 | SKSite * s = [SKSite stackOverflowSite]; 33 | SKFetchRequest * r = [[SKFetchRequest alloc] init]; 34 | [r setEntity:[SKAnswer class]]; 35 | [r setPredicate:[NSPredicate predicateWithFormat:@"%K = %d", SKAnswerOwner, 1234]]; 36 | [r setSortDescriptor:[[[NSSortDescriptor alloc] initWithKey:SKAnswerCreationDate ascending:YES] autorelease]]; 37 | [r setSite:s]; 38 | 39 | NSArray * a = [NSArray arrayWithObjects: 40 | NSClassFromString(@"_SKRequestBuilderAnswersByID"), 41 | NSClassFromString(@"_SKRequestBuilderAnswersForQuestion"), 42 | NSClassFromString(@"_SKRequestBuilderAnswersForUser"), 43 | nil]; 44 | NSLog(@"%@", a); 45 | NSLog(@"%@", [a valueForKey:@"allRecognizedSortDescriptorKeys"]); 46 | 47 | NSError * e = nil; 48 | Class builder = NSClassFromString(@"SKRequestBuilder"); 49 | NSURL * u = [builder URLForFetchRequest:r error:&e]; 50 | 51 | NSLog(@"error: %@", e); 52 | NSLog(@"url: %@", u); 53 | 54 | [r release]; 55 | 56 | [pool drain]; 57 | return 0; 58 | } -------------------------------------------------------------------------------- /Other Sources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleName 10 | ${PRODUCT_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034Identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | CFBundleShortVersionString 24 | 1.0 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Other Sources/StackKit_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'StackKit' target in the 'StackKit' project. 3 | // 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #ifdef __OBJC__ 27 | #import 28 | #endif 29 | 30 | #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR 31 | #define StackKitMobile 1 32 | #else 33 | #define StackKitMac 1 34 | #endif -------------------------------------------------------------------------------- /Other Sources/version.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildVersion 6 | 2 7 | CFBundleShortVersionString 8 | 1.0 9 | CFBundleVersion 10 | 1 11 | ProjectName 12 | DevToolsWizardTemplates 13 | SourceVersion 14 | 15920000 15 | 16 | 17 | -------------------------------------------------------------------------------- /Unit Tests/NSPredicate_SKAdditionsTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSPredicate_SKAdditionsTest.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | @interface NSPredicate_SKAdditionsTest : SenTestCase { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Unit Tests/NSPredicate_SKAdditionsTest.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSPredicate_SKAdditionsTest.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "NSPredicate_SKAdditionsTest.h" 27 | #import 28 | #import "NSPredicate+SKAdditions.h" 29 | 30 | @implementation NSPredicate_SKAdditionsTest 31 | 32 | - (void) testValueForLeftExpression { 33 | NSPredicate * p = [NSPredicate predicateWithFormat:@"%K = 42", SKUserID]; 34 | NSExpression * l = [NSExpression expressionForKeyPath:SKUserID]; 35 | 36 | id value = [p constantValueForLeftExpression:l]; 37 | STAssertNotNil(value, @"value should not be nil"); 38 | STAssertEqualObjects(value, [NSNumber numberWithInt:42], @"value should be 42"); 39 | 40 | p = [NSPredicate predicateWithFormat:@"(Foo = 13 AND Bar = \"Foo\") OR (%K = 42)", SKUserID]; 41 | value = [p constantValueForLeftExpression:l]; 42 | STAssertNotNil(value, @"value should not be nil"); 43 | STAssertEqualObjects(value, [NSNumber numberWithInt:42], @"value should be 42"); 44 | 45 | p = [NSPredicate predicateWithFormat:@"Foo = 13"]; 46 | value = [p constantValueForLeftExpression:l]; 47 | STAssertNil(value, @"value should be nil"); 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Unit Tests/SKBadgeTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKBadgeTest.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | @interface SKBadgeTest : SenTestCase { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Unit Tests/SKCommentTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKCommentTest.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | @interface SKCommentTest : SenTestCase { 29 | 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Unit Tests/SKQuestionTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKQuestionTest.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | #import 28 | 29 | @protocol SKFetchRequestDelegate; 30 | 31 | @interface SKQuestionTest : SenTestCase { 32 | BOOL didReceiveCallback; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Unit Tests/SKSiteTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKSiteTest.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | @interface SKSiteTest : SenTestCase { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Unit Tests/SKSiteTest.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKSiteTest.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "SKSiteTest.h" 27 | #import "SKTestConstants.h" 28 | #import 29 | 30 | @implementation SKSiteTest 31 | 32 | - (void) testStatistics { 33 | SKSite * site = [SKSite stackOverflowSite]; 34 | 35 | NSDictionary * stats = [site statistics]; 36 | 37 | NSString * apiVersion = [[stats objectForKey:SKStatsAPIInfo] objectForKey:SKStatsAPIInfoVersion]; 38 | STAssertEqualObjects(apiVersion, SKAPIVersion, @"API versions do not match!"); 39 | } 40 | 41 | - (void) testMetaSite { 42 | SKSite * so = [SKSite stackOverflowSite]; 43 | SKSite * metaSO = [so metaSite]; 44 | STAssertEqualObjects([[metaSO apiURL] host], @"api.meta.stackoverflow.com", @"Unexpected meta URL: %@", [metaSO apiURL]); 45 | 46 | SKSite * metaMetaSO = [metaSO metaSite]; 47 | STAssertTrue(metaSO == metaMetaSO, @"meta.stackoverflow.com should not have a meta site, but found: %@", [metaMetaSO apiURL]); 48 | 49 | SKSite * su = [SKSite superUserSite]; 50 | SKSite * metaSU = [su metaSite]; 51 | STAssertNotNil(metaSU, @"SuperUser should have a meta site"); 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /Unit Tests/SKTagTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKTagTest.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | @interface SKTagTest : SenTestCase { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Unit Tests/SKTestConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKTestConstants.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | extern NSString * const SKTestAPISite; 27 | -------------------------------------------------------------------------------- /Unit Tests/SKTestConstants.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKTestConstants.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | NSString * const SKTestAPISite = @"http://api.stackoverflow.com"; 27 | -------------------------------------------------------------------------------- /Unit Tests/SKUserActivityTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKUserActivityTest.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | @interface SKUserActivityTest : SenTestCase { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Unit Tests/SKUserActivityTest.m: -------------------------------------------------------------------------------- 1 | // 2 | // SKUserActivityTest.m 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import "SKUserActivityTest.h" 27 | #import 28 | 29 | @implementation SKUserActivityTest 30 | 31 | - (void) testUserActivity { 32 | SKSite * site = [SKSite stackoverflowSite]; 33 | 34 | SKFetchRequest * r = [[SKFetchRequest alloc] init]; 35 | [r setEntity:[SKUserActivity class]]; 36 | [r setPredicate:[NSPredicate predicateWithFormat:@"%K = %@", SKUserID, @"115730"]]; 37 | 38 | NSError * error = nil; 39 | NSArray * activity = [site executeSynchronousFetchRequest:r error:&error]; 40 | [r release]; 41 | 42 | STAssertNil(error, @"error should be nil"); 43 | 44 | STAssertTrue([activity count] > 0, @"activity should be non-empty"); 45 | } 46 | 47 | - (void) testUserActivityBetweenDates { 48 | SKSite * site = [SKSite stackoverflowSite]; 49 | 50 | SKFetchRequest * r = [[SKFetchRequest alloc] init]; 51 | [r setEntity:[SKUserActivity class]]; 52 | [r setPredicate:[NSPredicate predicateWithFormat:@"%K = %@ AND %K >= %@ AND %K <= %@", 53 | SKUserID, @"115730", 54 | SKUserActivityCreationDate, [NSDate dateWithString:@"2010-04-01 00:00:00 -0000"], 55 | SKUserActivityCreationDate, [NSDate dateWithString:@"2010-04-04 00:00:00 -0600"], 56 | nil]]; 57 | [r setSortDescriptor:[[[NSSortDescriptor alloc] initWithKey:SKUserActivityCreationDate ascending:YES] autorelease]]; 58 | 59 | NSError * error = nil; 60 | NSArray * activity = [site executeSynchronousFetchRequest:r error:&error]; 61 | NSLog(@"%@", error); 62 | [r release]; 63 | 64 | STAssertNil(error, @"error should be nil: %@", error); 65 | 66 | NSArray * actualDescriptions = [activity valueForKey:@"activityDescription"]; 67 | NSArray * expectedDescriptions = [NSArray arrayWithObjects:/**@"Is it possible to filter an NSArray by class?", 68 | @"Rounded Rect UIButton without the border", 69 | @"The 10.6.3 os x update broke simulated key-presses for Nestopia.", 70 | @"strchr in objective C?", 71 | @"Get currently selected item in Mac UI", 72 | @"UITabBar customization", 73 | @"Class variable defined at @implementation rather than @interface?",**/ 74 | @"MobileMe Connection - Cocoa", 75 | @"Options for Cocoa-based text editor", 76 | nil]; 77 | 78 | STAssertEqualObjects(actualDescriptions, expectedDescriptions, @"actual descriptions do not match (%@)", actualDescriptions); 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /Unit Tests/SKUserTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // SKUserTest.h 3 | // StackKit 4 | /** 5 | Copyright (c) 2011 Dave DeLong 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | **/ 25 | 26 | #import 27 | 28 | 29 | @interface SKUserTest : SenTestCase { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Unit Tests/Unit Tests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | --------------------------------------------------------------------------------