Init GitHub.com
取消Clone after init
Create
Init Local Only
Create
侧边栏Remote添加Url
Name:origin
Pull URL:https://github.com/Mygit/Myproject.git
Add Remote
Init GitHub.com
取消Clone after init
Create
Init Local Only
Create
侧边栏Remote添加Url
Name:origin
Pull URL:https://github.com/Mygit/Myproject.git
Add Remote
pod ‘MagicalRecord’安装MagicalRecord
/*************************以下为教程****************************/
AppDelegate.swift
import MagicalRecord
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. MagicalRecord.setupCoreDataStack()//只加这句话初始化 return true }
ViewController.swift
import MagicalRecord
override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. /*创建*/ let admin = Admin.MR_createEntity()//创建 admin?.token = "1234"//编辑 print("创建") NSManagedObjectContext.MR_defaultContext().MR_saveToPersistentStoreAndWait()//保存 /*创建结束*/ /*查询*/ let admins = Admin.MR_findAll()//查询 for a in admins as! [Admin]{ print(a.token) a.token = "liuman"//编辑 //a.MR_deleteEntity()//删除 } print("条件查询token值为liuman的") let liuman = Admin.MR_findFirstByAttribute("token", withValue: "liuman") print(liuman!.token) /*查询结束*/ //Admin.MR_truncateAll()//删除所有 NSManagedObjectContext.MR_defaultContext().MR_saveToPersistentStoreAndWait()//创建编辑删除之后都要保存,原save方法,被取代了。 //MagicalRecord.cleanUp()//app退出前操作,关闭coredata }
/etc/apache2/httpd.conf
去掉注释
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
Include /private/etc/apache2/extra/httpd-vhosts.conf
User _www 改 User liuman
/private/etc/apache2/extra/httpd-vhosts.conf文件添加多网站
Listen 8001 <VirtualHost *:8001> DocumentRoot "/Users/liuman/phpinfo" <Directory "/Users/liuman/phpinfo"> Options FollowSymLinks Multiviews MultiviewsMatch Any AllowOverride All Require all granted </Directory> </VirtualHost> Listen 8002 <VirtualHost *:8002> DocumentRoot "/Users/liuman/jlcloud2" <Directory "/Users/liuman/jlcloud2"> Options FollowSymLinks Multiviews MultiviewsMatch Any AllowOverride All Require all granted </Directory> </VirtualHost> Listen 8003 <VirtualHost *:8003> DocumentRoot "/Users/liuman/web" <Directory "/Users/liuman/web"> Options FollowSymLinks Multiviews MultiviewsMatch Any AllowOverride All Require all granted </Directory> </VirtualHost> Listen 8004 <VirtualHost *:8004> DocumentRoot "/Users/liuman/backend-jquery" <Directory "/Users/liuman/backend-jquery"> Options FollowSymLinks Multiviews MultiviewsMatch Any AllowOverride All Require all granted </Directory> </VirtualHost> Listen 8005 <VirtualHost *:8005> DocumentRoot "/Users/liuman/laravel5" <Directory "/Users/liuman/laravel5"> Options FollowSymLinks Multiviews MultiviewsMatch Any AllowOverride All Require all granted </Directory> </VirtualHost>
Listen 8007 <VirtualHost *:8007> DocumentRoot "/Users/liuman/wordpress" <Directory "/Users/liuman/wordpress"> Options FollowSymLinks Multiviews MultiviewsMatch Any AllowOverride All Require all granted </Directory> </VirtualHost>
import CoreData //添加数据 func saveCoreDate(){ //加载AppDelegate let app = UIApplication.sharedApplication().delegate as! AppDelegate //获取管理的上下文 let context = app.managedObjectContext var error:NSError? //创建一个实例并给属性赋值 let admin = NSEntityDescription.insertNewObjectForEntityForName("Admin", inManagedObjectContext: context) as! Admin admin.token = "1" //保存数据 do { try context.save() print("success!") }catch let error{ print("context can't save!, Error:\(error)") } } func fetchCoreData (){ //加载AppDelegate let app = UIApplication.sharedApplication().delegate as! AppDelegate //获取管理的上下文 let context = app.managedObjectContext // 声明数据请求实体 let fetchRequest = NSFetchRequest(entityName: "Admin") let predicate = NSPredicate(format:"token='1'") //fetchRequest.predicate=predicate//设置查询条件按照id查找不设置查询条件,则默认全部查找 //执行查询操作 do { let list = try context.executeFetchRequest(fetchRequest) as! [NSManagedObject] print("打印查询结果") for i in list as! [Admin] { print(i) //修改操作:将查询到的结果修改后,再调用context.save()保存即可 i.token = "1" //删除操作:将查询到的额结果删除后,再调用context.save()保存即可 context.deleteObject(i) } }catch let error{ print("context can't fetch!, Error:\(error)") } do { try context.save() print("success!") }catch let error{ print("context can't save!, Error:\(error)") } }
Mac基本快捷键
space:预览
command+w:关闭
command+q:退出
command+z:撤销
command+shift+z:重做
command+x:剪切
command+c:复制
command+v:粘贴
command+a:全选
command+r:刷新
command+s:保存
command+f:查找
command+space:切换输入法
command+tab:程序切换
command+~:同程序窗口切换
command++:放大
command+—:缩小
command+h:隐藏当前窗口
command+alt+f:隐藏除当前窗口外其他窗口
command+delete:删除
command+shift+delete:清空废纸篓
fn+command+delete:删除后面
command+方向键:光标跳到文本行的首位和文件的首位
command+F3:显示桌面
command+n:打开新窗口
command+m:最小化窗口
command+o:打开文件
command+ctrl+f:全屏
command+shift+3:截取全屏(+alt保存到剪切版)
command+shift+4:截取部分屏幕(按住space空格键选取窗口+alt保存到剪切版)
command+alt+esc:强制退出程序
按住command可以多选文件
开机alt选择启动驱动
control+shift+电源:关闭显示器
command+alt+电源:睡眠
command+control+电源:重启
sudo open . 打开当前文件夹
触控板快捷方式-系统偏好设置-触控板有演示(滚动方向-自然不勾选)
curl -L get.rvm.io | bash -s stable source ~/.bashrc source ~/.bash_profile #查看当前ruby版本 ruby -v ruby 1.8.7 #列出已知的ruby版本 rvm list known #安装ruby 2.3.0 rvm install 2.3.0 #Error running 'requirements_osx_brew_update_system ruby-2.3.0',showing last 15 lines of /Users/liuman/.rvm/log/1471250320_ruby-2.3.0/update_system.log rvm autolibs read-only # read more here:https://rvm.io/rvm/autolibs rvm install ruby
时间差
NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!.components(NSCalendarUnit.NSYearCalendarUnit, fromDate: date.date, toDate: NSDate(), options: NSCalendarOptions(rawValue: 0)).year//与今年相差年数
iOS9 隐藏状态栏方法
1.在Info.plist中增加 Status bar is initially hidden一行,选择为 YES,
2.还需增加 View controller-based status bar appearance 一行,选择为 NO。
这个方法支持iOS7及以后的系统,iOS9以后,通过[UIApplication sharedApplication] 取得app的单例,然后调用setStatusBarHidden方法隐藏 Status Bar的方法作废!
swift隐藏键盘
view.endEditing(true)
textfield.resignFirstResponder()
下一项
func textFieldShouldReturn(textField: UITextField) -> Bool { if textfield.isFirstResponder() { textfield1.becomeFirstResponder() } else if textfield1.isFirstResponder() { textfield.becomeFirstResponder() } else { view.endEditing(true) } return true }
App Transport Security
在Info.plist中添加NSAppTransportSecurity类型Dictionary。
在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES
html
<input type="text" ng-model="person.name"/> <div ng-controller="FirstCtrl"> {{person.name}} <button ng-click="setName()">set name to jack</button> </div> <div ng-controller="SecondCtrl"> {{person.name}} <button ng-click="setName()">set name to jack</button> </div> </div>
js
var myApp = angular.module("myApp", []); myApp.factory('Data', function() { return { name: "Ting" } }); myApp.controller('FirstCtrl', function($scope, Data) { $scope.data = Data; $scope.setName = function() { Data.name = "Jack"; } }); myApp.controller('SecondCtrl', function($scope, Data) { $scope.data = Data; $scope.setName = function() { Data.name = "Moby"; } });
方案一
html
<label ng-repeat="fruitName in fruits"> <input type="checkbox" name="selectedFruits[]" value="{{fruitName}}" ng-checked="selection.indexOf(fruitName) > -1" ng-click="toggleSelection(fruitName)" > {{fruitName}} </label>
js
app.controller('SimpleArrayCtrl', ['$scope', function SimpleArrayCtrl($scope) { // fruits $scope.fruits = ['apple', 'orange', 'pear', 'naartjie']; // selected fruits $scope.selection = ['apple', 'pear']; // toggle selection for a given fruit by name $scope.toggleSelection = function toggleSelection(fruitName) { var idx = $scope.selection.indexOf(fruitName); // is currently selected if (idx > -1) { $scope.selection.splice(idx, 1); } // is newly selected else { $scope.selection.push(fruitName); } }; }]);
方案二
html
<label ng-repeat="fruit in fruits"> <!-- - use `value="{{fruit.name}}"` to give the input a real value, in case the form gets submitted traditionally - use `ng-checked="fruit.selected"` to have the checkbox checked based on some angular expression (no two-way-data-binding) - use `ng-model="fruit.selected"` to utilize two-way-data-binding. Note that `.selected` is arbitrary. The property name could be anything and will be created on the object if not present. --> <input type="checkbox" name="selectedFruits[]" value="{{fruit.name}}" ng-model="fruit.selected" > {{fruit.name}} </label>
js
app.controller('ObjectArrayCtrl', ['$scope', 'filterFilter', function ObjectArrayCtrl($scope, filterFilter) { // fruits $scope.fruits = [ { name: 'apple', selected: true }, { name: 'orange', selected: false }, { name: 'pear', selected: true }, { name: 'naartjie', selected: false } ]; // selected fruits $scope.selection = []; // helper method to get selected fruits $scope.selectedFruits = function selectedFruits() { return filterFilter($scope.fruits, { selected: true }); }; // watch fruits for changes $scope.$watch('fruits|filter:{selected:true}', function (nv) { $scope.selection = nv.map(function (fruit) { return fruit.name; }); }, true); }]);