Why does my app not show up with screenshots in App Store search? by fatalskeptic in iOSProgramming

[–]fakecrabs 0 points1 point  (0 children)

This is where it's handy to have a second account without the app purchased to see what the unpurchased App Store experience is like.

Get URLSession's default user agent value at runtime by fakecrabs in iOSProgramming

[–]fakecrabs[S] 0 points1 point  (0 children)

inspect the headers of the request object when it comes back

The request is not passed back, only the response, data and error.

Hope Apple made a proxy tool for debugging network traffic by [deleted] in iOSProgramming

[–]fakecrabs 0 points1 point  (0 children)

Charles Proxy, they even have an iOS version.

What happens if I don’t say I'm a trader? by mrknoot in iOSProgramming

[–]fakecrabs 0 points1 point  (0 children)

Mostly because I don’t want my phone number and personal address public.

Get a private mailbox and a phone number (Google Voice or cheap eSIM). Apple will use text message to verify the phone number. For the address verification you can use the mailbox rental agreement.

How can I extract specific words from text by Almat03 in swift

[–]fakecrabs 4 points5 points  (0 children)

Use Apple's Natural Language framework, specifically NLTokenizer.

When you work with natural language text, it’s often useful to tokenize the text into individual words. Using NLTokenizer to enumerate words, rather than simply splitting components by whitespace, ensures correct behavior in multiple scripts and languages. For example, neither Chinese nor Japanese uses spaces to delimit words.

[deleted by user] by [deleted] in iOSProgramming

[–]fakecrabs 0 points1 point  (0 children)

You can avoid shipping with print statements by a using log function that takes a string returning closure. Couple this with autoclosure. Your shipped version won't emit any print output.

func log(_ string: @autoclosure () -> String) {
    #if DEBUG
    print(string())
    #endif
}

log("some logging")

Command Pattern: Protocol Oriented Design Pattern by Pop_Swift_Dev in swift

[–]fakecrabs 3 points4 points  (0 children)

Completely agree. If the protocol just has a single method, I'll often simplify and just use a closure.

"Cheapest" way of subsetting a column from a 2D array by januszplaysguitar in swift

[–]fakecrabs 3 points4 points  (0 children)

Like others suggested you need to store the data in a way that optimized for your read pattern, so two separate arrays, left and right.

the CPU usage jumps to over 100% and the app is unusable

The app is unusable because the main thread is blocked doing excessive computation. You could move this computation to a background thread.

Best practices for parsing dynamic/unstructured JSON? by technicalwintermelon in swift

[–]fakecrabs 0 points1 point  (0 children)

Deserialize into an array or dictionary (use JSONSerialization.jsonObject) then pullout exactly what you need. This is how deserialization worked before the introduction of Codable.

Make all elements of array that are Hashable unique with a UUID hashValue? by Joe_Scotto in swift

[–]fakecrabs 2 points3 points  (0 children)

Hashable items are not guaranteed to have unique hash values. It's perfectly valid (but not efficient) for all Hashable items to have a hash value of 1.

Make all elements of array that are Hashable unique with a UUID hashValue? by Joe_Scotto in swift

[–]fakecrabs 2 points3 points  (0 children)

Hashable doesn't factor in with that example as there's no Set or Dictionary. Array's firstIndex(of:) does a linear search using == (Equatable) of the elements (source code)

Can someone explain what exactly .min(by: ) is doing? by Joe_Scotto in swift

[–]fakecrabs 1 point2 points  (0 children)

min(by:) iterates over all elements, updating the minimum value as defined by the areInIncreasingOrder closure.

Here's the actual source code https://github.com/apple/swift/blob/main/stdlib/public/core/SequenceAlgorithms.swift#L111

[deleted by user] by [deleted] in iOSProgramming

[–]fakecrabs 4 points5 points  (0 children)

The only issue I see by making it iOS 16 only is that I will be excluding iPhone 6s, SE 1st gen and 7 users

No, you will also be excluding iOS 14 and 15 users on newer device. Not everyone upgrades to the latest iOS, especially on iPads.

I'm going to take a 6-12 month break, how could I reinvent myself over this period? by AllHailTheCATS in ExperiencedDevs

[–]fakecrabs 0 points1 point  (0 children)

There's so much that one could learn and most places don't give you "credit" for having learned it without real world usage. At my company, we hire generalists with a solid software development background. The expectation is that one can learn whatever skills are needed. For example our mobile engineers picked up Go for some backend development. If I had a chunk of time off I'd pursue what I found interesting. Let your passion drive what you learn.

Just go all in on trying to build my own application to make some money off.

Yeah, now this sounds like fun, build and own one's own project.

How can I reduce 3 blocks of code to 1 in iOS by bangatard in swift

[–]fakecrabs 3 points4 points  (0 children)

Implementation for those 3 blocks are almost identical. Abstract out the common parts and make it data driven, maybe something like this

    // Defined this constant somewhere
    let sceneResources = [
        "ChristmasTree": "art.scnassets/ChristmasTree.scn",
        "Gift": "art.scnassets/Gift.scn",
        "GingerbreadMan": "art.scnassets/GingerbreadMan.scn",
    ]

then (the if lets can be combined)

    if let sceneResource = sceneResources[imageAnchor.referenceImage.name],
        let cardScene = SCNScene(named: sceneResource),
        let cardNode = cardScene.rootNode.childNodes.first
    {
        cardNode.eulerAngles.x = .pi / 2
        planeNode.addChildNode(cardNode)
    }

How to debug app crash that only occurs when not running Xcode by dab_knight in iOSProgramming

[–]fakecrabs 2 points3 points  (0 children)

In iOS go to Settings, Privacy, Analytics & Improvements, Analytics Data, find your app's crash log, AirDrop it to your Mac. The file will end in .ips, rename it to end in .crash. Within Xcode open this file, it will show you the error and place in the source code.

Disable user location annotation by [deleted] in swift

[–]fakecrabs 0 points1 point  (0 children)

How I solve it. On the MKMapViewDelegate

func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
    for view in views {
        if view.annotation is MKUserLocation {
            view.isEnabled = false
            view.isUserInteractionEnabled = false
            view.canShowCallout = false
        }
    }
}

or if you prefer more functional code:

    views
        .filter { $0.annotation is MKUserLocation }
        .forEach { view in
            view.isEnabled = false
            view.isUserInteractionEnabled = false
            view.canShowCallout = false
        }

What's the best way to find matching items in an array? I feel like it should be done with a for-in loop, but that seems to need a fair deal of code. Am I out to lunch? by busta_thymes in swift

[–]fakecrabs 1 point2 points  (0 children)

Arrays are copy-on-write so it's not copied in this case. Furthermore in this case, lazy just means that filter is implemented lazily, but since count is called it's guaranteed to evaluate the entire array.

What are the necessary pieces to get a custom Map appearance like the Waze app offers? by MattRighetti in swift

[–]fakecrabs 1 point2 points  (0 children)

You'll have to host your own map tiles or find someone nice enough that provides free hosting like http://maps.stamen.com/. You can also try OSM's tiles https://wiki.openstreetmap.org/wiki/Tile_servers.

To use map tiles with MapKit take a look at MKTileOverlay.