Created: 2011-07-14 17:25
Updated: 2013-10-21 02:33
License: other




SGBaseFramework is a "I don't want to write code everytime and I want to write less code for common operations" library.



  • CoreData :

    • Controller to do the job that is done in the original template file of an application using CoreData. Offering a way to use more than one store without difficulty
    • A singleton handling all those stores
  • Memory : You'll find a convenient way to release safely objects

    • sgReleaseSafely(&object) : will do a release followed by an affectation to nil.
    • sgReleaseCFSafely(&object) : will do the same for CoreFoundation objects
    • sgInvalidateTimer
    • sgLocStr : Shorthand for getting localized strings
  • GameKit : SGSharedGK is a singleton class that will do most of the operations needed to work with the iOS GameCenter

    • Authentication :
        • (void)authenticateLocalPlayer;
        • (void)registerForAuthenticationNotification;
        • (void)unregisterForAuthenticationNotification;
        • (void)authenticationChanged;
    • Friends information :
        • (void)retrieveFriends;
        • (void)loadPlayerData:(NSArray *)identifiers;
    • Scoring :
        • (void)reportScore:(int64_t)score forCategory:(NSString*)category;
    • Leaderboard :
        • (void)showLeaderboard;
        • (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController;
        • (void)retrieveTopTenScores;
        • (void)receiveMatchBestScores:(GKMatch*)match;
        • (void)loadCategoryTitles;
    • Achievements :
        • (void)reportAchievementIdentifier:(NSString*)identifier percentComplete:(float)percent;
        • (void)loadAchievements;
        • (GKAchievement*)getAchievementForIdentifier:(NSString*)identifier;
        • (void)resetAchievements;
        • (void)showAchievements;
        • (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController;
  • Helpers :

    • Dictionary helper : in order to fetch in a clean way data from NSDictionary
  • Mathematics :

    • High precision float comparison
    • High precision double comparison
    • Normalized random
    • Bounded random
  • Categories :

    • NSString+Email : Compliant to RFC-2822
    • NSString+HTML : Right way to URL encode NSString

Adding SGBaseFramework to your project

  1. Drag the SGBaseFramework.xcodeproj project in to your XCode 4 project. You might want to drag it in to the Frameworks directory to keep it out of the way. Leave the default options 'Create groups for any added folders' and 'Add to targets (Your Project)' selected and press Finish.
  2. Select your project from the XCode sidebar and then the target you want to add SGBaseFramework to.
  3. Select the Build Phases tab.
  4. Under the Target Dependencies group, click the plus button, select the SGBaseFramework static library target and press Add.
  5. Under the Link Binary Libraries group, click the plus button, select libSGBaseFramework.a and press Add.
  6. Add SGBaseFramework/library/headers to the target's Header Search path. This will need to be a relative path based on where the SGBaseFramework repository is located relative to your project.



Copyright 2011 Samuel Grau

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more