Posts

Post marked as solved
2 Replies
424 Views
Using the CIFilter.qrCodeGenerator() to create a QR code I wanted to change the colours dynamically to suit Light/Dark mode, but was unable to figure out how to achieve this, is it possible please ? struct QrCodeImage {     let context = CIContext()     func generateQRCode(from text: String) -> UIImage {         var qrImage = UIImage(systemName: "xmark.circle") ?? UIImage()         let data = Data(text.utf8)         let filter = CIFilter.qrCodeGenerator()         filter.setValue(data, forKey: "inputMessage")         let transform = CGAffineTransform(scaleX: 2, y: 2)         if let outputImage = filter.outputImage?.transformed(by: transform) {             if let image = context.createCGImage(                 outputImage,                 from: outputImage.extent) {                 qrImage = UIImage(cgImage: image)             }         }         return qrImage     } } Further, I cannot see an option for the different modes and assume that any colour could be used, which would be a lot better for me. ref: https://developer.apple.com/documentation/coreimage/ciqrcodegenerator
Posted
by forklift.
Last updated
.
Post marked as solved
1 Replies
334 Views
Working from Apple documentation I wanted to apply the CIPixellate filter to a SpriteKit Node and found that SKEffectNode grants access to CoreGraphic's filters and could be a good bridge. I can get the image to pixelate, but I am looking for a smooth transition between the two stages and believe that I am having trouble with the "simd_smoothstep" function: let pixelateNode: SKEffectNode = SKEffectNode() let testSprite = SKSpriteNode(imageNamed: "testSprite") let filter = CIFilter(name: "CIPixellate")! let inputScale = simd_smoothstep(1, 0, abs(0.9)) let filter = CIFilter(name:"CIPixellate", parameters: [kCIInputImageKey: testSprite, kCIInputScaleKey: inputScale]) pixelateNode.filter = filter pixelateNode.shouldEnableEffects = true addChild(pixelateNode) pixelateNode.addChild(testSprite) ref: https://developer.apple.com/documentation/coreimage/customizing_image_transitions ref: https://developer.apple.com/documentation/coreimage/customizing_image_transitions nb. this is a repost in the SpriteKit forum. The old post can be removed: https://developer.apple.com/forums/thread/684687
Posted
by forklift.
Last updated
.
Post not yet marked as solved
1 Replies
316 Views
Working from Apple documentation I wanted to apply the CIPixellate filter to a SpriteKit Node and found that SKEffectNode grants access to CoreGraphic's filters and could be a good bridge. I can get the image to pixelate, but I am looking for a smooth transition between the two stages and believe that I am having trouble with the "simd_smoothstep" function: let pixelateNode: SKEffectNode = SKEffectNode() let testSprite = SKSpriteNode(imageNamed: "testSprite") let filter = CIFilter(name: "CIPixellate")! let inputScale = simd_smoothstep(1, 0, abs(0.9)) let filter = CIFilter(name:"CIPixellate", parameters: [kCIInputImageKey: testSprite, kCIInputScaleKey: inputScale]) pixelateNode.filter = filter pixelateNode.shouldEnableEffects = true addChild(pixelateNode) pixelateNode.addChild(testSprite) ref: https://developer.apple.com/documentation/coreimage/customizing_image_transitions
Posted
by forklift.
Last updated
.
Post marked as solved
1 Replies
484 Views
I am looking to integrate my code with CoreData. Presently I have the following of which allows a worker to check their requirements against an advert e.g. if the worker needs x3 sponges to clean a bathroom, then the advert must provide those sponges, but the worker can only work on set days: var cdExample: [CleaningRota] = [bathroomMonday, kitchenFriday]&#9;// [Full sample code](https://developer.apple.com/forums/content/attachment/648c2166-46f3-44a3-bfc7-5e36f3d38721){: .log-attachment} CORE DATA EXAMPLE &#9;&#9;let personAvailable: [Person] = [kath, mavis] &#9;&#9;//CORE DATA EXAMPLE : WORK ON OFFER &#9;&#9;for work in cdExample { &#9;&#9;&#9;&#9;//WORK TOOLS PROVIDED ON SITE &#9;&#9;&#9;&#9;for toolsAvailable in work.tool { &#9;&#9;&#9;&#9;&#9;&#9;//PERSONS AVAILABLE TO WORK &#9;&#9;&#9;&#9;&#9;&#9;for person in personAvailable { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;//PERSONAL REQUEST : SPECIFIC WORK DAY &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;if person.avilability == work.day { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;//CHECK PERSON TOOL REQUIREMENTS FOR JOB &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;for personRequirement in person.materialsNeeded { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;//CYCLE THROUGH TOOLS WORKER NEEDS ON SITE &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;if personRequirement.tool == toolsAvailable.name { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;//CONFIRM TOOLS WORKER NEEDS ARE FULLY PROVIDED &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;//AVOID CHECKING SAME STOCK TWICE IF CONDITION PREVIOUSLY MET &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;if personRequirement.quantity <= toolsAvailable.stock && personRequirement.met == false { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print(">>0> \(person.name)") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print(">>1> \(personRequirement.tool) : \(personRequirement.quantity)") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print(">>2> \(toolsAvailable.name) : \(toolsAvailable.stock)") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;personRequirement.met = true &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;person.materialID.append(toolsAvailable.id) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;} &#9;&#9;} As the adverts and requirements pile up this kind of system will not scale very quickly. I would like to know if there is a better way to model this data, or to check conditions. I plan to pull the cdExample from CoreData, and am unfamiliar with using it. Being a proprietary Apple Framework I do not know if anyone will help me here, but if not then how best to achieve what I want without a pyramid of doom (which I don't mind), is there a better way please? I also need to remove the stock, which I ran into trouble with as I had too many loops and hit a bug in Xcode, so I think I'm doing something wrong with all of these loops ?
Posted
by forklift.
Last updated
.
Post not yet marked as solved
2 Replies
357 Views
Using a relationship I am able to pair entries together, but cannot figure out how to exactly match the customer that I am looking for, nor to create new records without overwriting the old ones. let userEntryRecord = NSEntityDescription.entity(forEntityName: “Record”, in: managedContext)! let userEntryCustomer = NSEntityDescription.entity(forEntityName: “Customer”, in: managedContext)! let dataRecord = NSManagedObject(entity: userEntryRecord, insertInto: managedContext) as? Record let dataCustomer = NSManagedObject(entity: userEntryCustomer, insertInto: managedContext) as? Customer dataRecord?.year = “2021” dataRecord?.month = “March” dataRecord?.addToCustomer(dataCustomer ?? Customer()) dataCustomer?.age = 20 dataCustomer?.gender = “male” dataCustomer?.country = “UK I would like to search for all records for October 2023, with those of ages between 20-40, how do I create a fetch request for that ? On top of that, I need to amend records, and of course create new years to attach records to, something I am having difficulty with.
Posted
by forklift.
Last updated
.
Post not yet marked as solved
0 Replies
259 Views
Is there any protocol conformance to utilise the Full Screen capture feature present in iOS 13 as seen in apps like Safari and Mail?
Posted
by forklift.
Last updated
.
Post not yet marked as solved
0 Replies
416 Views
I have a new computer and would like to dedicate it to just development work in Xcode, for this I have a separate developer account to my normal iCloud personal account. However, I only have one iPhone, a personal one. Can I test apps on my iPhone with my personal account on the computer with a separate developer account through Xcode?
Posted
by forklift.
Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
I presently just fall foul of Apple's requirements to upgrade to Mojave, it a problem now because of the recent requirement that devices compile to iOS 12.1, which requires Swift 5, of which I cannot install on my machine!My main workstation is a May 2011-October 2012 iMac, I do not have the money to invest in a new computer and was wondering if I could get away with a Mac Mini, which I could hook up to the iMac as a screen?I could use a Thunderbolt cable to achieve this, but would it work?
Posted
by forklift.
Last updated
.
Post not yet marked as solved
3 Replies
1.3k Views
Drawing vectors with UIBezierPath I would like to export them as an SVG data file, but I think Apple's SDK only has a decoding option when dealing with SVGs, not encoding?Any ideas?
Posted
by forklift.
Last updated
.
Post not yet marked as solved
1 Replies
439 Views
I read of an app that features emoticons being rejected, which turned out to be because they were the property of Apple, even though drawn from a standard definition, they were created by Apple, which I understand.I was toying with the idea of releasing an app with an emoticon for a name, but just searching by emoticon I don't see any apps pop up for the most obvious emojis and assume then that this practice is not allowed?
Posted
by forklift.
Last updated
.
Post marked as solved
4 Replies
1k Views
I know that it's woefully inefficient and doesn't quite visually match up, but I really like the idea of VFL and wanted to try to recreate a standard simplified calculator UI with it.The code below does sort of resemble the UI (no logic to the buttons) but I would care to know any improvements to scale better without using hard coded points, just constraints so that it scales devices independently (I am especially looking for a loop to cut down on UI control declarations):@IBDesignable class calcButtons: UIButton { override init(frame: CGRect) { super.init(frame: frame) calcButtons() } required init?(coder: NSCoder) { super.init(coder: coder) calcButtons() } private func calcButtons() { let calcPlus = UIButton() calcPlus.translatesAutoresizingMaskIntoConstraints = false calcPlus.setTitle("+", for: .normal) calcPlus.setTitleColor(UIColor.black, for: .normal) calcPlus.setTitleColor(UIColor.white, for: .highlighted) calcPlus.backgroundColor = UIColor.orange addSubview(calcPlus) let calcSubtract = UIButton() calcSubtract.translatesAutoresizingMaskIntoConstraints = false calcSubtract.setTitle("-", for: .normal) calcSubtract.setTitleColor(UIColor.black, for: .normal) calcSubtract.setTitleColor(UIColor.white, for: .highlighted) calcSubtract.backgroundColor = UIColor.orange addSubview(calcSubtract) let calcMultiply = UIButton() calcMultiply.translatesAutoresizingMaskIntoConstraints = false calcMultiply.setTitle("x", for: .normal) calcMultiply.setTitleColor(UIColor.black, for: .normal) calcMultiply.setTitleColor(UIColor.white, for: .highlighted) calcMultiply.backgroundColor = UIColor.orange addSubview(calcMultiply) let calcDivide = UIButton() calcDivide.translatesAutoresizingMaskIntoConstraints = false calcDivide.setTitle("÷", for: .normal) calcDivide.setTitleColor(UIColor.black, for: .normal) calcDivide.setTitleColor(UIColor.white, for: .highlighted) calcDivide.backgroundColor = UIColor.orange addSubview(calcDivide) let calcEquals = UIButton() calcEquals.translatesAutoresizingMaskIntoConstraints = false calcEquals.setTitle("=", for: .normal) calcEquals.setTitleColor(UIColor.black, for: .normal) calcEquals.setTitleColor(UIColor.white, for: .highlighted) calcEquals.backgroundColor = UIColor.orange addSubview(calcEquals) let calcDot = UIButton() calcDot.translatesAutoresizingMaskIntoConstraints = false calcDot.setTitle(".", for: .normal) calcDot.setTitleColor(UIColor.black, for: .normal) calcDot.setTitleColor(UIColor.white, for: .highlighted) calcDot.backgroundColor = UIColor.orange addSubview(calcDot) let calcDisplay = UIButton() calcDisplay.translatesAutoresizingMaskIntoConstraints = false calcDisplay.setTitle("1234567890", for: .normal) calcDisplay.setTitleColor(UIColor.black, for: .normal) calcDisplay.setTitleColor(UIColor.white, for: .highlighted) calcDisplay.backgroundColor = UIColor.orange addSubview(calcDisplay) let calcSpacer1 = UIButton() calcSpacer1.translatesAutoresizingMaskIntoConstraints = false calcSpacer1.setTitle("§", for: .normal) calcSpacer1.setTitleColor(UIColor.black, for: .normal) calcSpacer1.setTitleColor(UIColor.white, for: .highlighted) calcSpacer1.backgroundColor = UIColor.orange addSubview(calcSpacer1) let calcSpacer2 = UIButton() calcSpacer2.translatesAutoresizingMaskIntoConstraints = false calcSpacer2.setTitle("§", for: .normal) calcSpacer2.setTitleColor(UIColor.black, for: .normal) calcSpacer2.setTitleColor(UIColor.white, for: .highlighted) calcSpacer2.backgroundColor = UIColor.orange addSubview(calcSpacer2) let calcSpacer3 = UIButton() calcSpacer3.translatesAutoresizingMaskIntoConstraints = false calcSpacer3.setTitle("§", for: .normal) calcSpacer3.setTitleColor(UIColor.black, for: .normal) calcSpacer3.setTitleColor(UIColor.white, for: .highlighted) calcSpacer3.backgroundColor = UIColor.orange addSubview(calcSpacer3) let calcSpacer4 = UIButton() calcSpacer4.translatesAutoresizingMaskIntoConstraints = false calcSpacer4.setTitle("§", for: .normal) calcSpacer4.setTitleColor(UIColor.black, for: .normal) calcSpacer4.setTitleColor(UIColor.white, for: .highlighted) calcSpacer4.backgroundColor = UIColor.orange addSubview(calcSpacer4) let calc1 = UIButton() calc1.translatesAutoresizingMaskIntoConstraints = false calc1.setTitle("1", for: .normal) calc1.setTitleColor(UIColor.black, for: .normal) calc1.setTitleColor(UIColor.white, for: .highlighted) calc1.backgroundColor = UIColor.orange addSubview(calc1) let calc2 = UIButton() calc2.translatesAutoresizingMaskIntoConstraints = false calc2.setTitle("2", for: .normal) calc2.setTitleColor(UIColor.black, for: .normal) calc2.setTitleColor(UIColor.white, for: .highlighted) calc2.backgroundColor = UIColor.orange addSubview(calc2) let calc3 = UIButton() calc3.translatesAutoresizingMaskIntoConstraints = false calc3.setTitle("3", for: .normal) calc3.setTitleColor(UIColor.black, for: .normal) calc3.setTitleColor(UIColor.white, for: .highlighted) calc3.backgroundColor = UIColor.orange addSubview(calc3) let calc4 = UIButton() calc4.translatesAutoresizingMaskIntoConstraints = false calc4.setTitle("4", for: .normal) calc4.setTitleColor(UIColor.black, for: .normal) calc4.setTitleColor(UIColor.white, for: .highlighted) calc4.backgroundColor = UIColor.orange addSubview(calc4) let calc5 = UIButton() calc5.translatesAutoresizingMaskIntoConstraints = false calc5.setTitle("5", for: .normal) calc5.setTitleColor(UIColor.black, for: .normal) calc5.setTitleColor(UIColor.white, for: .highlighted) calc5.backgroundColor = UIColor.orange addSubview(calc5) let calc6 = UIButton() calc6.translatesAutoresizingMaskIntoConstraints = false calc6.setTitle("6", for: .normal) calc6.setTitleColor(UIColor.black, for: .normal) calc6.setTitleColor(UIColor.white, for: .highlighted) calc6.backgroundColor = UIColor.orange addSubview(calc6) let calc7 = UIButton() calc7.translatesAutoresizingMaskIntoConstraints = false calc7.setTitle("7", for: .normal) calc7.setTitleColor(UIColor.black, for: .normal) calc7.setTitleColor(UIColor.white, for: .highlighted) calc7.backgroundColor = UIColor.orange addSubview(calc7) let calc8 = UIButton() calc8.translatesAutoresizingMaskIntoConstraints = false calc8.setTitle("8", for: .normal) calc8.setTitleColor(UIColor.black, for: .normal) calc8.setTitleColor(UIColor.white, for: .highlighted) calc8.backgroundColor = UIColor.orange addSubview(calc8) let calc9 = UIButton() calc9.translatesAutoresizingMaskIntoConstraints = false calc9.setTitle("9", for: .normal) calc9.setTitleColor(UIColor.black, for: .normal) calc9.setTitleColor(UIColor.white, for: .highlighted) calc9.backgroundColor = UIColor.orange addSubview(calc9) let calc0 = UIButton() calc0.translatesAutoresizingMaskIntoConstraints = false calc0.setTitle("0", for: .normal) calc0.setTitleColor(UIColor.black, for: .normal) calc0.setTitleColor(UIColor.white, for: .highlighted) calc0.backgroundColor = UIColor.orange addSubview(calc0) let views = ["calcPlus": calcPlus, "calcSubtract": calcSubtract, "calcMultiply": calcMultiply, "calcDivide": calcDivide, "calcEquals": calcEquals, "calcDot": calcDot, "calcDisplay": calcDisplay, "calcSpacer1": calcSpacer1, "calcSpacer2": calcSpacer2, "calcSpacer3": calcSpacer3, "calcSpacer4": calcSpacer4, "calc1": calc1, "calc2": calc2, "calc3": calc3, "calc4": calc4, "calc5": calc5, "calc6": calc6, "calc7": calc7, "calc8": calc8, "calc9": calc9, "calc0": calc0] //Display NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[calcDisplay]-0-|", options: .alignAllBottom, metrics: nil, views: views)) //NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[calcDisplay]-0-|", options: .alignAllTop, metrics: nil, views: views)) //0 . = NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[calc0]-[calcDot]-[calcEquals]-0-|", options: .alignAllBottom, metrics: nil, views: views)) NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[calc0]-|", options: .alignAllBottom, metrics: nil, views: views)) //1 2 3 + NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[calc1]-[calc2]-[calc3]-[calcPlus]-0-|", options: .alignAllBottom, metrics: nil, views: views)) NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[calc1]-[calc0]-|", options: .alignAllLeading, metrics: nil, views: views)) //4 5 6 - NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[calc4]-[calc5]-[calc6]-[calcSubtract]-0-|", options: .alignAllBottom, metrics: nil, views: views)) NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[calc4]-[calc1]", options: .alignAllLeading, metrics: nil, views: views)) //7 8 9 x NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[calc7]-[calc8]-[calc9]-[calcMultiply]-0-|", options: .alignAllBottom, metrics: nil, views: views)) NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[calc7]-[calc4]", options: .alignAllLeading, metrics: nil, views: views)) //spacerx3 ÷ NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[calcSpacer2]-[calcSpacer3]-[calcSpacer4]-[calcDivide]-0-|", options: .alignAllBottom, metrics: nil, views: views)) NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[calcSpacer2]-[calc7]", options: .alignAllLeading, metrics: nil, views: views)) } }
Posted
by forklift.
Last updated
.
Post not yet marked as solved
10 Replies
639 Views
In order to better color an app to a user's iphone model is there a way to find out what color iDevice they are using my app on?e.g. if they had a Product Red iPhone then I would like to have the same for the interface so that it matched.
Posted
by forklift.
Last updated
.
Post not yet marked as solved
0 Replies
487 Views
I am new to Swift and so I question everything. Right now I am looking into the Utility options in the IDE and I really have to question the Drawing group of options:OpaqueHiddenClear Graphics ContextClip To BoundsAutoresize SubviewsOPAQUEWhen designing a layout is it ever a conscious part of the design process to consider this option, or should it not be left up to the compiler? With hardware architecture today being so fast does it really improve performance on an app that much, and if so then why leave it up to human choice to extract those performance gains when the compiler clearly knows if alpha has been applied or not?HIDDENWith little to no experience in designing UI on a Storyboard I can appreciate this quick option over coded equivalents, but it seems too easy an option to forget about if the Storyboard is busy enough. I notice that nothing can be kept outside of the storyboard as well, which is very odd coming from other design environments, I am used to just moving something out of the way in a controlled fashion, does anybody make indispensable use of this feature?CLEAR GRAPHICS CONTENTThere being a number of coding options to this protocol, I fail to understand when this would be commonly enough used in the Storyboard for it to be taking up UI space, can anybody justify this feature in regular use?CLIP TO BOUNDSI assume that anything that cannot be seen is therefore not drawn, but short of this being some sort of “punch” option it seems to preserve all the offcuts, when really these should have been trimmed off by the designer. Further, it also causes conflicting issues with other expected “one-click option” (or one line coded) behaviour like drop-shadows, is clip to bounds for lazy designers?AUTORESIZE SUBVIEWSThis is the one option of the lot that I don’t take issue with, except that I think it would better be transferred to the Size Inspector pane where the interactive demo and autoresizing guides are kept.
Posted
by forklift.
Last updated
.
Post not yet marked as solved
0 Replies
429 Views
Learning Swift and not quite capable of writing the kind of macOS Safari Extention that I would like, I am curious about the limits of Extensions in Safari?I would like to write a simple download tool that writes specific metadata from a webpage into the image being downloaded e.g. append URL into IPTC:Description field, assuming it can be done e.g. JPEG file format.I know that the exiv2 library (written in C++) can do this, but am not sure if there is another way with Swift or even if it can be done, or even allowed?Many thanks.
Posted
by forklift.
Last updated
.
Post marked as solved
6 Replies
1.3k Views
Learning Swift right now I am up to Enums and realise that Syntactical-Sugar (simplification) was always going to be something that Apple would like to do, as they did with scrollbars.While removing type names may be cool, and it is readable, it’s seems like it makes it harder to understand, but then again I am a beginner. It would be nice to have a toggle (as the compiler knows what is going on) to switch either way: to remove all of the type names, or add them in. The idea being that for the first few passes over somebody else’s code you may prefer to read all of the detail, until becoming familiar, when you then toggle it off yourself, at your convenience.I would like to know more advanced coders views on this, or if I will just get used to it?Thanks!
Posted
by forklift.
Last updated
.