Something about Swift 3
Well, this is how I felt when I was listening ‘Happy’, em~ a masterpiece, don’t u think so~
![](https://archive.writeitdown.site/2014-11-10 231742.jpg)
JUST KIDDING, Keep on Swift
Declare a swift dictionary
var object = ["name":"Light","model":"az001"]
Initializer of struct
Pretty simple
init(fromAnyData:NSDictionary){ //assign value here,or customize your properties }
Compare to the old syntax from OC, it’s much easier to init a struct. Swift forced you to assign values for every property, except you declare it as a optional one.
Swift Dictionary vs. NSDictionary
Look at this:
let userCourseDictionary:NSDictionary = NSJSONSerialization.JSONObjectWithData(userCourseData, options: nil, error: nil) as NSDictionary
It seems like we are not using a rewritten new brand Class NSJSONSerialization, but just provided some swift Syntax to access old OC. If not so, we don’t need to Convert it to a NSDictionary. This is a awesome truth for tons of existing 3rd open source Objective-C libs, that means you can use them directly by several steps setting.
Cocoapods + Objective-C+Swift together!!
It amazed me! Can’t believe it was so easy to do!
Setup any cocoapods lib, I take pop for example.
Create a header file, import the libs like you did with OC before.
Include this header file in Build settings –> Swift Compiler –> Objective-C Bridging Header
![](https://archive.writeitdown.site/屏幕快照 2014-11-12 上午11.37.59.png)Use the libs obey Swift syntax, compare these two pieces of code to see differences.
let popAnimation:POPSpringAnimation = POPSpringAnimation(propertyNamed: kPOPLayerPositionY) popAnimation.toValue = 300 actionLabel.layer.pop_addAnimation(popAnimation, forKey: "slideIn")
POPSpringAnimation *popAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY]; popAnimation.toValue = @(300) [self.actionLabel.layer pop_addAnimation:strokeAnimation forKey:@"slideIn"];
Use assistant view to preview layout
Never knew there’s such nice way to preview layout. Thanks to Pasan!
![](https://archive.writeitdown.site/屏幕快照 2014-11-12 上午11.47.07.png)
Resize label after input long text
Shortcut: command =
Some basic subversion command
The leader is too busy to move code from svn to git, and after upgrade to Yosemite, my Versions app would crash after launch. So I need to do it with command.
#create a change list svn cl clTiger Views/WSViewController.h #remove a file from a change list svn cl —remove Views/WSViewController.h #commit a change list svn ci —changelist clTiger -m "Test ChangeList" #update specific files svn up filename1 filename2 #make a branch svn copy fromPath toPath -m "Creating a branch for version 1.0" #revert a file svn revert filename #delete a file svn del filename
Sometimes command lines are more powerful & beautiful.