Post

Replies

Boosts

Views

Activity

UIImage memory
Does reloading new images into a UIImage view increase the memory usage each time a new image is loaded, thus potentially leading to a memory leak? If so, then do I need to release the memory used for the currently loaded image before reloading the UIImage with a new image?
34
0
9.0k
Apr ’20
Can Dispatch.Queue.main.async calls exists within each other
I would like to wrap a certain function call, which performs UI updates, inside of a Dispatch.Queue.main.async call. This function can eventually call other functions which might call other functions, etc.. so code execution might hit another area of code which also has another Dispatch.Queue.main.async call. Will it do any harm have two or more Dispatch.Queue.main.async calls being call in the same code execution path?
2
0
3.5k
Apr ’20
GKMatchmakerVC indicates "connecting" but never starts match
My card game application has been released in the App Store and various friends are now downloading it wanting to play. Most people can download the game, send invites to each other and start playing, however, there are two friends who are having trouble. I can send an invite to them to join a game or they can send an invite to me to join the game. In both cases the GKMatchmaker View Controller is displayed for the host player, then initially reports "Matching" and eventually reports "Connecting". However, the GKMatchmaker ViewController simply spins and spins indicating "Connecting" status only and the game never starts.Using the iOS simulator I was able to verify the "didFind match" function is being called, however, the expectedPlayerCount is not 0 so the match never starts. Also, the "didChange state" function is never called to indicate the other player has "connected", so the match still never startsHas anyone experience this issue and might know how to resolve it?Notes:1) Both friends can invite each other and play the game together, however, neither friend can invite me and play2) My iPhone 8 has iOS 13.4 and both friends have iPhone 6 (iOS 12.4.5)3) Using my iPhone 8, I can invite a third (different) player who has an iPhone 6 (iOS 12.4.5) succcessfully4) Using an iPhone11 (iOS 13.3) I can invite either of the two friends successfully
1
0
701
Apr ’20
Polling Game Center for match data?
When Game Center determines a player is forced to disconnect from a match, Game Center sends a disconnect message via the "didChange state" function. However, not all devices connected to the match are receiving the disconnect state change message. One device will think the player is disconnected, but there is still messaging passing from the (supposedly) disconnected player to the other players in the match.The only way I can think to resolve this issue is have all players poll Game Center to obtain updated match information. Based on this updated match information then all players can determine what players are truly still connected properly or not.Can Game Center be polled to obtained updated match information? If so, how?Any other ideas how to resolve the issue when all players do not receive the same disconnect state chaneg from Game Center?
9
0
1.6k
Apr ’20
How to handle player invites spinning forever when not accepted?
I noticed invite requests never time out in the GKMatchmakerViewController window and thus spin forever with "Invitation Sent"Say I requested to start a 4-player game and the GKMatchmakerViewController is displayed. I clicked "Invite Friends" and only invited one friend to play. The other two players, requried for the game, are to be selected randomly by Game Center matchmaking. If the one invited player never accepts the invite request, then the GKMatchmakerViewController spins forever with "Invitation Sent".Is there a way to have GKMatchmakerViewController fill the invited player slot with a random player (OR) perhaps I just have to manually cancel the GKMatchmakerViewController when I decided enough time has passed if the invite has not been accepted?If I sent out 2 invites and only one player accepted their invite, then am I forced to cancel the complete match and start from scratch by sending a reInvite to the one friend who wants to play? I guess all of this discussion would be handled by text messaging, outside the game, to inform any players that I will restart the invite process again?
0
0
537
Apr ’20
Invite image not working - GKMessageImage.png
I placed a GKMessageImage.png image file into the Assets.xcassets folder in my Xcode project and then reloaded each iPhone, which I use for testing, with my new application via XCode. When one iPhone sends an Invite text message to the other iPhone, I do not see my GKMessageImage.png being presented. The Game Center default colored bubbles are still being presented.What am I doing wrong?Does the GKMessageImage.png have to be a specific size ?
3
0
741
Apr ’20
Where is XCode 11.4 ?
I recently upgraded to iOS 13.4 and discovered my current XCode 11.3 version must be upgraded to 11.4 to work with the iPhone 13.4 iOS. That being said, I cannot find XCode 11.4 on the AppStore. I also tried looking around developer.apple.com, but cannot find where a Xcode 11.4 download option might exist.If someone can please point me to the proper location to grab XCode 11.4 I would be most grateful.
2
0
2.1k
Apr ’20
Game Center sends an immediate DISCONNECT after all CONNECTS provided
I am testing my peer-to-peer game application by starting a 4-player game (3 real iPhones + 1 simulator iPhone) and I am experiencing an issue where Game Center sends a CONNECT for each player in the match, via the "didChange state" function (as expected), but then immediately sends a DISCONNECT for one of the players. It seems the DISCONNECT is only received by one of the players in the game. In addition, the player who Game Center disconnected, is still available in the game with the remaining players. I would have assumed that if Game Center is going to send a disconnect to one player then it would send the same disconnect to all other players, but this is not the case. Player 1 = Xcode simulator player (didChange state) Player 2 CONNECT (didChange state) Player 3 CONNECT (didChange state) Player 4 CONNECT (didChange state) Player 2 DISCONNECT Player 1 no longer has a network connection to Player 2 Player 1, Player 3 and Player 4 maintain a network connection with each other Player 2, Player 3 and Player 4 maintain a network connection with each otherThis occurs about 1 out of every 13-15 times I attempt to create a 4-player game.Is there anything which I might be doing that might be causing Game Center to behave this way or is Game Center known to act this way sometimes?
1
0
749
Apr ’20
How to handle Game Center updates occurring at the same time?
I use GameKItHelper as a base to process information sent from Game Center.I just discovered the "match (didChange state: )" function is immediately being called twice, back to back at the same exact time, to indicate two other players in the match have connected. In addition, both separate function calls indicate "expectedPlayerCount = 0" so my match processing starts twice, thus resulting in bad things happening.I experienced this in the past and added a "myMatchStarted" boolean flag to indicate when the match really started, so I could stop the match from starting a second time (see code below). This code was confirmed to be working for many various cases which would have originally failed, so I thought I resolved this issue.However, I just experienced this issue one more time where my code updates (below) were still not good enough to block two simutaneous calls to the "match (didChange state: )" function if these functions occurred really really close to each other.Please refer to the debug output (provided below the code snippet) to see how the function is being called twice extremely fast and how the "myMatchStarted" boolean flag did not even have a chance to be set for the first function call, thus could not stop the second call from being processed.How should I process Game Center function calls which occur at the same time?func match(_ match: GKMatch, player: GKPlayer, didChange state: GKPlayerConnectionState) { print("(GAMEKIT) ENTER match() didChange state") switch (state) { case GKPlayerConnectionState.connected: print("(GAMEKIT) PLAYER CONNECTED! = \(player.displayName)") if (myMatchStarted == false) { print("(GAMEKIT) (match didChange) Match DID NOT start yet") if (match.expectedPlayerCount == 0) { print("(GAMEKIT) (match didChange) START THE MATCH!") startMatch() } } etc.. } func startMatch() { print("(GAMEKIT) ENTER startMatch()") if (myMatchStarted == true) { print("(GAMEKIT) ** MATCH ALREADY STARTED, DO NOT START AGAIN !! **") return } myMatchStarted = true loadOtherPlayerInfo() print("(GAMEKIT) EXIT startMatch()") }LOG OUTPUT(GAMEKIT) ENTER match() didChange state(GAMEKIT) ENTER match() didChange state(GAMEKIT) PLAYER CONNECTED! = Bob(GAMEKIT) PLAYER CONNECTED! = Mary(GAMEKIT) (match didChange) Match DID NOT start yet(GAMEKIT) (match didChange) START THE MATCH!(GAMEKIT) (match didChange) Match DID NOT start yet(GAMEKIT) (match didChange) START THE MATCH!(GAMEKIT) ENTER startMatch()(GAMEKIT) ENTER startMatch()(GAMEKIT) ENTER loadOtherPlayerInfo(GAMEKIT) ENTER loadOtherPlayerInfo(GAMEKIT) EXIT startMatch()(GAMEKIT) EXIT match() didChange state(GAMEKIT) EXIT startMatch()(GAMEKIT) EXIT match() didChange state
2
0
693
Apr ’20
Unexpected messaging and event data from Game Center
Throughout the testing of my game, I have noticed multiple unexpected message events provided by Game Center which required me to add special code handling to overcome. I confirmed all of these issues occur more often then I would have thought.Has anyone else experienced these issues as well?Issues1) Game Center sends CONNECTED for all players then immediately sends DISCONNECT for one player before the match even had a chance to startGame Center sends a "match(didChange state)" CONNECTED indication for each non-GKLocalPlayer in the match (as expected) and eventually indicates the expectedPlayerCount is 0 so match start processing can begin (as expected), which involves loading all other player information via GKPlayer.loadPlayers(forIdentifiers: ) method. However, Game Center will then sometimes immediately send a "match(didChange state)" DISCONNECT, indicating one of the other players has disconnected from the match, even though that player never quit/disconnected from the match themselves. Also, no other player in the match receives this same DISCONNECT event either. The player who was disconnected from Game Center still maintains two-way network connections to other players and a one-way network connection to the player who did receive the disconnect event, so the player is clearly not totally disconnected.This quick DISCONNECT event arrives before "match start" processing has even completed (ie: before GKPlayer.loadPlayers completion handler is called). This has been experienced in 3 and 4 player matches2) Game Center sends a separate CONNECTED state change event for both players and both CONNECTED events indicate expectedPlayerCount = 0In a three player game, the GKLocalPlayer, who requested the match to be created, will receive a separate "match(didChange state)" CONNECTED indication for each of the other two players in the match (as expected), however, both individual CONNECTED events will have expectedPlayerCount = 0. I was under the impression only the last CONNECTED event would indicate expectedPlayerCount = 0 (ie: all players are ready), but that is no the case. This has been experienced in 3 player matches.3) Game Center sends two DISCONNECT state changes for the same player back to backWhen a player quits from my game, then I ensure the match is disconnected by calling "myMatch.disconnect( )". When this occurs, it is expected that all other players still in the match will receive one DISCONNECT state change event from Game Center, indicating one of the players have quit/disconnected from the game. However, I see Game Center sometimes sends two "match(didChange state)" DISCONNECT events one after the next. This has been experienced in 3 and 4 player matches4) Messages never arrive at the intended player destinationMessages sent from one player, using the following ".reliable" protocol, results in the message never arriving at the intended player. This is very annoying when the message which never arrives is the initial "game init data" message which includes all of the information required to sync up the game between all players before it starts. This has been experienced in 3 and 4 player matches. myMatch?.send(data, to: playerArray, dataMode: .reliable)
0
0
581
Mar ’20
How to resolve Large Style before iOS 13.0 warning?
I have the following warning in my application and have no idea how to resolve it. Any ideas? Large Style before iOS 13.0Googling around did not provide much insight, however, it seems to be related to the Activity Indicator object I am using on my ViewController, which has it's property set to "Large". Note: If I seet the property to "Medium" then I get a warning called "Medium Style before iOS 13.0" instead
2
1
4.9k
Mar ’20
Dispatch.main queue questions since I might be confused
I am new to swift and have been working my first application for a while now. During testing I have seen some crashes in my code and I believe they are caused by some of the UI updates not being processed on the main thread. I googled around and I read all "UI Updates" need to be made on the main thread. Will someone please confirm what exactly a "UI update" actually is for me?Do I need to wrap all of the following inside "DispatchQueue.main.async" ?updating text in a TextViewupdating a UIButton textadding corner radius and button width values to a UIButtoneverytime I want to present an alert messageeach time I call "dismiss(animated: true, completion: nil)" to close the current ViewController and return to the previous oneeach time I call "storyBoard.instantiateViewController(withIdentifier: )" to create a ViewController and also when calling "present( )"updating the myLabel.frame.size values (width and height)updating a scrollview.frame.size valuewhen the "isHidden" property of a button, label, etc is setsetting colors to labels, buttons, etc.In my viewDidLoad( ), viewWillLayoutSubviews( ), viewDidLayoutSubviews( ), etc. functions I hide objects, set borders, set colors, set ScrollView sizes, etc.. so would I use "DispatchQueue.main.async" inside all of these functions?I do a bunch of UI updates (I believe) so wanted to understand whether I need to add a ton of separate "DispatchQueue.main.async" wrappers all over my code. It seems I would need plenty and I am concerned about polluting my code, where all you see is a ton of "DispatchQueue.main.async" wrappers all over the place.Does my application start off using the main thread and then for some reason goes into the background thread? if so, then perhaps I would only need to use Dispatch in cases where my application would switch to the background thread? I would not know when this would occur of course.I am also concerned that if I use "async" throughout my code then the code inside the Dispatch region will not execute right then but rather continue on executing the code located after/outside the dispatch region, whcih would be out of order as I would like the code to execute.Perhaps someone can confirm all of this for me?ASIDEI tried using a DispatchQueue.main.async code wrapper around some code which updates label and button text. I confirmed the code inside the Dispatch region occasionally does not execute. I see the print statements which are before and after the Dispatch region but sometimes(occasionally) the print statements inside the region do not get hit. Should I be using "sync" instead of "async" to guarantee by code always runs when I want it to?
6
1
7.6k
Mar ’20
No longer can load or test application on iPhone via XCode 11
Help Please ... My application development has completely stopped.I mistakenly clicked "DENY" button when prompted to enter my password for loading my application on to my iPhone and now I can no longer load my application on "any" iPhones I have available for testing. Clicking the RUN button in XCode, "immediately" results in Build Failed and then clicking on the little RED error circle indicates the following: "Command CodeSign failed with a nonzero exit code"Typically, I would do the following to successfully load my application on my iPhone for testing:Attach my iPhone via USB cable to my MacBook AirSelect my iPhone from the dropdown box (instead of a simulator)Click RUNEnter my Macbook Air password to allow the application to be loaded on to my iPhoneApplication starts on my iPhone and can be used with XCode for debuggingI googled around for this error and see it has something to do with Mac KeyChain and certificates. I am "not" a Mac user at all so going in and messing with certificates makes me very nervous. I am afraid I will really mess something up and then not be able to develop my application anymore.Since I clicked DENY, I am assuming this is blocking all iPhones from being loaded. How do I ALLOW again so XCode will start prompting me to enter my password again and allow my iPhones to be loaded and used for testing once againCompiling and running using a specific Xcode simulator is still working, however, I need real iPhone to continue testing my app at this pointI tried "Product/Clean Build Folder" but this still did not allow me to load my real iPhone. In "KeyChain Access" I do/see the following:Select Login (Key Chains)Select Keys (Category)I see "Apple Development - <my Name> (private key)" listedClicking the little "expand arrow" icon I can see the following associated certificate: Apple Development - <my Name> (Cert ##) (certificate)After right-clicking the "(private key)" entry, selecting "Get Info" then "Access Control", I see the following option set: Allow all appplications to access this itemAfter right-clicking the "(certificate)" entry, selecting "Get Info" and expanding the "Trust" section, I see the following option set: When using this certificate = Use System Defaults
5
0
1.2k
Mar ’20