Giter Club home page Giter Club logo

nicethings's Introduction

NiceThings

Build Status

A collection of extensions and methods to make Swift and iOS even better

Inspired by Soroush Khanlou's talk, You Deserve Nice Things, at #Pragma Conference 2017.

Load a view from a nib

To load a view from a nib, don't use this:

let view = Bundle.main.loadNibNamed("YourView", owner: self, options: nil)?.first as? YourView

Instead, use this:

let view = YourView().loadNib()

Just grab UIView+loadNib.swift to make loading nibs super easy.

Thanks to Matt Lorentz for contributing this!

Dequeue table view cells

To dequeue a table view cell, don't use this:

dequeueReusableCell(withIdentifier identifier: String)

Instead, use this:

dequeueReusableCell(withIdentifier identifier: String, for indexPath: IndexPath)

Why? Look closely at the documentation for each, and check out the Return Value. On the second, it says:

A UITableViewCell object with the associated reuse identifier. This method always returns a valid cell.

This is nicer than checking for nil and instantiating a new cell.

nicethings's People

Contributors

joshuatbrown avatar mplorentz avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.