大部分人缺乏一種主動發(fā)掘信息的意識。讀著別人寫好的文字,思考著別人提出的問題,做著別人交代的事情。
https://bitbucket.org/dcutting/verijson
nsurlsession管理并發(fā)請求數(shù)目:
首先,嘗試方法:設(shè)置NSURLSessionConfiguration對HTTPMaximumConnectionsPerHost屬性,發(fā)現(xiàn)問題:如果我入隊列5個任務(wù),前三個在完成了,后兩個任務(wù)會超時對待。新的方法:設(shè)置nsurlsession的delegateQueue的最大并發(fā)數(shù),發(fā)現(xiàn)無效, 無效2,所以又去尋找新的方法 方法是使用nsoperartion包裝nsurlsession,雖然nsurlsession有自己的隊列,但是你不能對他的并發(fā)數(shù)做更改,改了也會被忽略。
最后,使用nsoperation包裝nsurlsession的,見代碼
property.
- (id)initWithNibName:(NSString *bundle:(NSBundle *)nibBundleOrNil
- (id)initWithCoder:(NSCoder *)aDecoder
- (void)awakeFromNib {
執(zhí)行順序:1, 2, 3
- (void)awakeFromNib {
uiviewcontroller擁有以上三個方法,uiview沒有第一個方法
- 當從storyboard中加載vc時,initwithcode和awakfromnib被調(diào)用,如果從代碼創(chuàng)建vc, 只有initwithnibname:bundle被調(diào)用
- 當從storyboard中加載v時,initwithcode和awakfromnib被調(diào)用,如果從代碼創(chuàng)建v,initwithframe被調(diào)用
- 當從storyboard中加載vc或v的時候,initwithcoder方法中,iboutlet連接的屬性是nil,awakfromnib中的屬性才是有值,
小技巧
linux command
xdg-open . # 在file manager中打開當前路徑
Linux command
- http://www.grymoire.com/Unix/sed.html
-
https://www.digitalocean.com/community/tutorials/how-to-use-ps-kill-and-nice-to-manage-processes-in-linux
-黑色pdf, done - 命令行藝術(shù),done
// MLAMUtils, CocoaLumberjack, MagicalRecord, SDWebImage, SVPullToRefresh, SVProgressHUD, TTTAttributedLabel,
// KeyboardAvoiding, FXKeychain, JSONValidation, TQStarRatingView, MLAMModel,RNCryptor
Target_Name="RNCryptor"
# 在build/Release-iphoneos/${Target_Name}.framework下創(chuàng)建真機framework
xcodebuild -configuration Release -target "${Target_Name}" -sdk iphoneos clean build
# 在build/Release-iphonesimulator/${Target_Name}.framework下創(chuàng)建模擬器framework
xcodebuild -configuration Release -target "${Target_Name}" -sdk iphonesimulator clean build
Device_Dir=build/Release-iphoneos/${Target_Name}.framework
Simulator_Dir=build/Release-iphonesimulator/${Target_Name}.framework
Device_Simulator_Dir=../MLAppMaker/Framework/${Target_Name}.framework
# 將真機的framework里的內(nèi)容全部復(fù)制到合并的framework文件夾內(nèi),主要是一些頭文件,真機的編譯的代碼最終會被真機與模擬器合并后的代碼覆蓋
cp -R "${Device_Dir}/" "${Device_Simulator_Dir}"
# 合并模擬器和真機的代碼
lipo -create "${Device_Dir}/${Target_Name}" "${Simulator_Dir}/${Target_Name}" -output "${Device_Simulator_Dir}/${Target_Name}"
# 移除build目錄
#rm -r build
open $Device_Simulator_Dir/..
Mach-o static-library
arm7s
http://www.cocoachina.com/ios/20150906/13323.html
http://stackoverflow.com/questions/26024100/dyld-library-not-loaded-rpath-libswiftcore-dylib
navigationcontroller執(zhí)行push或pop的時候執(zhí)行navigationcontroller的代理方法:
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC {
提供一個實現(xiàn)了UIViewControllerAnimatedTransitioning協(xié)議的轉(zhuǎn)場對象動畫子,動畫子實現(xiàn)了協(xié)議中的方法:
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext;
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext;
在方法中有一個UIViewControllerContextTransitioning的參數(shù),參數(shù)對象可以獲取轉(zhuǎn)場的畫布,源控制器,目的控制器。
在交互驅(qū)動轉(zhuǎn)場回退過程中,同樣執(zhí)行navigationcontroller的代理方法:
- (id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController NS_AVAILABLE_IOS(7_0);
方法需要返回一個實現(xiàn)了UIViewControllerInteractiveTransitioning協(xié)議的對象,通常這個對象是UIPercentDrivenInteractiveTransition對象
以上是navigationcontroller的轉(zhuǎn)場,下面是模態(tài)的轉(zhuǎn)場。
模態(tài)轉(zhuǎn)場從A控制器到B控制器
a.transitioningDelegate = self;
a.modalPresentationStyle = UIModalPresentationCustom;
a.modalPresentationCapturesStatusBarAppearance = YES
transitioningdelegate表示協(xié)議UIViewControllerTransitioningDelegate,協(xié)議需要實現(xiàn)4個方法:
表示present和dismiss轉(zhuǎn)場
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source;
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed;
表示交互驅(qū)動轉(zhuǎn)場
- (id <UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id <UIViewControllerAnimatedTransitioning>)animator;
- (id <UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id <UIViewControllerAnimatedTransitioning>)animator;
自定義模態(tài)的一個案例:
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
{
UIView *fromView = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey].view;
fromView.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
fromView.userInteractionEnabled = NO;
UIView *dimmingView = [[UIView alloc] initWithFrame:fromView.bounds];
dimmingView.backgroundColor = [UIColor customGrayColor];
dimmingView.layer.opacity = 0.0;
UIView *toView = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey].view;
toView.frame = CGRectMake(0,
0,
CGRectGetWidth(transitionContext.containerView.bounds) - 104.f,
CGRectGetHeight(transitionContext.containerView.bounds) - 288.f);
toView.center = CGPointMake(transitionContext.containerView.center.x, -transitionContext.containerView.center.y);
[transitionContext.containerView addSubview:dimmingView];
[transitionContext.containerView addSubview:toView];
POPSpringAnimation *positionAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
positionAnimation.toValue = @(transitionContext.containerView.center.y);
positionAnimation.springBounciness = 10;
[positionAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
[transitionContext completeTransition:YES];
}];
POPSpringAnimation *scaleAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
scaleAnimation.springBounciness = 20;
scaleAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(1.2, 1.4)];
POPBasicAnimation *opacityAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerOpacity];
opacityAnimation.toValue = @(0.2);
[toView.layer pop_addAnimation:positionAnimation forKey:@"positionAnimation"];
[toView.layer pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
[dimmingView.layer pop_addAnimation:opacityAnimation forKey:@"opacityAnimation"];
}
自定義UIStoryboardSegue子類覆蓋perform方法,關(guān)聯(lián)wind和unwind動作
override func perform() {
// Assign the source and destination views to local variables.
var firstVCView = self.sourceViewController.view as UIView!
var secondVCView = self.destinationViewController.view as UIView!
// Get the screen width and height.
let screenWidth = UIScreen.mainScreen().bounds.size.width
let screenHeight = UIScreen.mainScreen().bounds.size.height
// Specify the initial position of the destination view.
secondVCView.frame = CGRectMake(0.0, screenHeight, screenWidth, screenHeight)
// Access the app's key window and insert the destination view above the current (source) one.
let window = UIApplication.sharedApplication().keyWindow
window?.insertSubview(secondVCView, aboveSubview: firstVCView)
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.destinationViewController as UIViewController,
animated: false,
completion: nil)
}
}
override func perform() {
// Assign the source and destination views to local variables.
var secondVCView = self.sourceViewController.view as UIView!
var firstVCView = self.destinationViewController.view as UIView!
let screenHeight = UIScreen.mainScreen().bounds.size.height
let window = UIApplication.sharedApplication().keyWindow
window?.insertSubview(firstVCView, aboveSubview: secondVCView)
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, screenHeight)
}) { (Finished) -> Void in
self.sourceViewController.dismissViewControllerAnimated(false, completion: nil)
}
}
第二種實現(xiàn)自定義segue的做法是自定義一個navigationcontroller,覆蓋如下方法:
- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier {
return [UIStoryboardSegue segueWithIdentifier:identifier source:fromViewController destination:toViewController performHandler:^{
UIView *fromView = fromViewController.view;
UIView *toView = toViewController.view;
UIView *containerView = fromView.superview;
NSTimeInterval duration = 1.0;
CGRect initialFrame = fromView.frame;
CGRect offscreenRect = initialFrame;
offscreenRect.origin.x -= CGRectGetWidth(initialFrame);
toView.frame = offscreenRect;
[containerView addSubview:toView];
// Animate the view onscreen
[UIView animateWithDuration:duration
delay:0
usingSpringWithDamping:0.5
initialSpringVelocity:4.0
options:0
animations: ^{
toView.frame = initialFrame;
} completion: ^(BOOL finished) {
[toView removeFromSuperview];
[toViewController.navigationController popToViewController:toViewController animated:NO];
}];
}];
}
獲取unwind的數(shù)據(jù),通過在源控制器中加入一個自定義的方法,記住方法的返回值需要是IBAction,參數(shù)必須是UIStoryboardSegue類型
@implementation OneViewController
-(IBAction)prepareForUnwind:(UIStoryboardSegue *)segue {
if ([segue.identifier isEqualToString:@"unwindToViewController1"]) {
ThreeViewController *threeVC = (ThreeViewController *)segue.sourceViewController;
NSLog(@"Violets are %@", threeVC.violetsAreColor);
}
}
@end
emacs
GCD
Autolayout
https://github.com/smileyborg/UIView-AutoLayout/wiki/Tips-and-Tricks
http://nshint.io/blog/2015/08/17/autolayout-breakpoints/
UIAnimation
http://nshint.io/blog/2015/06/23/toggle-slow-animations/
疑難雜癥
- http://blog.sina.com.cn/s/blog_65c178a80102v0f4.html
- http://stackoverflow.com/questions/19054625/changing-back-button-in-ios-7-disables-swipe-to-navigate-back
UIViewController
- http://stackoverflow.com/questions/12412240/ios-bounds-change-after-rotating-to-landscape-then-back-to-portrait
- http://stackoverflow.com/questions/9539676/uiviewcontroller-returns-invalid-frame
- http://stackoverflow.com/questions/13739902/ios-change-auto-layout-constraints-when-device-rotates
git
- 禁用push --force
- http://stackoverflow.com/questions/5094524/github-prevent-collaborators-from-using-push-f/5094762#5094762
- https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
- https://git-scm.com/book/zh/v1
kSecAttrSynchronizable使用:
- http://stackoverflow.com/questions/24294993/keychain-data-not-storing-in-icloud
- https://github.com/granoff/Lockbox/issues/33
- http://www.cocoachina.com/bbs/read.php?tid=86249&keyword=icloud
- http://www.raywenderlich.com/6015/beginning-icloud-in-ios-5-tutorial-part-1
- http://www.raywenderlich.com/12779/icloud-and-uidocument-beyond-the-basics-part-1
- http://www.raywenderlich.com/83116/beginning-cloudkit-tutorial
- http://www.raywenderlich.com/6031/beginning-icloud-in-ios-5-tutorial-part-2
- http://code.tutsplus.com/tutorials/working-with-icloud-key-value-storage--pre-37542
javascript core:
- http://nshipster.com/javascriptcore/
- https://www.bignerdranch.com/blog/javascriptcore-and-ios-7/
- https://www.bignerdranch.com/blog/javascriptcore-example/
- http://stackoverflow.com/questions/18920536/why-use-javascriptcore-in-ios7-if-it-cant-access-a-uiwebviews-runtime
- https://medium.com/@dalmaer/javascript-and-ios-7-a28d741eb2f9
NSURLSession:
IAP Auto-renewable Subscriptions:
對于可續(xù)訂的內(nèi)購商品,如果用戶購買了一個一年的商品,該商品含有一個月的試用期限,那么當用戶購買后,會產(chǎn)生一條發(fā)票記錄,如下:
{
"expires_date" = "2015-08-04 09:08:48 Etc/GMT";
"expires_date_ms" = 1438679328000;
"expires_date_pst" = "2015-08-04 02:08:48 America/Los_Angeles";
"is_trial_period" = false;
"original_purchase_date" = "2015-08-04 09:03:48 Etc/GMT";
"original_purchase_date_ms" = 1438679028000;
"original_purchase_date_pst" = "2015-08-04 02:03:48 America/Los_Angeles";
"original_transaction_id" = 1000000166210549;
"product_id" = "com.bsn.mercurypro.yearft";
"purchase_date" = "2015-08-04 09:03:48 Etc/GMT";
"purchase_date_ms" = 1438679028000;
"purchase_date_pst" = "2015-08-04 02:03:48 America/Los_Angeles";
quantity = 1;
"transaction_id" = 1000000166210549;
"web_order_line_item_id" = 1000000030247637;
}
該記錄包含了5分鐘的區(qū)間,也就是對應(yīng)實際時間一個月,如果一個月內(nèi)用戶沒有取消訂閱,那么5分鐘后,會產(chǎn)生一條新的關(guān)于一年訂閱的發(fā)票信息。如果用戶在一個月內(nèi)取消了,則不會繼續(xù)產(chǎn)生一年的發(fā)票信息。
![R7F53}8U]DLE@`%EX97FEGT副本.jpg](http://upload-images.jianshu.io/upload_images/276552-3fc29d06075f7add.jpg?imageMogr2/auto-orient/strip|imageView2/2/w/1240)
- http://www.raywenderlich.com/36270/in-app-purchases-non-renewing-subscription-tutorial
- http://stackoverflow.com/questions/7086612/in-app-purchase-multiple-auto-renewing-subscriptions-having-different-durations
- http://stackoverflow.com/questions/7688197/auto-renewing-subscription-differences-to-non-renewing-subscription
-
https://www.google.com/
-https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/StoreKitGuide.pdf - http://stackoverflow.com/questions/14328374/skpaymenttransaction-what-is-transactiondate-exactly
- (http://savvyapps.com/blog/getting-started-with-auto-renewable-subscriptions-in-ios/)
- http://stackoverflow.com/questions/8739116/ios-getting-expiration-time-of-in-app-subscription-purchases
-
http://gregheo.com/blog/iap-restore
https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Introduction.html
NSNotification
-
http://southpeak.github.io/blog/2015/03/14/nsnotificationyu-duo-xian-cheng/
非技術(shù)文章: - http://www.ruanyifeng.com/blog/2013/10/register.html
- http://36kr.com/p/534432.html
- http://www.thegeekstuff.com/2009/06/expertise-in-google-search/
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 20.0px; font: 13.0px Helvetica; color: #323333}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 20.0px; font: 13.0px Helvetica; color: #323333; min-height: 16.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 20.0px; font: 13.0px 'Heiti SC Light'; color: #323333}span.s1 {font: 13.0px 'Heiti SC Light'}span.s2 {font: 13.0px Helvetica}span.Apple-tab-span {white-space:pre}
一.看coredata視頻 11:30之前
Core Data優(yōu)化調(diào)試建議:
1.只提取10個或者可見區(qū)域內(nèi)需要的對象
2.盡可能不要將所有對象都提取出來
3.使用fetch batch size為20
4.將BLOB數(shù)據(jù)放在一個單獨的實體中
5.使用預(yù)提取 prefetch: [fetchRequest setRelationshipKeyPathsForPrefetching:@[@“subItems”]];
6.單獨為在實體上創(chuàng)建一個緩存縮略圖
7.當本地數(shù)據(jù)和遠程傳回的JSON數(shù)據(jù)進行同步時候,
壞的做法:每次取出JSON字典中的一個元素,查詢本地數(shù)據(jù)是否存在,如果沒有插入,有的話就取出更新。本地數(shù)據(jù)較多時,查詢的時間就非常大。
好的做法:在執(zhí)行動作之前,先將本地數(shù)據(jù)和JSON字典中的元素ID號排序,然后通過ID號按序枚舉,如果本地存在,則更新,無則插入
8.成批的導(dǎo)入數(shù)據(jù),而不是一股腦的全部灌入內(nèi)存
9.將對象轉(zhuǎn)為fault狀態(tài),通過在調(diào)用[context refreshObject:object mergeChanges:YES];將當前不需要的對象移除內(nèi)存。
10.配置提取請求返回字典:[request setResutlType:NSDictionaryResultType];
11.只提取需要的屬性字段,通過調(diào)用[request setPropertiesToFetch:@[@“magnitude”]];
12.使用NSExpression執(zhí)行計算
13.NSPredicate表達式依次升高:Beginswith,EndWith,Equality,Contains,Matches,[cd]會更加耗時。
二.自動布局看完:12點到4點
- 應(yīng)對屏幕不同尺寸和不同方向的變化
- 某些語言的拼寫順序額并不是從左到右,像德語和阿拉伯語
- 根據(jù)內(nèi)容的尺寸控制控件的大小
constraint = [NSLayoutConstraint constraintWithItem:button1 attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0f
constant:-20.0f];
[self.view addConstraint:constraint];
A= B*m + C;
3.設(shè)計模式:晚上
iOS開發(fā)中用過哪些設(shè)計模式:
1.創(chuàng)建類型的:單例和抽象工廠
2.結(jié)構(gòu)化類型的:MVC,裝飾著,適配器,外觀以及組合
3.行為類型:觀察者,備忘錄,責(zé)任鏈和命令
今天回去的兩件事情:設(shè)計模式和autolayout,常用的那些設(shè)計模式,都用在什么場景。自動布局用過嗎?怎么用的?iOS 7中自動布局的變化
cocoachina的版主大大總結(jié)的面試題以及cocoachian中的面試題分享的
iOS引入了那些新功能,列舉8個點:
UIKit 物理引擎
集成javascript到本地app
后臺下載NSURLSession
自定義視圖控制器過渡
新的地圖
新的自動布局
新的單元測試框架
AirDrop
2013 WWDC問題:
http://adcdownload.apple.com//videos/wwdc_2012__hd/session_407__adopting_storyboards_in_your_app.mov
http://adcdownload.apple.com//videos/wwdc_2012__hd/session_214__core_data_best_practices.mov
http://adcdownload.apple.com//videos/wwdc_2012__hd/session_415__debugging_with_lldb.mov
http://adcdownload.apple.com//videos/wwdc_2012__hd/session_211__building_concurrent_user_interfaces_on_ios.mov
void insertSort(int *array, int length) {
for (int i = 1; i < length; i++) {
int j = i;
int temp = array[i];
while (j > 0 && temp < a[j - 1]) {
a[j] = a[j - 1];
j—
}
a[j] = temp;
}
}
看過哪些WWDC視頻:
1.優(yōu)化Core Data
1.高級調(diào)試使用LLDB
po [self view];
p self.subviews.count
expr username= @“username”
expr password = @“password”
2.修復(fù)內(nèi)存問題
- 節(jié)能最佳實踐
4.設(shè)計代碼為性能 designing code for performance
5.最佳實踐core animation
UIButton的層次結(jié)構(gòu):
UIButton—>UIControl—>UIView—>UIResponder—>NSObject
:
靜態(tài)分析器:
- 內(nèi)存泄露
- 僵尸變量
3.未使用的變量
LLDB:http://my.oschina.net/notting/blog/115294
列舉6個常用的Instruments 模板,并說明用處:
Allocations
Leaks
Zoombies
Core Animation
Core Data
Time Profiler
Automation
Time Profiler 時間評測器
反轉(zhuǎn)調(diào)用樹 invert call tree
KVC實現(xiàn)分析:
當我們?yōu)橐粋€類的某個屬性添加observer時候,框架自動創(chuàng)建這個類的一個子類,并且修改這個類的isa指向這個新的子類。
由于在ios中函數(shù)調(diào)用都是轉(zhuǎn)化為isa查表形式,所以這次查得時新的子類的表,
也就是說對類的函數(shù)調(diào)用被子類給攔截了,在攔截的實現(xiàn)中就可以通知observer了。
修改類的isa被稱為isa-swizzling技術(shù)。isa-swizzling就是類型混合指針機制。KVC主要通過isa-swizzling,來實現(xiàn)其內(nèi)部查找定位的。
給圖層提供內(nèi)容有三種方法,一種是直接賦值contents,一種是調(diào)用它的代理方法,代理方法有兩個,一個是displayLayer,一個是drawLayer:inContext。如果兩個代理方法都實現(xiàn)了,只會調(diào)用displayLayer方法。
圖層的繪圖方法:
? 如果你的代理實現(xiàn)了displayLayer:方法,實現(xiàn)方法負責(zé)創(chuàng)建位圖并賦值給contents屬性。
? 如果你的代理實現(xiàn)的是drawLayer:inContext:方法,Core Animation創(chuàng)建一個位圖,創(chuàng)建一個用于繪制位圖的上下文,并調(diào)用代理方法填充該位圖。你的代理方法所要做的是將內(nèi)容畫在圖形上下文上。
代理對象必須實現(xiàn)displayLayer:或者drawLayer:inContext方法之一。如果代理對象把這兩個方法都實現(xiàn)了,圖層只調(diào)用displayLayer:方法。
UIGraphicsBeginImageContextWithOptions(size,NO,0)
UIGraphicsGetCurrentContext
CGContextSetLineWidth
CGContextSetLineCap
視圖的繪圖方法:在- (void) drawRect: (CGRect) rect方法中,直接調(diào)用UIGraphicsGetCurrentContext,進行繪圖
也可以在任意的一個實例方法中,創(chuàng)建圖片上下文UIGraphicsCreateImageContext
路徑:UIBizerPath:
UIBezierPath* aPath = [UIBezierPath bezierPath];
[aPath moveToPoint:CGPointMake(100.0, 0.0)];
[aPath addQuadCurveToPoint:CGPointMake(120, 100) controlPoint:CGPointMake(70, 0)];
- (UIBezierPath *)bezierPathWithOvalInRect:(CGRect)rect
- (UIBezierPath *)bezierPathWithRect:(CGRect)rect
干凈內(nèi)存:框架,可運行的app,內(nèi)存映射文件
臟內(nèi)存:堆分配,解壓圖片,數(shù)據(jù)庫緩存。
ARC:
__bridge只做類型轉(zhuǎn)換,但是不修改對象(內(nèi)存)管理權(quán);
__bridge_retained(也可以使用CFBridgingRetain)將Objective-C的對象轉(zhuǎn)換為Core Foundation的對象,同時將對象(內(nèi)存)的管理權(quán)交給我們,后續(xù)需要使用CFRelease或者相關(guān)方法來釋放對象;
__bridge_transfer(也可以使用CFBridgingRelease)將Core Foundation的對象轉(zhuǎn)換為Objective-C的對象,同時將對象(內(nèi)存)的管理權(quán)交給ARC。
優(yōu)化建議:http://xiaojiayi.com/blog/2013/03/06/iose680a7e883bde4bc98e58c96efbc88wwdce7ac94e8aeb0efbc89/ 多看幾遍
- 使用arc
2.盡可能設(shè)置不透明opacity為YES
3.不要卡到主線程,CPU密集型操作放在后臺執(zhí)行,模板如下使用GCD:
dispatch_async(dispatch_get_global_queue(0,0), ^{
// connect network get something
dispatch_async(dispatch_get_main_queue(), ^{
// update UI
});
); - 開啟GZIP
- 對于需要變化的內(nèi)容,可以考慮使用代碼繪制。圖片顯示之前使用預(yù)渲染解壓縮圖片。
- 重用耗時的對象,比如NSDateFormattter
- 對設(shè)置陰影的情況,設(shè)置陰影路徑:view.layer.shadowPath = [[UIBezierPath bezierPathWithRect:view.bounds] CGPath];
8.緩存圖片,使用NSURLProtocol或者使用一些第三方的工具類庫 SDWebImage
9.重用耗時創(chuàng)建的對象,比如NSDateFormmtter。
10.在代碼繪制圖片時,不要將圖片上下文設(shè)的過大,1000*1000的圖片上下文會占據(jù)7MB內(nèi)存。
列出幾個instruments,你所使用的經(jīng)歷。
app的五個狀態(tài):未啟動,閑置,活動,后臺,掛起
動態(tài)運行時:
調(diào)用一個沒有實現(xiàn)的方法:首先會調(diào)用:,如果沒有返回YES,則運行時會再發(fā)送一遍動態(tài)方法解析消息。如果返回resolveInstanceMethod也沒有做方法重定向,就會觸發(fā)轉(zhuǎn)發(fā)調(diào)用消息:(void)forwardInvocation:(NSInvocation *)anInvocation;。通常將不能處理的消息轉(zhuǎn)發(fā)給其他對象。
@endcode類型編碼
@interface Lender : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) struct LOCATION location;
@property (nonatomic, retain) NSArray *colors;
@property (nonatomic, assign) NSInteger count;
@property (nonatomic, assign) BOOL success;
@property (nonatomic, assign, getter = isSquare) BOOL square;
@property (nonatomic, assign, readonly) NSTimeInterval time;
@property (nonatomic, strong) KivaFeed *kivaFeed;
@property (nonatomic, weak) NSArray<FirstProtocol, SecondProtocol> *lenders;
T@“NSString”,C,N,V_name
T{LOCATION=ff},N,V_locaiton
T@“NSArray”,&,N,V_colors
This is a good day,N,V_count
Tc,N,V_success
Tc,N,GisSquare,V_square
Td,R,N,V_time
T@“KivaFeed”,&,N,V_kivaFeed
T@“NSArray<FirstProtocol><SecondProtocol>”,W,N,V_lenders
*/
消息轉(zhuǎn)發(fā):
class_addMethod([self class], sel, imp, “v@:”);
objc_getAssociatedObject(self.class, &kMapperObjectKey)
objc_setAssociatedObject(
self.class,
&kMapperObjectKey,
mapper,
OBJC_ASSOCIATION_RETAIN // This is atomic
);
unsigned int propertyCount;
objc_property_t *properties = class_copyPropertyList(class, &propertyCount);
[self method1];
[self method2];
// 獲得方法method,就是用class_getInstantceMeth
Method method1 = class_getInstanceMethod(self.class, @selector(method1));
Method method2 = class_getInstanceMethod(self.class, @selector(method2));
// 獲得方法的實現(xiàn),就是用method_getImplementation
IMP imp1 = method_getImplementation(method1);
IMP imp2 = method_getImplementation(method2);
method_exchangeImplementations(method1, method2);
[self method1];
[self method2];
Method method 1 = class_get_InstanceMethod(self.class, @selector(method1{);
IMP imp = method_getImepletation(method);
Method imageNameMethod = class_getClassMethod(UIImage.class, @selector(imageNamed:));
Method customMethod = class_getClassMethod(self.class, @selector(loadImageFromCurrentFolder:));
method_exchangeImplementations(imageNameMethod, customMethod);
獲得屬性列表:
objc_property_t *properties = class_copyPropertyList(class, &propertyCount);
const char *propertyName = property_getName(property);
const char *attrs = property_getAttributes(property);
設(shè)計模式
自動布局
iOS 7的新特性
iOS面試題
響應(yīng)鏈
圖層和視圖的關(guān)系
block內(nèi)存管理和block的實現(xiàn)
view的層次結(jié)構(gòu)
autorelease 的作用域
__weak, __block實現(xiàn)
block什么時候在棧中,什么時候在堆中
hittest是否了解:
當觸擊視圖上的某一區(qū)域,在UIResponder的hitTest:withEvent:實現(xiàn)方法內(nèi):
1.首先調(diào)用self.pointInside:withEvent方法
2.如果返回NO,hitTest:withEvent:將直接返回nil,方法結(jié)束。
3.如果返回YES,則會依次對其所擁有的子視圖集合發(fā)送hitTest:withEvent:消息。在子視圖方法hitTest:withEvent:內(nèi)同樣調(diào)用PointInSide方法,如果返回NO,則子視圖的hitTest:withEvent:返回nil,如果子視圖的PointInSide返回YES,則子視圖方法hitTest:withEvent:內(nèi)會接著調(diào)用其所擁有子視圖的hitTest:withEvent:方法,以此遞歸調(diào)回下去。直到子視圖已經(jīng)沒有子視圖集合時,返回子視圖本身self。
4.如果遇到一個子視圖返回了一個非nil的對象,那么hitTest:withEvent:將會直接返回此對象,方法結(jié)束。
hitTest:withEvent:{
BOOL isPointInside = [self pointInside];
if (isPointInside) {
id hitView = nil;
for (UIView *subView in self.subViews) {
hitView = [subView hitTest:withEvent];
if (hitView) return hitView;
}
return self;
} else {
return nil;
}
}
如何擴大子view的點擊區(qū)域?
UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
// set the image size smaller than the size of button (for example 32 x 32)
[button setImage: [UIImage imageNamed: @"buttonIcon.png"] forState: UIControlStateNormal];
// just set the frame of the button (here 64 x 64)
[button setFrame: CGRectMake(xPositionOfMyButton, yPositionOfMyButton, 64, 64)];
【走向平庸的四個特征】一、沒目標,只混日子。沒方向,不規(guī)劃人生,瞎折騰。浪費時間二、不獨立自主,,不學(xué)習(xí)不吸收信息,沒主見,被動的活著。三、沒責(zé)任心,沒風(fēng)險意識,不敢承擔(dān)風(fēng)險、四、沒有投資理財意識。
留下性命來為你做錯的事,來向這個世界償還,因為凡此種種,全是你欠她的,人生從來不容易,但是再不容易也要熬下去。
我知道,你雖然現(xiàn)在已經(jīng)把東西翻譯好了,但是后面幾章的質(zhì)量也是隨便糊弄出來的。現(xiàn)在一章一章的貼上去。一方面是為了進行糾正。
你心里還是沒底,我到底學(xué)到了什么,為什么會這么想,因為你沒有真正去練手。繼續(xù)看
時間抓起來就是黃金,抓不起來就是流水。對讀書來說,尤其是如此。早晨早十分鐘起床,可以擠這十分鐘讀書;晚上少看一點電視,翻幾頁書應(yīng)該可以做到;節(jié)假日休息時,推掉一兩個應(yīng)酬,就有了整塊時間。有時候,說一個“不”字,就贏得了讀一本書的時間。閱讀像爬山,不怕慢,只怕站。謹記,分享!
這是DCCF.ME為你準備的電影周刊。
閑暇時光有我陪伴,DCCF.ME本周好看的電影推薦:
讓這些電影治愈你
1、缺乏學(xué)習(xí)動力:《幸福終點站》、《風(fēng)雨哈佛路》
2、對愛失望:《偷天情緣》、《初戀50次》
3、自卑失落:《阿甘正傳》、《肖申克的救贖》
4、失敗或絕望:《鐵權(quán)男人》、《迫在眉梢》、《伊麗莎白鎮(zhèn)》
5、厭倦生活:《在世界的轉(zhuǎn)角遇見愛》、《搏擊俱樂部》
最費腦力的14部電影
《盜夢空間》、《記憶裂痕》、《生死停留》、《死亡幻覺》、《禁閉島》、《穆赫蘭道》、《蝴蝶效應(yīng)》、《恐怖游輪》、《傷城》、《盜走達芬奇》、《88分鐘》、《萬能鑰匙》、《決勝21點》、《沉默的羔羊》
結(jié)局最意外的20部電影
《搏擊俱樂部》、《迷霧》、《心理游戲》、《第六感》、《蝴蝶效應(yīng)》、《電鋸驚魂》、 《賽末點》、《 穆赫蘭道》、《非常嫌疑犯》、《魔術(shù)師》、《小島驚魂》、《萬能鑰匙》、《火柴人》、《七宗罪》、《魔鬼代言人》、《孤兒》、《八面埋伏 》、《香水》、《偷拐搶騙》
走進12星座女孩內(nèi)心世界的電影
《情人》白羊
《綠蔭下》金牛
《初戀50次》雙子
《黑暗中的舞者》巨蟹
《辦公室的故事》獅子
《傲慢與偏見》處女
《西西里的美麗傳說》天秤
《布達佩斯之戀》天蝎
《艷舞女郎》射手
《楊朵兒》摩羯
《羅丹的情人》水瓶
《天使艾米麗》雙魚
16部講天才的電影
《美麗心靈》、《雨人》、《波拉克》、《暗物質(zhì)》、《天才瑞普利》、《貓鼠游戲》、《香水》、《一級恐懼》、《心靈捕手》、《莫扎特傳》、《證據(jù)》、《海上鋼琴師》、《電鋸驚魂》、《沉默的羔羊》、《非常嫌疑犯》、《尋找弗羅斯特》
推薦給女人的十部電影
1、《亂世佳人》(堅強)
2、《母女情深》(親情)
3、《簡愛》(尊嚴)
4、《蒂凡尼的早餐》(虛榮)
5、《白領(lǐng)麗人》(才華)
6、《鋼琴課》(溝通)
7、《漂亮女人》(浪漫)
8、《紫色》(苦難)
9、《末路狂花》(女權(quán))
10、《女人那話兒》(性愛)
推薦給男人的十部影片
1、《阿甘正傳》(執(zhí)著)
2、《東方不敗》(才華)
3、《美國往事》(人生)
4、《羅馬假日》(愛情)
5、《勇敢的心》(勇氣)
6、《辛德勒的名單》(責(zé)任)
7、《肖申克的救贖》(信念)
8、《E.T》(童心)
9、《現(xiàn)代啟示錄》(痛苦)
10、《第七封印》(哲思)
推薦給心理愛好者的10部經(jīng)典電影
《致命ID》多重人格障礙;
《歌西卡》犯罪心理學(xué);
《美國精神病》雙重人格;
《鋼琴教師》性心理變態(tài);
《美麗心靈》偏執(zhí)性精神分裂;
《記憶碎片》失憶癥;
《藍絲絨》心理扭曲;
《雨人》自閉癥;
《本能》性與暴力;
《沉默的羔羊》變態(tài)心理。
最值得欣賞的英式發(fā)音電影
《如果能再愛一次》、《成長教育》、《穿越時空愛上你》、《生死朗讀》、《猜火車》、《哈利波特》《女王》、《真愛至上》、《戀愛假期》、《諾丁山》、《真愛之吻》、《傲慢與偏見》、《莎翁情史》、《成為簡奧斯汀》、《福爾摩斯》、《霧都孤兒》、《兵臨城下》、《英國病人》
因為名字爛而被錯過的好電影
《三傻大鬧寶萊塢》、《刺激1995》、《搏擊俱樂部》、《機器人總動員》、《殺死比爾》、 《低俗小說》、《落水狗》、《午夜牛郎》、《洋蔥電影》、《蝴蝶效應(yīng)》、《諾丁山》、《兩桿大煙槍》、《搖滾黑幫》、《十誡》
看一場電影。
在20歲的時候,遇見你。與你戀愛。
10年之后,你只能做我的愛人。
有些話,不說出來就能明白。
我們都需要一個愛人,可以安心的在身邊入睡。
可以說話,或者相愛。
——DCCF.ME東長村夫
這段時間你需要做的不是胡思亂想學(xué)什么web,什么游戲。靜下心來邊學(xué)習(xí)iOS,邊學(xué)習(xí)算法,英語就夠了。多讀書、管理類、經(jīng)濟類、投資類 設(shè)計模式+UML
出國,美好的生活,身邊的朋友談?wù)撝悴恢赖娜な? 英語口語,努力努力
https://github.com/xdream86/iOS7-Sampler
學(xué)習(xí)iOS 7的主要功能:
- 包括TextKit
- 自動布局
- 新的UIKit動力學(xué)
- iOS 7示例代碼
- 透明視圖 類似podcast
- Tintcolor
- 自動布局與動畫
- 將某一個文件恢復(fù)到某一個版本
設(shè)置漸變色:https://gist.github.com/alanzeino/6619253
這幾天一個是忙散項目,一個是要離職,心有點散。博客沒寫了,胡適魯迅的書也不讀了!當當?shù)臅膊毁I了。晚上回去也就上上網(wǎng),也不看代碼,不關(guān)注技術(shù)的東西了。希望去了那邊,這些習(xí)慣帶起來。不要瞎想,專注就好。
- 上班路上手機放在包里 不能拿在手里
- 看MagicalRecord代碼
- 早上設(shè)計模式
3.晚上衣服一定要洗好
MagicalRecord:
This method will save the child context to the parent context and then the parent context to the persistent store. The save to the parent context will be fast because it is performed within memory.
@interface NSManagedObjectContext (MagicalRecordInternal),
@interface MagicalRecord (Internal)NSString * const kMagica
將MagicalRecord類中特定功能通過MagicalRecod+Actoins/ErrorHandling/Setup/Options/ShorthandSupport/Logging/Options/Deprecated/ShorthandSupport移到單獨文件中
4.__weak static id errorHandlerTarget = nil;
static SEL errorHandlerAction = nil;-
maigicalRecord包含日志系統(tǒng):
define LOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, …) \
NSLog (frmt, ##VA_ARGS)
參考的企業(yè)級日志系統(tǒng);CocoaLumberjack
在MagicalRecord+Options中一些對默認行為的配置,比如是否在model的版本與store的版本不匹配時候,自動刪除本地的store,以及默認的日志級別
MagicalRecord對NSManagedObjectModel, NSPersistentStore,NSPersistentStoreCoordinator,NSManagedObjectContext, NSManagedObject進行了增強補充。
NSManagedObjectModel:設(shè)置默認的NSManagedObjectModel,主要是在特定的目錄內(nèi)查找.xcdatamodeld文件,然后生成NSManagedObjectModel。- (NSManagedObjectModel *) MR_newManagedObjectModelNamed:(NSString *)modelFileName NS_RETURNS_RETAINED;
從MyApp.app目錄內(nèi)查找Model.xcdatamodeld文件:
NSString *path = [[NSBundle mainBundle] pathForResource:[modelName stringByDeletingPathExtension]
ofType:[modelName pathExtension]
inDirectory:bundleName];在h文件中extern NSString * const kMagicalRecordDefaultStoreFileName;,
在m文件中NSString * const kMagicalRecordDefaultStoreFileName = @“CoreDataStore.sqlite”;-
NSPersistentStore:設(shè)置:主要是獲取store的URL,通過設(shè)置一個xx.sqlite,在目錄中查找,返回URL,實現(xiàn)文件中包含了獲取Document、Storage目錄
13:MagicalRecord+ShorthandSupport.m中
13.1:在metaclass中添加類方法,在class中添加實例方法
Class targetMetaClass = objc_getMetaClass([NSStringFromClass(targetClass) cStringUsingEncoding:NSUTF8StringEncoding]);BOOL methodWasAdded = class_addMethod(targetMetaClass, sourceSelector,
method_getImplementation(targetClassMethod),
method_getTypeEncoding(targetClassMethod));
13.2: Class targetMetaClass = objc_getMetaClass([NSStringFromClass(targetClass) cStringUsingEncoding:NSUTF8StringEncoding]);
// 這里的含義就是交叉調(diào)用,使用MR_resolveClassMethod覆蓋默認的resolveClassMethod簽名實現(xiàn),這樣當系統(tǒng)調(diào)用resolveClassMethod,會調(diào)用MR_resolveClassMethod
// 然后將resolveClassMethod的默認實現(xiàn)使用MR_resolveClassMethod替換掉
// 運行時會先調(diào)用resolveClassMethod,因為resolveClassMethod的實現(xiàn)已經(jīng)被替換成了MR_resolveClassMethod,所以會調(diào)用MR_resolveClassMethod的代碼,
// 而在方法代碼中,MR_resolveClassMethod會調(diào)用默認的resolveClassMethod實現(xiàn)。
// 從目的上來看,是想將resolveClassMethod調(diào)用自定義的MR_resolveClassMethod方法代碼。
BOOL methodWasAdded = class_addMethod(targetMetaClass, sourceSelector,
method_getImplementation(targetClassMethod),
method_getTypeEncoding(targetClassMethod));// 這里使用添加代碼的目的是為了在自定義的方法代碼中,當出現(xiàn)調(diào)用
// MR_resolveClassMethod的情況,自動調(diào)用默認的resolveClassMethod,以防止死循環(huán)調(diào)用。
查找resolveClassMethod方法,然后如果沒有此方法,則將此方法簽名前面加上MR_前綴,然后生成方法,將原始沒有前綴的方法綁定有MR_的實現(xiàn)。添加到當前的類中。
因為用戶調(diào)用的時候,需要自動完成,所以在MagicalRecordShorthand.h中添加了大量的方法預(yù)定義,實際的方法并沒有實現(xiàn),而是通過在運行時動態(tài)添加。
在CoreData+MagicalRecord.h中有代碼:ifdef MR_SHORTHAND
import “MagicalRecordShorthand.h”
endif
NSPersistentStoreCoordinator:獲取默認的協(xié)作器與設(shè)置默認的協(xié)作器,設(shè)置默認協(xié)作器時也需要設(shè)置默認store。
創(chuàng)建指定路徑下的文件夾。
// 負責(zé)添加store,只在出現(xiàn)因為model的版本不匹配才進行刪除store,并重建處理。其過程主要刪除之前的.sqlite/.wal/.shm文件。
// 刪除、重建的通知:將要刪除store、已經(jīng)刪除store/失敗刪除store,將要重建store, 已經(jīng)重建store/失敗重建store
NSPersistentStoreCoordinator.h/m文件主要負責(zé)創(chuàng)建協(xié)調(diào)器,根據(jù)store名,以及配置是否一些自動遷移選項。
15.NSManagedObjectStore,主要是獲取store的位置,以及設(shè)置store。從文檔目錄和NSApplicationSupportDirectory目錄搜索指定的sqliteNSManagedObjectContext+MagicalObserving.h/m主要完成對給定上下文的變更通知觀察,并執(zhí)行合并
17.NSManagedObjectContext (MagicalRecord):使用給定的協(xié)作器初始化默認的上下文,包含兩個上下文:根上下文和默認上下文,根上下文負責(zé)保存并合并到默認上下文
18.在MagicalRecord+MagicalSaves中:
關(guān)鍵性方法:- (void) MR_saveWithOptions:(MRSaveContextOptions)mask
completion:(MRSaveCompletionHandler)completion;
方法參數(shù)保存選項mask有4個選項:無選項0,繼續(xù)保存父上下文、同步執(zhí)行保存、同步執(zhí)行保存除了在根上下文上。如果選擇繼續(xù)保存父上下文,則會遞歸調(diào)用 [[self parentContext] MR_saveWithOptions:mask completion:completion];如果同步執(zhí)行保存,[self performBlockAndWait:saveBlock];否則調(diào)用[self performBlock:saveBlock];。如果設(shè)置的是保存除根上下文,則當[[self class] MR_rootSavingContext]為真時,執(zhí)行performBlock:方法。
performBlockAndWait的block會在調(diào)用該方法的線程上執(zhí)行,并且該方法支持內(nèi)嵌
performBlock放入隊列,在一個不確定的時間不確定的線程上被執(zhí)行,在入隊列之后會立即返回,perfromBlockAndWait會在一個不確定的時間,一個完全相同的線程上被執(zhí)行,方法會在代碼被完全執(zhí)行完之后被返回。
當調(diào)用performBlockAndWait,block會在調(diào)用此方法的線程上執(zhí)行。
19.NSManagedObjectContext+MagicalObserving,
- (void) MR_observeContext:(NSManagedObjectContext *)otherContext;
觀察otherContext,如果otherContext發(fā)出了了NSManagedObjectContextDidSaveNotification,則執(zhí)行合并。
- NSManagedObject+MagicalRecord.h/m
主要是獲取、按條件獲取、獲取首個對象,獲取指定上下文中的首個對象,創(chuàng)建實體實例、刪除實體、按給定的屬性列表排序
pragma clang diagnostic push
pragma clang diagnostic ignored “-Wdeprecated-declarations”
return [self MR_executeFetchRequest:request inContext:[NSManagedObjectContext MR_contextForCurrentThread]];
pragma clang diagnostic pop
[NSEntityDescription entityForName:entityName inManagedObjectContext:context];
NSEntityDescription *description = [self MR_entityDescription];
// key:string of property name,value:NSAttributeDescription and/or NSRelationshipDescription.
NSDictionary *propDict = [description propertiesByName];
/創(chuàng)建NSManagedObject/
NSEntityDescription * doctorEntityDescription = [NSEntityDescription entityForName:@“Doctor” inManagedObjectContext:context];
NSManagedObject newDoctor = [[NSManagedObject alloc] initWithEntity:doctorEntityDescription insertIntoManagedObjectContext:context];
/創(chuàng)建NSManagedObject*/
NSManagedObject *newPatient = [NSEntityDescription insertNewObjectForEntityForName:@“Patient” inManagedObjectContext:context];
[newPatient setValue:@“John” forKey:@“firstName”];
[newPatient setValue:@“Doe” forKey:@“l(fā)astName”];
[newPatient setValue:practiceDoctor forKey:@“doctor”];
NSError anyError = nil;
BOOL saveSuccessfully = [context save:&anyError];
if (!saveSuccessfully) {
/ do something with anyError */
}
NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
// Create a new Person in the current thread context
Person *person = [Person MR_createInContext:localContext];
person.firstname = firstname;
person.lastname = lastname;
person.age = age;
// Save the modification in the local context
// With MagicalRecords 2.0.8 or newer you should use the MR_saveNestedContexts
[localContext MR_save];
- NSManagedObject+MagicalFinder.h/m 主要是提取數(shù)據(jù),以及生成NSFetchedResultsControlller
考慮代碼1和代碼2的區(qū)別,代碼2在NSManagedObject中設(shè)置了一個類方法,直接生成NSFetchedResultsController
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@“Patient”];
[request setBatchSize:20];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@“l(fā)astName” ascending:YES];
[request setSortDescriptors:@[sortDescriptor]];
[sortDescriptor release];
NSFetchedResultsController *newController = [[NSFetchedResultsController alloc] initWithFetchRequest:request
managedObjectContext:context
sectionNameKeyPath:@“doctor.fullName”
cacheName:@“patientsCache”];
與下列代碼的區(qū)別:
- (NSFetchedResultsController *) MR_fetchController:(NSFetchRequest *)request
delegate:(id<NSFetchedResultsControllerDelegate>)delegate
useFileCache:(BOOL)useFileCache
groupedBy:(NSString *)groupKeyPath
inContext:(NSManagedObjectContext *)context;
閱讀該類代碼,可以發(fā)現(xiàn),NSManagedObject+MagicalRecord.h/m和NSManagedObject+MagicalRequest.h/m都是為NSManagedObject+MagicalRequest.h/m服務(wù)的。
// 查找第一個,沒有就創(chuàng)建一個 - (instancetype) MR_findFirstOrCreateByAttribute:(NSString *)attribute withValue:(id)searchValue
if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
endif
NSManagedObject+MagicalRequests.h/m
負責(zé)生成各式各樣的request對象,類似于生成模板化的sql。
// 創(chuàng)建獲取所有實體實例的request
// 創(chuàng)建獲取滿足特定條件的request
// 創(chuàng)建所有滿足特定屬性的屬性值和給定的相同的所有對象的request
// 創(chuàng)建獲取滿足條件的第一個對象的request
// 創(chuàng)建獲取滿足指定屬性的屬性值和給定相同的的request第一個對象的request
// 創(chuàng)建一個擁有特定謂詞以及排序方式的返回所有對象的requestNSManagedObject+MagicalAggregation.h/,m
為了不每次稱體重的時候糾結(jié)
為了遇見 最好的她
為了健康
如果你每次運動只有十五分鐘,則燒掉的是糖類,燒不掉脂肪;運動半小時后,才會開始燃燒較多的脂肪。每次運動的時間越久,燒掉的脂肪越多,這是因為連續(xù)性運動的主要能源是脂肪而不是糖類。相反的,瞬時爆發(fā)性運動的能源是糖類而不是脂肪,故這類運動對減肥沒什么幫助
所以每次掐表
control+cmd+j方法聲明和方法實現(xiàn)之間跳轉(zhuǎn)
折疊所有方法:command+alt+shift+<-
選中A,然后按住Alt,然后選中B則出現(xiàn)兩個頁面
Shift+Option+Command+回車 比較文件
鍵盤上左右側(cè)都有:Shift+Command+Option,Option就是Alt,只有左側(cè)有Control。
fn + Option +↑ 向上翻頁
fn +Option+↓ 向下翻頁
option+command+回車 顯示右側(cè)的輔助窗口
Command+Shift+{ 左側(cè)標簽
Command+Shift+} 右側(cè)標簽
- Command+Y顯示歷史
1:command+數(shù)字 1-8
2:展開折疊左側(cè)界面:command+數(shù)字0
3:展開折疊右側(cè)界面:command+option+0
4: 折疊調(diào)試窗口command+Shift+Y
5:command+shift+2是organizer
6 command+J 新建編輯區(qū)域
7:command+control+J 跳轉(zhuǎn)到定義
8: command+shift+j 在項目導(dǎo)航器中選中當前正在被編輯的文件:
9:command+option+J是執(zhí)行文件過濾
10:command+option+L是搜索代碼塊
11: command+shift+字母0快速打開文件
12:command+L定位到行
13: command+option+數(shù)字1-6
14:command+Control+E 快速編輯,在作用域中編輯
15: 注銷行command+/
16: 添加斷點command+
16.1 禁用/開啟所有斷點 command+Y
17: control+字母I執(zhí)行代碼格式化re-indent(縮排)
18:control+數(shù)字1打開顯示相關(guān)項目,可以瀏覽caller
19:command+K清除控制臺信息
20:command+Shift+K 清理項目
21 option+command+H 隱藏其他除xcode的窗口
22 command+control+<- -> 前進后退
23 command+control+上下鍵 .h/.m切換
24 command+R,Command+B command+U command+.運行,構(gòu)建,單元測試,停止 - option+左方向鍵收起菜單,右方向鍵展開菜單
- command+`(在鍵盤的左上第二排第一個)在同一個程序中切換窗口
- command+M最小化當前窗口
- 在keyboard中配置,app shortcuts->標題輸入Zoom,快捷鍵輸入control+Command+=最大化窗口
29.control+command+f進入全屏
30:control+command+f繼續(xù)執(zhí)行斷點