Snippets

Fabian Hernando Leon Ortega Swift - Common Tasks

Updated by Fabian Leon

File Swift-Language Modified

  • Ignore whitespace
  • Hide word diff
 let bundle = NSBundle(path: path!)
 let string = bundle?.localizedStringForKey("key", value: nil, table: nil)
 
-// print device token of push notification
+// print device token for push notifications
 
  let characterSet: NSCharacterSet = NSCharacterSet( charactersInString: "<>" )
  
Updated by Fabian Leon

File Swift-Language Modified

  • Ignore whitespace
  • Hide word diff
+// Change language application dinamically
+
 var language = "de"
 let path = NSBundle.mainBundle().pathForResource(language, ofType: "lproj")
 let bundle = NSBundle(path: path!)
-let string = bundle?.localizedStringForKey("key", value: nil, table: nil)
+let string = bundle?.localizedStringForKey("key", value: nil, table: nil)
+
+// print device token of push notification
+
+ let characterSet: NSCharacterSet = NSCharacterSet( charactersInString: "<>" )
+ 
+ let deviceTokenString: String = ( deviceToken.description as NSString )
+            .stringByTrimmingCharactersInSet( characterSet )
+            .stringByReplacingOccurrencesOfString( " ", withString: "" ) as String
+        
+ print("Device token: \(deviceTokenString)" )
Updated by Fabian Leon

File Swift-Language Added

  • Ignore whitespace
  • Hide word diff
+var language = "de"
+let path = NSBundle.mainBundle().pathForResource(language, ofType: "lproj")
+let bundle = NSBundle(path: path!)
+let string = bundle?.localizedStringForKey("key", value: nil, table: nil)

File snippet.txt Deleted

  • Ignore whitespace
  • Hide word diff
-var language = "de"
-let path = NSBundle.mainBundle().pathForResource(language, ofType: "lproj")
-let bundle = NSBundle(path: path!)
-let string = bundle?.localizedStringForKey("key", value: nil, table: nil)
Created by Fabian Leon

File snippet.txt Added

  • Ignore whitespace
  • Hide word diff
+var language = "de"
+let path = NSBundle.mainBundle().pathForResource(language, ofType: "lproj")
+let bundle = NSBundle(path: path!)
+let string = bundle?.localizedStringForKey("key", value: nil, table: nil)
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.