Before Xcode 15.0, I removed this rows. After updating it appeared again without possibility to remove it. In this screenshot part of my settings.
When I'm trying to rename it, it's create a new row with new name and the old with old name still there.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Im trying to use new functionality of navigation in SwiftUI and now I've problem with similar early problem in NavigationLink when destination view created more than twice. Could you please help me to find right solution.
As you can see the WelcomeViewModel created multiple times. I'm tried add a specific id to make view/viewModel unique, but it's didn't help.
enum Step: String, Identifiable {
case page1
case page2
case page3
var id: String {
self.rawValue
}
}
class Router: ObservableObject {
@Published var steps: [Step] = []
static let shared = Router()
private init(){}
func showPage1() {
steps.append(.page1)
}
func showPage2() {
steps.append(.page2)
}
func showPage3() {
steps.append(.page3)
}
func popToRoot() {
steps.removeAll()
}
}
class BaseStepViewModel: ObservableObject {
let step: Step
let router: Router
init(step: Step, router: Router) {
self.step = step
self.router = router
print("Created step \(step.rawValue)")
}
func shopNextPage() {
router.showPage2()
}
}
class Step1ViewModel: BaseStepViewModel { }
class Step2ViewModel: BaseStepViewModel {
override func shopNextPage() {
router.showPage3()
}
}
class Step3ViewModel: BaseStepViewModel {
override func shopNextPage() {
router.popToRoot()
}
}
struct StepView: View {
@StateObject var viewModel: BaseStepViewModel
var body: some View {
Button {
viewModel.shopNextPage()
} label: {
Text(viewModel.step.rawValue)
}
}
}
class WelcomeViewModel: ObservableObject, Identifiable {
let title: String
let router: Router
var id: String {
title
}
init(title: String, router: Router) {
self.title = title
self.router = router
print("Created welcome view")
}
func startFlow() {
router.showPage1()
}
}
struct WelcomeView: View {
@StateObject var viewModel: WelcomeViewModel
var body: some View {
Button {
viewModel.startFlow()
} label: {
Text(viewModel.title)
}
}
}
struct RootView: View {
@StateObject var router = Router.shared
var body: some View {
NavigationStack(path: $router.steps) {
WelcomeView(viewModel: .init(title: "Welcome", router: router))
.id("Welcome")
.navigationDestination(for: Step.self) { step in
switch step {
case .page1:
StepView(viewModel: Step1ViewModel(step: step, router: router))
case .page2:
StepView(viewModel: Step2ViewModel(step: step, router: router))
case .page3:
StepView(viewModel: Step3ViewModel(step: step, router: router))
}
}
}
}
}
Hello!
I have an beacon (this. device doesn't support pair) that should work as SOS button, but required option is that the device should work for a long time in background.
Sequence algorithm:
BLE device send trigger to nearest device
iPhone should receive this trigger (in background) then do network request
I can't find right solution cz the BGTask has 30 sec limit
Topic:
App & System Services
SubTopic:
Hardware
Tags:
External Accessory
Background Tasks
Core Bluetooth
Today i have little problem and I can't understand what's happened. I'm trying to implement realtime applying CIFIlter(s) to image from video stream using MTKView without delegate. I have this error:Take image and send to processing code:extension CameraCamptureOperator: AVCaptureVideoDataOutputSampleBufferDelegate {
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
DispatchQueue.main.async {
connection.videoOrientation = AVCaptureVideoOrientation(rawValue: UIApplication.shared.statusBarOrientation.rawValue) ?? .portrait
}
guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return }
DispatchQueue.main.async {[weak self] in
self?.delegate?.campturedNewImage(CIImage(cvImageBuffer: pixelBuffer))
}
}
}In didSet image, I calling render(): private func renderingInProcess() {
guard let image = imageToDraw,
let targetTexture = mtkView.currentDrawable?.texture else { return }
let commandBuffer = GraphicApi.commandQueue?.makeCommandBuffer()
let render = mtkView.currentRenderPassDescriptor
render?.colorAttachments[0].clearColor = .init(red: 244.0/255.0, green: 241.0/255.0, blue: 238.0/255.0, alpha: 1.0)
let renderEncoder = commandBuffer?.makeRenderCommandEncoder(descriptor: render!)
renderEncoder?.endEncoding()
let scaleX = mtkView.drawableSize.width / image.extent.width
let scaleY = mtkView.drawableSize.height / image.extent.height
let scale = min(scaleX, scaleY)
let scaledImage = image.transformed(by: CGAffineTransform(scaleX: scale, y: scale))
var bounds = CGRect(origin: .zero, size: mtkView.drawableSize)
if scale == scaleX {
let space = (mtkView.drawableSize.height - scaledImage.extent.height) / 2
let origin = CGPoint(x: 0, y: -space)
bounds.origin = origin
} else {
let space = (mtkView.drawableSize.width - scaledImage.extent.width) / 2
let origin = CGPoint(x: -space, y: 0)
bounds.origin = origin
}
GraphicApi.context.render(scaledImage,
to: targetTexture,
commandBuffer: commandBuffer,
bounds: bounds,
colorSpace: GraphicApi.colorSpace)
commandBuffer!.present(mtkView.currentDrawable!)
commandBuffer!.commit()
}[CAMetalLayerDrawable present] should not be called after already presenting this drawable. Get a nextDrawable instead.[Common] _BSMachError: port 600b; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND" Execution of the command buffer was aborted due to an error during execution. Discarded (victim of GPU error/recovery) (IOAF code 5)2018-11-29 22:07:58.446854+0200 AVCIProject[1244:223735] [Common] _BSMachError: port 5597; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"