Skip to content

Instantly share code, notes, and snippets.

View jkatayama's full-sized avatar
😷
Working from home

Jumpei Katayama jkatayama

😷
Working from home
  • Tokyo
View GitHub Profile

iOS sheat-sheet

Get a selected cell's index

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    let path = self.tableView.indexPathForSelectedRow
    segue.destinationViewController.detail = self.detailForIndexPath(path)
}

iOS9 improvement

Disblae ATS(AppTransportSecurity) to allow http

<key>NSAppTransportSecurity</key>
     <dict>
         <key>NSAllowsArbitraryLoads</key><true/>
     </dict>
@jkatayama
jkatayama / which_and_go.sh
Created February 17, 2016 19:48
go to the directory in which your command exists
cd $(dirname "$(which npm)")
@jkatayama
jkatayama / brew_prune_batch.sh
Created February 17, 2016 00:22
Batches broken brew symlinks
while read path
do
if [ -f "$path" ]; then
echo "Pruning $path.."
brew prune “$path”
else
echo "$path not found"
fi
done < "$1"

###swift

$ curl https://raw.githubusercontent.com/github/gitignore/master/Swift.gitignore -o .gitignore

###objective-C

$ curl https://raw.githubusercontent.com/github/gitignore/master/Objective-C.gitignore -o .gitignore

LocationService

  • Add it to info.plist
<key>NSLocationAlwaysUsageDescription</key>
<string>Description</string>

Rename Xcode Project

1.Rename project from Xcode

2.Rename scheme

  • Most sites tell you only two steps avobe, but that's not enough to rename evrything. Since the original project name also exsists in .phxproj file and .xcuserstate file, you cannot modify these files from Xcode.
  • To solve the problem, you can use grep command.

3.Go to your project directory

4.List all lines containing the original project name from the current directory

When you create a tableCell object for each row all you have to do is call dequeueReusableCellWithIdentifier on your tableView object. But this approach is only aviable when you work with storyboar. If you want to use a fully code-based cell class and one from .xib file, you need to register these identifiers to your tableView object.

Your tableViewCell is not on a tableView in storyboard and is initizlied progmatically

self.tableView.registerClass(<YourCellClass.self, forCellReuseIdentifier: "Cell")
{
"categories": [
"Decorative Trays & Bowls",
"Electronics",
"Other Dresses",
"Pants",
"Musical Instruments",
"Shirts",
"Tabletop",
"Other Lighting",