Skip to content

Commit

Permalink
Merge pull request #77 from ahmedrezik/fix-issue-75
Browse files Browse the repository at this point in the history
Fix issue #75
  • Loading branch information
Sam-Spencer authored Jul 19, 2020
2 parents 447cb66 + 1cb07a6 commit 35f60f3
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 58 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
GameCenterManager.xcodeproj/project.xcworkspace/xcuserdata
GameCenterManager.xcodeproj/xcuserdata

*.xcuserstate
7 changes: 7 additions & 0 deletions GC Manager/GCMConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
#ifndef GCMConstants_h
#define GCMConstants_h

#if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted)
#define GCM_FINAL __attribute__((objc_subclassing_restricted))
#else
#define GCM_FINAL
#endif


/// Leaderboard sort order. Use this value when submitting new leaderboard scores. This value should match the value set in iTunes Connect for the speicifed leaderboard.
typedef enum GameCenterSortOrder {
/// Scores are sorted highest to lowest. Higher scores are on the top of the leaderboard
Expand Down
2 changes: 1 addition & 1 deletion GC Manager/GCMMultiplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@protocol GameCenterMultiplayerManagerDelegate;

@interface GCMMultiplayer : NSObject <GKMatchmakerViewControllerDelegate, GKMatchDelegate, GKLocalPlayerListener>
GCM_FINAL @interface GCMMultiplayer : NSObject <GKMatchmakerViewControllerDelegate, GKMatchDelegate, GKLocalPlayerListener>

/// Returns the default instance of the multiplayer manager
+ (GCMMultiplayer *)defaultMultiplayerManager;
Expand Down
4 changes: 4 additions & 0 deletions GC Manager/GameCenterManager Mac-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

4 changes: 4 additions & 0 deletions GC Manager/GameCenterManager-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

2 changes: 1 addition & 1 deletion GC Manager/GameCenterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
/// GameCenter Manager helps to manage Game Center in iOS and Mac apps. Report and keep track of high scores, achievements, and challenges for different players. GameCenter Manager also takes care of the heavy lifting - checking internet availability, saving data when offline and uploading it when online, etc.
@class GameCenterManager;
@protocol GameCenterManagerDelegate;
@interface GameCenterManager : NSObject <GKGameCenterControllerDelegate>
GCM_FINAL @interface GameCenterManager : NSObject <GKGameCenterControllerDelegate>


/// Returns the shared instance of GameCenterManager.
Expand Down
3 changes: 2 additions & 1 deletion GC Manager/GameCenterManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,9 @@ - (void)saveAndReportScore:(long long)score leaderboard:(NSString *)identifier s
if (playerDict == nil) playerDict = [NSMutableDictionary dictionary];

NSNumber *savedHighScore = [playerDict objectForKey:identifier];
//MARK:- issue arises here
if (savedHighScore == nil)
savedHighScore = [NSNumber numberWithLongLong:0];
savedHighScore = [NSNumber numberWithLongLong:-INFINITY];

long long savedHighScoreValue = [savedHighScore longLongValue];

Expand Down
69 changes: 69 additions & 0 deletions GC Manager/Multiplayer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// Multiplayer.swift
// GameCenterManager
//
// Created by Sam Spencer on 12/13/15.
// Copyright © 2015 NABZ Software. All rights reserved.
//

import Foundation
import GameKit

protocol MultiplerManagerDelegate {
func matchStarted(manager:Multiplayer, match:GKMatch)
func matchEnded(manager:Multiplayer, match:GKMatch)
func matchRecievedData(manager:Multiplayer, match:GKMatch, data:NSData, sendingPlayerID:NSString)
}

protocol MultiplayerPlayerManagerDelegate {
func allPlayersConnectedToMatch(manager:Multiplayer, match:GKMatch, players:[String])
func allPlayersDisconnectedFromMatch(manager:Multiplayer, match:GKMatch, players:[String])
func recievedMatchInvitation(manager:Multiplayer, invitedPlayer:GKPlayer, players:[GKPlayer])
func acceptedMatchInvitation(manager:Multiplayer, invite:GKInvite, player:GKPlayer)
}

class Multiplayer: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDelegate, GKLocalPlayerListener {

var matchPresentingController: UIViewController?
var multiplayerMatchStarted: Bool
var multiplayerMatch: GKMatch?

override init() {
// Initialize the class
matchPresentingController = nil
multiplayerMatchStarted = false
multiplayerMatch = nil

super.init()
}

deinit {
GKLocalPlayer.localPlayer().unregisterAllListeners()
}

class MultiplayerManager {
static let sharedInstance = Multiplayer()
}

func beginListeningForMatches() {
GKLocalPlayer.localPlayer().registerListener(self)
}

func matchmakerViewControllerWasCancelled(viewController: GKMatchmakerViewController) {
// Matchmaking was cancelled by the user
matchPresentingController!.dismissViewControllerAnimated(true) { () -> Void in
NSLog("Matchmaking View Controller was dissmissed.")
}
}

func matchmakerViewController(viewController: GKMatchmakerViewController, didFailWithError error: NSError) {
// Matchmaking failed due to an error
matchPresentingController!.dismissViewControllerAnimated(true) { () -> Void in
NSLog("Error finding match: %@", error)
}
}

func matchmakerViewController(viewController: GKMatchmakerViewController, didFindMatch match: GKMatch) {

}
}
15 changes: 15 additions & 0 deletions GC Manager/Referee.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Referee.swift
// GameCenterManager
//
// Created by Sam Spencer on 12/13/15.
// Copyright © 2015 NABZ Software. All rights reserved.
//


import Foundation
import GameKit

class Referee: NSObject {

}
48 changes: 20 additions & 28 deletions GameCenterManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,7 @@
99B3FA1F18773CBE00539A7B /* GameBanner.png in Resources */ = {isa = PBXBuildFile; fileRef = 99B3FA1C18773CBE00539A7B /* GameBanner.png */; };
99B3FA2018773CBE00539A7B /* GameBanner.psd in Resources */ = {isa = PBXBuildFile; fileRef = 99B3FA1D18773CBE00539A7B /* GameBanner.psd */; };
99B3FA2118773CBE00539A7B /* Interface.png in Resources */ = {isa = PBXBuildFile; fileRef = 99B3FA1E18773CBE00539A7B /* Interface.png */; };
99ED4CDB1C1E7BDC00B39320 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 99ED4CD81C1E7BDC00B39320 /* AppDelegate.m */; };
99ED4CDC1C1E7BDC00B39320 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 99ED4CDA1C1E7BDC00B39320 /* ViewController.m */; };
99ED4CDD1C1E7D0400B39320 /* NSDataAES256.m in Sources */ = {isa = PBXBuildFile; fileRef = 99B16C24172D71130091618D /* NSDataAES256.m */; };
99ED4CDE1C1E7D0600B39320 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 99B16C26172D71130091618D /* Reachability.m */; };
99ED4CDF1C1E7D0800B39320 /* GameCenterManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 99B16C22172D71130091618D /* GameCenterManager.m */; };
99ED4CE01C1E7D0D00B39320 /* GCMMultiplayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A6D07E011C03E0ED00EDC417 /* GCMMultiplayer.m */; };
99ED4CE11C1E7D0E00B39320 /* GCMMultiplayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A6D07E011C03E0ED00EDC417 /* GCMMultiplayer.m */; };
99ED4CE31C1E869D00B39320 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99ED4CE21C1E869D00B39320 /* GameKit.framework */; };
99ED4CE61C1E882300B39320 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99ED4CE51C1E882300B39320 /* CoreData.framework */; };
99ED4CE81C1E882B00B39320 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99ED4CE71C1E882B00B39320 /* CoreGraphics.framework */; };
99ED4CEA1C1E883200B39320 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99ED4CE91C1E883200B39320 /* Foundation.framework */; };
99ED4CEC1C1E883C00B39320 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99ED4CEB1C1E883C00B39320 /* SystemConfiguration.framework */; };
99ED4CEE1C1E884200B39320 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99ED4CED1C1E884200B39320 /* UIKit.framework */; };

A6BACC651A6AC45E00EAABCF /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A6BACC641A6AC45E00EAABCF /* Storyboard.storyboard */; };
A6BACC681A6ACB5100EAABCF /* MacViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A6BACC671A6ACB5100EAABCF /* MacViewController.m */; };
A6D07E021C03E0ED00EDC417 /* GCMMultiplayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A6D07E011C03E0ED00EDC417 /* GCMMultiplayer.m */; };
Expand Down Expand Up @@ -110,16 +98,7 @@
99B3FA1C18773CBE00539A7B /* GameBanner.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = GameBanner.png; sourceTree = "<group>"; };
99B3FA1D18773CBE00539A7B /* GameBanner.psd */ = {isa = PBXFileReference; lastKnownFileType = file; path = GameBanner.psd; sourceTree = "<group>"; };
99B3FA1E18773CBE00539A7B /* Interface.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Interface.png; sourceTree = "<group>"; };
99ED4CD71C1E7BDC00B39320 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
99ED4CD81C1E7BDC00B39320 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
99ED4CD91C1E7BDC00B39320 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
99ED4CDA1C1E7BDC00B39320 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
99ED4CE21C1E869D00B39320 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/GameKit.framework; sourceTree = DEVELOPER_DIR; };
99ED4CE51C1E882300B39320 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; };
99ED4CE71C1E882B00B39320 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; };
99ED4CE91C1E883200B39320 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
99ED4CEB1C1E883C00B39320 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
99ED4CED1C1E884200B39320 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };

A6BACC641A6AC45E00EAABCF /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard.storyboard; sourceTree = "<group>"; };
A6BACC661A6ACB5100EAABCF /* MacViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacViewController.h; sourceTree = "<group>"; };
A6BACC671A6ACB5100EAABCF /* MacViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MacViewController.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -339,9 +318,13 @@
99B0162C1754FD7700F56A5C /* Dependencies */,
99B16C21172D71130091618D /* GameCenterManager.h */,
99B16C22172D71130091618D /* GameCenterManager.m */,
A61038E91C1E30CD00C3CBD1 /* Referee.swift */,
A6D07E001C03E0ED00EDC417 /* GCMMultiplayer.h */,
A6D07E011C03E0ED00EDC417 /* GCMMultiplayer.m */,
A61038E61C1DF21600C3CBD1 /* Multiplayer.swift */,
A6D07E031C03E34700EDC417 /* GCMConstants.h */,
A61038E01C1DF1CE00C3CBD1 /* GameCenterManager-Bridging-Header.h */,
A61038E81C1E30CD00C3CBD1 /* GameCenterManager Mac-Bridging-Header.h */,
);
path = "GC Manager";
sourceTree = "<group>";
Expand Down Expand Up @@ -429,11 +412,7 @@
659699CD1515718700724EBE /* Project object */ = {
isa = PBXProject;
attributes = {
KnownAssetTags = (
"com.apple.gamecenter.Dashboard Image",
com.apple.gamecenter.Leaderboard,
com.apple.gamecenter.PlayerScores,
);

LastUpgradeCheck = 0710;
ORGANIZATIONNAME = "NABZ Software";
TargetAttributes = {
Expand Down Expand Up @@ -524,6 +503,8 @@
659699EB1515718800724EBE /* AppDelegate.m in Sources */,
659699EE1515718800724EBE /* ViewController.m in Sources */,
99B16C27172D71130091618D /* GameCenterManager.m in Sources */,
A61038E71C1DF21600C3CBD1 /* Multiplayer.swift in Sources */,
A61038EA1C1E30CD00C3CBD1 /* Referee.swift in Sources */,
99B16C28172D71130091618D /* NSDataAES256.m in Sources */,
99B16C29172D71130091618D /* Reachability.m in Sources */,
A6D07E021C03E0ED00EDC417 /* GCMMultiplayer.m in Sources */,
Expand All @@ -550,6 +531,7 @@
files = (
A6BACC681A6ACB5100EAABCF /* MacViewController.m in Sources */,
994E294E17838BF300EAACD2 /* main.m in Sources */,
A61038EB1C1E30CD00C3CBD1 /* Referee.swift in Sources */,
993EFA181847C37A0061C758 /* NSDataAES256.m in Sources */,
993EFA171847C2E30061C758 /* GameCenterManager.m in Sources */,
99ED4CE11C1E7D0E00B39320 /* GCMMultiplayer.m in Sources */,
Expand Down Expand Up @@ -690,8 +672,11 @@
GCC_THUMB_SUPPORT = NO;
INFOPLIST_FILE = "GameCenterManager/GameCenterManager-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
ONLY_ACTIVE_ARCH = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "GC Manager/GameCenterManager-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
};
Expand All @@ -709,7 +694,9 @@
GCC_THUMB_SUPPORT = NO;
INFOPLIST_FILE = "GameCenterManager/GameCenterManager-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "GC Manager/GameCenterManager-Bridging-Header.h";
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
};
Expand Down Expand Up @@ -793,11 +780,14 @@
GCC_PREFIX_HEADER = "GameCenterManager Mac/GameCenterManager Mac-Prefix.pch";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "GameCenterManager Mac/GameCenterManager Mac-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.gamecentermanager;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "GC Manager/GameCenterManager Mac-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand All @@ -823,10 +813,12 @@
GCC_PREFIX_HEADER = "GameCenterManager Mac/GameCenterManager Mac-Prefix.pch";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "GameCenterManager Mac/GameCenterManager Mac-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = com.gamecentermanager;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "GC Manager/GameCenterManager Mac-Bridging-Header.h";
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
67 changes: 41 additions & 26 deletions Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,74 @@
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "AppIcon29x29.png",
"scale" : "1x"
"scale" : "2x",
"size" : "20x20"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
"scale" : "3x",
"size" : "20x20"
},
{
"filename" : "AppIcon29x29.png",
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
"scale" : "1x",
"size" : "29x29"
},
{
"size" : "40x40",
"filename" : "[email protected]",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
"scale" : "3x",
"size" : "29x29"
},
{
"size" : "57x57",
"filename" : "[email protected]",
"idiom" : "iphone",
"filename" : "Icon.png",
"scale" : "1x"
"scale" : "2x",
"size" : "40x40"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "[email protected]",
"scale" : "2x"
"scale" : "3x",
"size" : "40x40"
},
{
"filename" : "Icon.png",
"idiom" : "iphone",
"scale" : "1x",
"size" : "57x57"
},
{
"size" : "60x60",
"filename" : "[email protected]",
"idiom" : "iphone",
"scale" : "2x",
"size" : "57x57"
},
{
"filename" : "[email protected]",
"scale" : "2x"
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*This project is currently being rewritten in Swift. To contribute or check progress, please visit the [swift-refactor](https://github.com/nihalahmed/GameCenterManager/tree/swift-refactor) branch.*

### A Note on Swift Conversion
*This branch of the project is currently being refactored and rewritten in Swift. Please contibute to help finish the conversion and improve the project. Once completed, the projct will switch over to Swift from Objective-C. Until that time, this branch is not ready for production use.*

<img width=100% src="https://raw.github.com/nihalahmed/GameCenterManager/master/Images/GameBanner.png"/>

Expand Down

0 comments on commit 35f60f3

Please sign in to comment.