Post

Replies

Boosts

Views

Activity

[Stanford Assignment I] How do I correctly track and update the Concentration game's flipCount in an MVC-appropriate manner?
Total beginner here working on Assignment I of Stanford's Developing iOS 11 Apps with Swift course.I managed to do all the required tasks 1 - 6 but am struggling with:8. Tracking the flip count almost certainly does not belong in your Controller in a proper MVC architecture. Fix that.We have the controller ViewControl.swift and we have the model Concentration.swift files.In the lecture, flipCount was implemented inside ViewControl.swift as such:var flipCount = 0 { didSet { flipsLabel.text = "Flips: \(flipCount)" } }Now if I simply moved that over to the model file Concentration.swift, I get an error that flipsLabel is unresolved there - which makes sense, because as I understand it, the controller should be UI-independent, and flipsLabel is clearly a UI element.But does that mean that if I track flipCount in the model, I can't use didSet at all, and instead have to doflipsLabel.text = "Flips: \(game.flipCount)"where game is my Concentration class object in the controller ViewController.swift whenever I do something that changes flipsCount?I'm confused how to separate these things out in the correct and most elegant way.
1
0
669
Mar ’20
Is there no way to check in code if the "Focus Style: High Contrast" accessibility setting on tvOS is active?
On tvOS you can choose Settings > Accessibility > Display > Focus Style > High Contrast to have teasers highlighted by a white border when focused: However, I cannot find out how to use this feature on my own custom views. It seems that only TVPosterView makes use of this High Contrast accessibility setting. I'd like to be able to show such a frame on my custom views if this setting is enabled but I cannot find how to check if it's enabled. None of the bools listed on https://developer.apple.com/documentation/uikit/uiaccessibility under Capabilities (like isVoiceOverRunning, isGuidedAccessEnabled, isReduceTransparencyEnabled, etc.) seems to refer to this Focus Style setting. Can anybody point me in the right direction? How do I check in code whether Focus Style is set to High Contrast? How do I get the High Contrast frame on non-TVPosterView views?
1
1
1.2k
Oct ’21
stdout/stderr in Instruments does not show output
I'm using Instruments to profile a C program that prints to stdout via printf but the program output does not appear in the Detail Area of the stdout/stderr instrument I added. The program is launched by Instruments itself when I click the Record button and it appears to run correctly – I just can't see the stdout output. I'm using Version 14.3.1 (14E300c) of Instruments on a MacBook Pro 16" (2019) running macOS 13.4 (22F66).
1
0
1.1k
Jun ’23
Cache-related CPU Counters in macOS Instruments stop increasing after a few seconds or don't show any measurements at all
I'm trying to learn about profiling by tracking the events L1D.REPLACEMENT, MEM_LOAD_RETIRED.L2_MISS, and MEM_LOAD_RETIRED.L3_MISS using the CPU Counters instrument in Instruments 14.3.1 (14E300c) on my MacBook Pro 16" (2019) with the Intel Core i9-9980HK, running macOS 13.4 (22F66). In this run, the counters do show some values but they don't change after the first few seconds of the program even though the program ran much longer. In other runs, the Detail Area for the CPU Counters instruments doesn't get populated at all. What am I doing wrong here and how can I get this to work? Thank you for any advice.
1
0
770
Jun ’23
Xcode (14 & 15 beta) not responding when creating a new project
I'm trying to use the Xcode 15.0 beta on macOS 13.4 (22F66) on a MacBook Pro 16" (2019) but whenever I try to start a new project, Xcode becomes unresponsive – seemingly indefinitely. In Activity Monitor I see "Open and Save Panel Service (Xcode) (Not Responding)": Even if I try to use Xcode 14.3.1 now I get the same problem. I've tried to resolve this by removing all Xcode-related files as well as the Xcode command line tools and reinstalling them but to no avail. I'd appreciate any and all help in how to fix this. EDIT: I have since found out that if I force-quit the bird process, Xcode will react again. But the bird process will start up and shoot to the top of the % CPU l column in Activity Monitor again almost instantly. It appears to be iCloud-related but I don't know what's causing it to take up so much CPU resources and make Xcode unresponsive, and how I can fix this.
3
1
2.4k
Jun ’23