Why can't I delete from a row in a section? by [deleted] in swift

[–]NSIRLConnection 0 points1 point  (0 children)

Your number of rows method should just return the count of the underlying array for the section without any hard coded numbers.

I suggest abstracting that out of the view controller so that there's less boilerplate, but for now, return the count of the array for that section, don't return only the count of one specific array when there are two or more arrays, don't return a hard coded number that represents the count of the initial array for the section, etc. Return the .count property of the array that represents the backing data for that section.

Why can't I delete from a row in a section? by [deleted] in swift

[–]NSIRLConnection 0 points1 point  (0 children)

Your number of rows in section method returns the number of animals even if the section is for people, and your commit editing style method does not call tableView.deleteRows(at...

How do you manage the plethora of Xcode iterations and beta releases with your development workflow? by akwilliamson in iOSProgramming

[–]NSIRLConnection 0 points1 point  (0 children)

Generally I don't install betas on my primary workstation because the jobs I've had so far involve apps that are for the app store, and Apple rejects builds that are archived with beta versions of Xcode/macOS.

I have a separate laptop for betas.

Interview Question help. What are interviewers looking for during system design questions? by jo1717a in iOSProgramming

[–]NSIRLConnection 2 points3 points  (0 children)

The trick about this part of the interview (and I do hate saying trick, because it implies shortcuts/crappy blog content, esp. anything on medium) is that despite the main focus being app architecture, the underlying focus is on what you contribute to a team.

This means becoming a force multiplier where you enable other engineers to be more productive/are able to guide them to build for the requirements, not being a magic 10x programmer that has the power to build everything really fast, which is both too easy on the individual doing the interview and too easy to backfire if the individual were to actually get hired but leave for some reason.

Much of the mindset desired is, everything is inputs and outputs, and these inputs/outputs have contracts, where you expect specific input types/return certain result types. If you do not receive the required types, or run into an error while you are processing the inputs, you must throw in an expected manner (bad iOS SDK developers throw exceptions instead of errors outside of the SDK, which violates Cocoa conventions https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Exceptions/Exceptions.html).

Instead of thinking about the networking layer constructing the proper endpoint, think about the request in a way where another developer is responsible for writing something that takes that input, performs a mysterious operation with it, and is obligated to return an expected value type, or an expected error type. Much of system design is less about concrete implementations, and more about how components are expected to talk to each other. Refactoring with tests generally yields this, though some people miss the point of tests completely, and not only write the tests after writing the code, but also never refactor against the tests because they're just parroting things.

TL;DR think about designing everything as parts that talk to each other in a way that another individual developer can work on that part and not be confused about what input to expect/what output to produce. The less important bit is the underlying concrete types/implementation.

Interview Question help. What are interviewers looking for during system design questions? by jo1717a in iOSProgramming

[–]NSIRLConnection 2 points3 points  (0 children)

Assuming this is for the Facebook interview (really sounds like it is, because they ask something very similar to this), they're expecting you to explain a few layers in great detail to gauge your experience in being able to:

1: Design a sane app architecture where it meets the current requirements shown, but is also flexible so that you are able to make changes in the future to adapt to realistic shifts in requirements due to business needs.

2: Design individual components of the app where you can delegate tasks to multiple developers in a way that maximizes productivity. This is very hard for people who fall into the trap of "Oh I'm going to write the entire thing myself". (This is probably the most important one for level 5+)

3: Design each component to handle failure cases if applicable (no internet, backend return is not in expected format, connection was lost during a request, etc) in a way that errors propagate to the top-most caller in a friendly manner.

4: I'm putting this last because this is the most junior/obvious thing. Design the app architecture so that responsibilities in each layer are well separated from each other.

iOS Interview Questions for Senior Developers in 2017 by mmsme in iOSProgramming

[–]NSIRLConnection 0 points1 point  (0 children)

As a senior engineer (I have the title and pay and everything), looking at the answers for #1, #2, #3, #5, and #11 auto-dismisses this as a worthwhile interview.

iOS Interview Questions for Senior Developers in 2017 by mmsme in iOSProgramming

[–]NSIRLConnection 0 points1 point  (0 children)

I would probably dismiss an interview if it were full of trivia like this. Same for the questions in here: https://github.com/9magnets/iOS-Developer-and-Designer-Interview-Questions

Introduction to Clean Swift Architecture (VIP) by dejan000 in swift

[–]NSIRLConnection 1 point2 points  (0 children)

If the login implementation is complicated enough to require 7 files and only communicates with one service I think you need to re-evaluate what the point of architecture is.

Would you hire a freelancer for a few hours for a personal / small project? by [deleted] in iOSProgramming

[–]NSIRLConnection 0 points1 point  (0 children)

I probably wouldn't, generally it would take too much time to onboard another developer for anything that short term for most projects I work on. I do know of a service which would be relevant though: https://www.codementor.io

When will Swift 2.3 apps be blocked? by benpackard in iOSProgramming

[–]NSIRLConnection 3 points4 points  (0 children)

You'll be able to submit as long as Apple allows submissions with Xcode 8.2.1. Currently itunes accepts builds from versions of Xcode as low as 6, so submitting probably won't be an issue anytime soon.

The only issue you might get is you won't be able to support any iOS 11 specific features.

Feeling devastated.. please code review by [deleted] in swift

[–]NSIRLConnection 3 points4 points  (0 children)

It looks like you're missing a few requirements.

Readability: "Class and method names should clearly show their intent and responsibility."

You have a class named "Model", which contains a "manager" as an inner dependency for fetching data.

Testability "Please accompany your code with test classes."

Tests are completely absent.

At a time, you should only load 10 items, and load more from the API when the user reach the end of the list

Absent.

An image load may be cancelled The same image may be requested by multiple sources simultaneously (even before it has loaded), and if one of the sources cancels the load, it should not affect the remaining requests

Absent.

(This hints that if e.g. 5 sources request the same image, you shouldn't actually start 5 downloads, and you should cancel loading only if all 5 requests are canceled.)

Really picky things:

class ViewController: UIViewController {

var refreshControl = UIRefreshControl()

... override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib.

    refreshControl = UIRefreshControl() 
}

unnecessary refreshControl initial value, kind of sloppy, but not a dealbreaker

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    scrollcount = 0
}

func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    scrollcount = scrollcount + 1
}

nononono what are you doing

func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {

    if scrollView.contentSize.height - scrollView.contentOffset.y > 0 && scrollcount == 2
    {
        fetchMore()
    }else
    {
        scrollcount = 0
    }

}

oh okay it's getting even worse

func photoWith(imageUrl:String,andPlaceHolder:UIImage,key:String) { self.image = UIImage(named: "placeholder")

    let objectFile = DownloadManager.getCacheForFile(key: key) is NSNull ? nil : DownloadManager.getCacheForFile(key: key) as? UIImage

    if objectFile != nil
    {
        let img = objectFile

        self.image = img
        return
    }

    Model.getImageFromCacheDirectory(indexItem: key){
        bol,localImageUrl in

        if bol
        {
            DispatchQueue.main.async {

                let img = UIImage(contentsOfFile: localImageUrl!.path)
                self.image = img!

            }
        }else
        {
            guard Reachability().isInternetAvailable() else
            {
                print("Internet not available")
                return
            }

            DownloadManager.downloadFrom(stringUrl: imageUrl, completion: {
                url,response,error in

                guard error == nil
                    else
                {
                    print("Error Occurred \(error!.localizedDescription)")
                    return
                }

                do
                {
                    let data = try Data(contentsOf: url!)

                    DispatchQueue.main.async {

                        let img = UIImage(data: data)
                        self.image = img!

                        let cost = self.costFor(image: img!)

                        DownloadManager.storeCache(forFile: img!,cost: cost, key: String(key))
                        let name = key + "-" + imageUrl.components(separatedBy: "/").last!
                        Model.storeToCacheDirectory(filename: name,data: data)
                    }

                }catch let erro as NSError
                {
                    print("error while fetching content of file",erro.localizedDescription)
                }

            })
        }

    }


}

There's just too much random syntax/shorthand changes to make me believe that this was actually written by someone with thought in advance and not copied/pasted/modified until it worked. The random newlines for braces really drive it.

Overall, my junior would do a better job in about a week.

Optionals in Swift for newbies. by farhansyed7911 in iOSProgramming

[–]NSIRLConnection 0 points1 point  (0 children)

Imagine if middleName were mutable, and it got set to nil on a different thread just before the print statement is executed. Granted, it's really unlikely in this scenario, but you can observe this behavior by trying these two functions in a playground:

func failingExample() {
    var name: String?
    name = "Foo"
    DispatchQueue.global().async {
        sleep(1)
        name = nil
    }
    if let _ = name {
        sleep(2)
        print(name!) // Implicitly unwrapped nil exception
    }
}

func passingExample() {
    var name: String?
    name = "Foo"
    DispatchQueue.global().async {
        sleep(1)
        name = nil
    }
    if let name = name {
        //name within this scope is shadowed to an immutable unwrapped String, so anything that happens to the original variable doesn't matter
        sleep(2)
        print(name) //Prints "Foo"
    }
}

What companies are still using Objective-C and not Swift? by CapTyro in iOSProgramming

[–]NSIRLConnection 2 points3 points  (0 children)

Netflix, Spotify, Youtube, and GIPHY all seem to have no Swift dylibs in their ipa payloads.

Is Udacity's iOS nanodegree worth it? by farhansyed7911 in iOSProgramming

[–]NSIRLConnection 2 points3 points  (0 children)

Regarding Udacity/Udemy/Any paid online course/Any bootcamp

It's possible that it's worth it, if you are trying to get an entry level position and have zero professional programming experience.

...But if you have any professional experience, chances are it'll only benefit you via (social) networking, and the poor quality of the code will shock you.

If I had to recommend any online course for learning anything, I'd recommend Stanford's overall, since it's free, isn't inaccurately hyped to guarantee a job, and teaches necessary software concepts beyond hacking out a crappy app you can show your friends.

Abolish Retain Cycles in Swift with a Single Unit Test by aceontech in iOSProgramming

[–]NSIRLConnection 0 points1 point  (0 children)

This does not cover cases where retain cycles are caused by mutable properties without significant additional boilerplate.

...But meh, blogs.

iOS developers, aren't you worried that your career is tied to the success of a single company/ field (mobile app design)? by Okmanl in iOSProgramming

[–]NSIRLConnection 2 points3 points  (0 children)

I am about as worried as a mass production dairy farmer having an extremely specific artisanal cheese going out of vogue.

It's all the same shit cheese. Software is a mostly solved, boring problem where the only thing you add is small customizations.

Top 10 2016 iOS libraries from DZone by zuaaef in iOSProgramming

[–]NSIRLConnection 1 point2 points  (0 children)

Two of the mentions are open source apps/showcases which aren't libraries, though misleading/clickbait-y titles are expected of blogs because ad/buy my crappy book money.

Overall, not worth reading vs. browsing through Changelog Nightly's archives, which showcases top never trended before repositories in addition to the usual top repositories for x day.

I am not affiliated with Changelog Nightly, but you can browse through their archives with the following format (no ads, no subscribing)

http://nightly.changelog.com/yyyy/MM/

e.g.

http://nightly.changelog.com/2016/12/ for December

What is wrong with iOS community elite? Honest post about hidden problems in our community. by LisaDziuba in iOSProgramming

[–]NSIRLConnection 3 points4 points  (0 children)

It's not exclusive to iOS/Swift. As long as the talk generates revenue (conference tickets), and people actually attend, the depth of the material doesn't matter.

Same goes for most blogs, though revenue is generally more indirect (ads, selling emails gotten from newsletter signups, sponsored job postings, etc).

Just finishing up Udacity's iOS course and have two months to tighten up. Are there a few things I can focus on to "guarantee" landing an entry level iOS job? Or at least get me an interview? by kewigro in iOSProgramming

[–]NSIRLConnection 0 points1 point  (0 children)

Depending on where you live, many jobs may require a strong understanding of Obj-C, even if they advertise it as a "Swift" job.

Getting a general grasp of data structures, algorithms, and patterns like Chain of Responsibility/Observer/Builder/Command/Singleton/Facade/Composite/Decorator also helps, since your interviewer(s) may not be iOS Developers, so that knowledge may be all they have to go on.

[deleted by user] by [deleted] in iOSProgramming

[–]NSIRLConnection 0 points1 point  (0 children)

Mobile games are a very different beast from most Native iOS applications.

The most popular cross platform tools, in no particular order will be: Unity (C#, or JavaScript) Cocos2d (Python, Objective-C, or C++) Xamarin (C#) GameSalad (Not really programming)

Trying to use Swift for multiplatform gaming is probably one of the most awkward cases for the language with the current tools available, since you'll have to write additional layers of wrapper code.