Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘
I said yeah.

Sofia Swidarowicz phynet

🤘
I said yeah.
View GitHub Profile
View gist:10732884
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellName = @"CellViewName";
CellChatEditNameGroup *aCellName = [tableView dequeueReusableCellWithIdentifier:cellName];
if (aCellName == nil) {
NSArray *views = [[NSBundle mainBundle] loadNibNamed:cellName owner:nil options:nil];
aCellName = (CellViewName *)[views objectAtIndex:0];
}
View designer.html
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../yt-video/yt-search-video.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
View gist:57b3c6548dd8948423f9

##Extension A Swift extension is similar to an Objective-C category. Extensions expand the behavior of existing classes, structures, and enumerations, including those defined in Objective-C.

extension Double {
   var km: Double { return self * 1_000.0 }
   var m: Double { return self }
   var cm: Double { return self / 100.0 }
   var mm: Double { return self / 1_000.0 }
   var ft: Double { return self / 3.28084 }
}
View Translate removeObjectAtIndex from NSMutableArray into Array in Swift.mkd

##Translate removeObjectAtIndex from NSMutableArray into Array in Swift

If you were wondering how in hearth you could removeObject from an Array declared in Swift... I was in your same predicament. Thankfully there are people out there that came first, and found a solution. I'm goin to translate it here for you all and of course, for me...

###Objective-C code:

[self.selectedRows removeObject:[NSNumber numberWithLong:indexPath.row]];
View Recursivity in Swift 2.mkd

Taken from Stackoverflow

func f(n: Int) {
  func lap(n: Int) -> Int {
    if n == 0 { return 0 }
    print(n)
    return lap(n - 1)
  }
  lap(n)
}
View Obtaining-characters-from-a-String-in-SWIFT.mkd

Previous Swift 2.0, the option .character for String's type, was obtained using advance and startIndex (pretty much a pain in the butt, so make it an extension and you could have the characters :P )

var kString = "My string"
var countString = count(kString)

for i in 0...countString - 1 {
  let index = advance(kString.startIndex, i)
  print("INSIDE FOR \(kString[index])")
  self.labelAmount.text?.append(kString[index])
@phynet
phynet / observer_updateData.m
Created Sep 14, 2015
Using NSNotification to update data
View observer_updateData.m
__typeof__(self) __weak wself = self;
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
[wself updateData];
}];
View NSOrderedSet.swift
let orderedSet = NSOrderedSet(array: [ 42, 43, 44])
var enumarator = orderedSet.reversedOrderedSet
print(enumarator)
for elem in orderedSet {
print("elements \(elem)")
}
@phynet
phynet / parse.js
Created Nov 11, 2015
To know which column/property has been changed in beforeSave in PARSE
View parse.js
for (var i in userPoints.dirtyKeys()) {
var dirtyKey = userPoints.dirtyKeys()[i];
alert("DIRTY KEY val " + dirtyKey);
}
@phynet
phynet / DictionaryToArray.js
Created Dec 11, 2015
Create an array with dictionary values in JAVASCRIPT
View DictionaryToArray.js
var array = [];
for (key in dictPush){
temp = {};
temp[key] = dictPush[key];
array.push(temp);
}
You can’t perform that action at this time.