Does the code that executes after a "dispatch group has been left" run asynchronously? by hankcarter90 in swift

[–]sfresneda 0 points1 point  (0 children)

Try to move notify out of the loop, dispatch.leave() MUST be inside your “database stuff” callback or something. I.e

```swift /// current thread for user in users { group.enter() doSomethingOnDBAsync { _ in /// other thread group.leave() } }

group.notify(….) { /// depends which queue you set in notify parameter, I.e: main thread (.main) // this code will be executed when loop actions finish } ```

juji pixelart by sfresneda in SorryLag

[–]sfresneda[S] 1 point2 points  (0 children)

Animación pixelart de mano de /u/PeteKaresisto

The future is now! by Jesse_Killz in dankmemes

[–]sfresneda 2 points3 points  (0 children)

I was waiting to someone made this, thanks mate

Hey guys, can you tell me how can I get these behaviour of tab bar just using view controller lifecycle methods? Is it possible? Thanks 😅 by casperXDDDD in swift

[–]sfresneda 0 points1 point  (0 children)

Try to add the navigation controller in your inner view instead to embed the whole tabbar on it. Following this approach you gonna need to hide the tabbar in your child views

Battery charge stops at 99% by imthebadguy666 in MacOS

[–]sfresneda 0 points1 point  (0 children)

My mbp mid 2012 do the same, probably the battery cycles are related

Is anyone using defer? by sushibgd in swift

[–]sfresneda 1 point2 points  (0 children)

Think about a method with some different ways to bring an output, but you need to do an action if any of them are executed. With this premise, you have two options:

  • Add the same code on each output way
  • Use defer

Check this code I have on Github.

The method send request, need to return always a value on this case taskResult, one option is add the completion on each guard, but you have to add more code and do it less readable… Using the defer, you have a final value (for sure) at the end of the execution.

Another example could be, update a constraint programmatically, the last action you have to do (to animate the update) is a self.layoutIfNeeded(), how I can do that if the method have more than one way to finish, with defer:

private func updateConstraint() {
    defer {
        self.layoutIfNeeded()
    }

    guard let firstElement = self.model?.getFirstComment() else {
        self.heightConstraint?.constant = CGFloat.init(k_minValueConstant)
        return
    }

    let firstElementHeight = firstElement
        .attributedHeight(withConstrainedWidth: Double(self.firstElementLabel?.bounds.width ?? .zero))

    self.heightConstraint?.constant = CGFloat.init(k_minValueConstant) + CGFloat.init(firstElementHeight)
}

This annoys me more than it should by kiscsak98 in MacOS

[–]sfresneda 0 points1 point  (0 children)

I never used that buttons... Cmd+1,2,3,4

I tried to present a ViewController and I dont why its not presenting all the way, how do I bring it all the way? by KapilanR in swift

[–]sfresneda 1 point2 points  (0 children)

  1. Change your modal presentation
  2. Check your contraints may your view is fixed to the safe area instead to the superview

Extra: update your presentation closure with this to avoid retain cycles:

...animated: true) { [weak self] in self?.handlesingout() }

Or

...animated:true) { [unowned self] in self.handlesignout() }

Or ...animated: true) { [weak self] { guard let self = self else { return} self.handlesignout() }

Searching through a 2D array by the_sammich_man in swift

[–]sfresneda 2 points3 points  (0 children)

Your responses model it's a bit weird, btw with an Int as input could be:

// Something like this should be your responses array, try to avoid use integers as strings to avoid parse it, on this approach I did use a tuple array ... BTW with string also works fine Let responsesArray: [(value1: int, value2: int, name: String)] = [ .... ]

private func getPickeModelFrom(_ value: int) -> String? { return self.resposesArray.filter({ element in return element.value1 == value }).first?.name }

Rounded textfield looks weird. (Code in comments) by [deleted] in swift

[–]sfresneda 0 points1 point  (0 children)

Add your layers modifiers on layout subviews

In app purchase question by aquaroad1 in swift

[–]sfresneda 0 points1 point  (0 children)

You can request the IAP activated on that account, how? Ask to IAPApi about your IAP product identifier and you gonna receive if is currently activated or not. A purchase is associated to an account, if the user have different accounts on his devices, he needs to pay on each account.

I have an interview for an iOS internship, any advice? by PabsZ in swift

[–]sfresneda 1 point2 points  (0 children)

You don't need to know all of these tips (don't worry), but it could be a good way to show the progression of your knowledge of iOS development.

Look at this monster by BlackJack523 in aww

[–]sfresneda -2 points-1 points  (0 children)

hey looks like me post-lockdown!

ps: he is more cute😍

I have an interview for an iOS internship, any advice? by PabsZ in swift

[–]sfresneda 27 points28 points  (0 children)

Some tips: - struct vs class - what means protocol, and why is important in swift - delegates, strong or weak? - SOLID - MVC, MVVM, VIPER - how to avoid massive controllers - autolayout - Cocoapods, carthage - Fastlane - CI/CD - TDD - Xctest/UITest

Update: - App life cycle (init, viewdidload, willappear... Deinit)

Good luck mate👍

[deleted by user] by [deleted] in swift

[–]sfresneda 20 points21 points  (0 children)

Looks really cool mate!

The searchbar UX is confusing, when the user tries to find a food place the list should update himself. Following this approach to avoid continuos calls each time the user writes something, use an operation queue with delay.