日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ios开发之.pch文件的使用

發(fā)布時間:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ios开发之.pch文件的使用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

案例:開源中國iOS客戶端? ?? ? 當我們新建一個工程的時候,在Supporting FIles文件下會看到一個以??-Prefix.pch結(jié)尾文件的文件,pch全稱是“precompiled header”,也就是預(yù)編譯頭文件,該文件里存放的工程中一些不常被修改的代碼,比如常用的框架頭文件,這樣做的目的提高編譯器編譯速度。我們知道當我們修改一個工程中某個文件代碼時候,編譯器并不是重新編譯所有所有文件,而是編譯改動過文件的,假如pch中某個文件修改了,那么pch整個文件里包含的的其他文件也會重新編譯一次,這樣就會消耗大量時間,所以它里面添加的文件最好是是很少變動或不變動的頭文件或者是預(yù)編譯的代碼片段;


在新建一個工程時,pch后綴文件里代碼是

  • #import <Availability.h>
  • #ifndef __IPHONE_4_0
  • #warning "This project uses features only available in iOS SDK 4.0 and later."
  • #endif
  • #ifdef __OBJC__
  • ? ? #import <UIKit/UIKit.h>
  • ? ? #import <Foundation/Foundation.h>
  • #endif
  • 復(fù)制代碼

    或許你會覺得這預(yù)編譯代碼很少,但是你可以查看一下UIKit.h的定義文件中


  • //
  • //??UIKit.h
  • //??UIKit
  • //
  • //??Copyright (c) 2005-2011, Apple Inc. All rights reserved.
  • //
  • #import <UIKit/UIKitDefines.h>
  • #import <UIKit/UIAccelerometer.h>
  • #import <UIKit/UIAccessibility.h>?
  • #import <UIKit/UIActivityIndicatorView.h>
  • #import <UIKit/UIAlert.h>
  • #import <UIKit/UIApplication.h>
  • #import <UIKit/UIBarButtonItem.h>
  • #import <UIKit/UIBarItem.h>
  • #import <UIKit/UIBezierPath.h>
  • #import <UIKit/UIButton.h>
  • #import <UIKit/UIColor.h>
  • #import <UIKit/UIControl.h>
  • #import <UIKit/UIDataDetectors.h>
  • #import <UIKit/UIDatePicker.h>
  • #import <UIKit/UIDevice.h>
  • #import <UIKit/UIDocument.h>
  • #import <UIKit/UIDocumentInteractionController.h>
  • #import <UIKit/UIEvent.h>
  • #import <UIKit/UIFont.h>
  • #import <UIKit/UIGeometry.h>
  • #import <UIKit/UIGestureRecognizer.h>
  • #import <UIKit/UIGraphics.h>
  • #import <UIKit/UIImage.h>
  • #import <UIKit/UIImagePickerController.h>
  • #import <UIKit/UIImageView.h>
  • #import <UIKit/UIInterface.h>
  • #import <UIKit/UILabel.h>
  • #import <UIKit/UILocalNotification.h>
  • #import <UIKit/UILocalizedIndexedCollation.h>
  • #import <UIKit/UILongPressGestureRecognizer.h>
  • #import <UIKit/UIManagedDocument.h>
  • #import <UIKit/UIMenuController.h>
  • #import <UIKit/UINavigationBar.h>
  • #import <UIKit/UINavigationController.h>
  • #import <UIKit/UINib.h>
  • #import <UIKit/UINibDeclarations.h>
  • #import <UIKit/UINibLoading.h>
  • #import <UIKit/UIPageControl.h>
  • #import <UIKit/UIPageViewController.h>
  • #import <UIKit/UIPanGestureRecognizer.h>
  • #import <UIKit/UIPasteboard.h>
  • #import <UIKit/UIPickerView.h>
  • #import <UIKit/UIPinchGestureRecognizer.h>
  • #import <UIKit/UIPopoverController.h>
  • #import <UIKit/UIPopoverBackgroundView.h>
  • #import <UIKit/UIPrintError.h>
  • #import <UIKit/UIPrintFormatter.h>
  • #import <UIKit/UIPrintInfo.h>
  • #import <UIKit/UIPrintInteractionController.h>
  • #import <UIKit/UIPrintPageRenderer.h>
  • #import <UIKit/UIPrintPaper.h>
  • #import <UIKit/UIProgressView.h>
  • #import <UIKit/UIReferenceLibraryViewController.h>
  • #import <UIKit/UIResponder.h>
  • #import <UIKit/UIRotationGestureRecognizer.h>
  • #import <UIKit/UIScreen.h>
  • #import <UIKit/UIScreenMode.h>
  • #import <UIKit/UIScrollView.h>
  • #import <UIKit/UISearchBar.h>
  • #import <UIKit/UISearchDisplayController.h>
  • #import <UIKit/UISegmentedControl.h>
  • #import <UIKit/UISlider.h>
  • #import <UIKit/UISplitViewController.h>
  • #import <UIKit/UIStepper.h>
  • #import <UIKit/UIStoryboard.h>
  • #import <UIKit/UIStoryboardPopoverSegue.h>
  • #import <UIKit/UIStoryboardSegue.h>
  • #import <UIKit/UIStringDrawing.h>
  • #import <UIKit/UISwipeGestureRecognizer.h>
  • #import <UIKit/UISwitch.h>
  • #import <UIKit/UITabBar.h>
  • #import <UIKit/UITabBarController.h>
  • #import <UIKit/UITabBarItem.h>
  • #import <UIKit/UITableView.h>
  • #import <UIKit/UITableViewCell.h>
  • #import <UIKit/UITableViewController.h>
  • #import <UIKit/UITapGestureRecognizer.h>
  • #import <UIKit/UITextField.h>
  • #import <UIKit/UITextInput.h>
  • #import <UIKit/UITextInputTraits.h>
  • #import <UIKit/UITextView.h>
  • #import <UIKit/UIToolbar.h>
  • #import <UIKit/UITouch.h>
  • #import <UIKit/UIVideoEditorController.h>
  • #import <UIKit/UIView.h>
  • #import <UIKit/UIViewController.h>
  • #import <UIKit/UIWebView.h>
  • #import <UIKit/UIWindow.h>
  • 復(fù)制代碼

    這些不少了吧,工程每次運行都編譯是不是很費時間,這些是蘋果公司內(nèi)部定義的標準頭文件,我們不能也沒有權(quán)限修改這些頭文件定義內(nèi)容,所以,當放到pch文件中會加速編譯過程;



    再來看看我們開源中國iOS客戶端pch文件

  • //
  • // Prefix header for all source files of the 'oschina' target in the 'oschina' project
  • //
  • #import <Availability.h>
  • #ifndef __IPHONE_4_0
  • #warning "This project uses features only available in iOS SDK 4.0 and later."
  • #endif
  • #ifdef __OBJC__
  • ? ? #import <UIKit/UIKit.h>
  • ? ? #import <Foundation/Foundation.h>
  • ? ? #import <CoreData/CoreData.h>
  • ? ? #import <QuartzCore/QuartzCore.h>
  • //添加的預(yù)編譯
  • #import "ASIHTTPRequest.h"
  • #import "ASIFormDataRequest.h"
  • #import "ASIHTTPRequestDelegate.h"
  • #import "ASIHTTPRequestConfig.h"
  • #import "TBXML.h"
  • #import "TBXML+HTTP.h"
  • #import "TBXML+Compression.h"
  • #import "Config.h"
  • #import "EGORefreshTableHeaderView.h"
  • #import "DataSingleton.h"
  • #import "ImgRecord.h"
  • #import "IconDownloader.h"
  • #import "MBProgressHUD.h"
  • #import "GCDiscreetNotificationView.h"
  • #import "NdUncaughtExceptionHandler.h"
  • #import "JSNotifier.h"
  • #import "AFOSCClient.h"
  • #import "AFHTTPRequestOperation.h"
  • #import "AFXMLRequestOperation.h"
  • //api定義
  • #define api_news_list @"http://www.oschina.net/action/api/news_list"
  • #define api_news_detail @"http://www.oschina.net/action/api/news_detail"
  • #define api_post_list @"http://www.oschina.net/action/api/post_list"
  • #define api_post_detail @"http://www.oschina.net/action/api/post_detail"
  • #define api_post_pub @"http://www.oschina.net/action/api/post_pub"
  • #define api_tweet_list @"http://www.oschina.net/action/api/tweet_list"
  • #define api_tweet_detail @"http://www.oschina.net/action/api/tweet_detail"
  • #define api_tweet_delete @"http://www.oschina.net/action/api/tweet_delete"
  • #define api_tweet_pub @"http://www.oschina.net/action/api/tweet_pub"
  • #define api_active_list @"http://www.oschina.net/action/api/active_list"
  • #define api_message_list @"http://www.oschina.net/action/api/message_list"
  • #define api_message_delete @"http://www.oschina.net/action/api/message_delete"
  • #define api_message_pub @"http://www.oschina.net/action/api/message_pub"
  • #define api_comment_list @"http://www.oschina.net/action/api/comment_list"
  • #define api_comment_pub @"http://www.oschina.net/action/api/comment_pub"
  • #define api_comment_reply @"http://www.oschina.net/action/api/comment_reply"
  • #define api_comment_delete @"http://www.oschina.net/action/api/comment_delete"
  • #define api_login_validate @"https://www.oschina.net/action/api/login_validate"
  • #define api_user_info @"http://www.oschina.net/action/api/user_info"
  • #define api_user_information @"http://www.oschina.net/action/api/user_information"
  • #define api_user_updaterelation @"http://www.oschina.net/action/api/user_updaterelation"
  • #define api_notice_clear @"http://www.oschina.net/action/api/notice_clear"
  • #define api_software_detail @"http://www.oschina.net/action/api/software_detail"
  • #define api_blog_detail @"http://www.oschina.net/action/api/blog_detail"
  • #define api_favorite_list @"http://www.oschina.net/action/api/favorite_list"
  • #define api_favorite_add @"http://www.oschina.net/action/api/favorite_add"
  • #define api_favorite_delete @"http://www.oschina.net/action/api/favorite_delete"
  • #define api_user_notice @"http://www.oschina.net/action/api/user_notice"
  • #define api_search_list @"http://www.oschina.net/action/api/search_list"
  • #define api_friends_list @"http://www.oschina.net/action/api/friends_list"
  • #define api_softwarecatalog_list @"http://www.oschina.net/action/api/softwarecatalog_list"
  • #define api_software_list @"http://www.oschina.net/action/api/software_list"
  • #define api_softwaretag_list @"http://www.oschina.net/action/api/softwaretag_list"
  • #define api_blogcomment_list @"http://www.oschina.net/action/api/blogcomment_list"
  • #define api_blogcomment_pub @"http://www.oschina.net/action/api/blogcomment_pub"
  • #define api_my_information @"http://www.oschina.net/action/api/my_information"
  • #define api_blogcomment_delete @"http://www.oschina.net/action/api/blogcomment_delete"
  • #define api_userblog_delete @"http://www.oschina.net/action/api/userblog_delete"
  • #define api_userblog_list @"http://www.oschina.net/action/api/userblog_list"
  • #define api_blog_list @"http://www.oschina.net/action/api/blog_list"
  • #define api_userinfo_update @"http://www.oschina.net/action/api/portrait_update"
  • //宏定義 新聞
  • #define TweetCellIdentifier @"TweetCellIdentifier"
  • #define loadMoreIdentifier @"loadMoreIdentifier"
  • #define NewsCellIdentifier @"NewsCellIdentifier"
  • #define PostCellIdentifier @"PostCellIdentifier"
  • #define MsgCellIdentifier @"MsgCellIdentifier"
  • #define MsgUnitCellIdentifier @"MsgUnitCellIdentifier"
  • #define ActiveCellIdentifier @"ActiveCellIdentifier"
  • #define UserActiveCellIdentifier @"UserActiveCellIdentifier"
  • #define ColorActiveCellIdentifier @"ColorActiveCellIdentifier"
  • #define RTActiveCellIdentifier @"RTActiveCellIdentifier"
  • #define ColorUserActiveCellIdentifier @"ColorUserActiveCellIdentifier"
  • #define ProfielCellIdentifier @"ProfielCellIdentifier"
  • #define CommentCellIdentifier @"CommentCellIdentifier"
  • #define NormalCellIdentifier @"NormalCellIdentifier"
  • #define FavoriteCellIdentifier @"FavoriteCellIdentifier"
  • #define FriendCellIdentifier @"FriendCellIdentifier"
  • #define SoftwareCellIdentifier @"SoftwareCellIdentifier"
  • #define SoftwareCatalogIdentifier @"SoftwareCatalogIdentifier"
  • #define SettingTableIdentifier @"SettingTableIdentifier"
  • #define MyInfoCellIdentifier @"MyInfoCellIdentifier"
  • #define MyPortraitCellIdentifier @"MyPortraitCellIdentifier"
  • #define loadNext20Tip @"下面 20 項 . . ."
  • #define loadingTip @"正在加載 . . ."
  • #define networkError @"網(wǎng)絡(luò)無連接"
  • #define noNetworkTip @"網(wǎng)絡(luò)無連接"
  • //消息通知固定字符串
  • #define Notification_DetailCommentCount @"Notification_DetailCommentCount"
  • #define Notification_NoticeUpdate @"Notification_NoticeUpdate"
  • #define Notification_TabClick @"Notification_TabClick"
  • //html頭部
  • #define HTML_Style @"<style>#oschina_title {color: #000000; margin-bottom: 6px; font-weight:bold;}#oschina_title img{vertical-align:middle;margin-right:6px;}#oschina_title a{color:#0D6DA8;}#oschina_outline {color: #707070; font-size: 12px;}#oschina_outline a{color:#0D6DA8;}#oschina_software{color:#808080;font-size:12px}#oschina_body img {max-width: 300px;}#oschina_body {font-size:16px;max-width:300px;line-height:24px;} #oschina_body table{max-width:300px;}#oschina_body pre { font-size:9pt;font-family:Courier New,Arial;border:1px solid #ddd;border-left:5px solid #6CE26C;background:#f6f6f6;padding:5px;}</style>"
  • #define HTML_Bottom @"<div style='margin-bottom:60px'/>"
  • #define USERAGENT @"OSChina.NET/iOS/5.0"
  • #define AppVersion @"1.6.1"
  • #ifdef DEBUG
  • #define debugLog(...) NSLog(__VA_ARGS__)
  • #define debugMethod() NSLog(@"%s", __func__)
  • #else
  • #define debugLog(...)
  • #define debugMethod()
  • #endif
  • #endif
  • 復(fù)制代碼

    我們看到有這樣些文件也被添加到里面,可能會想難道這些頭文件變化不大嗎?

  • //添加的預(yù)編譯
  • #import "ASIHTTPRequest.h"
  • #import "ASIFormDataRequest.h"
  • #import "ASIHTTPRequestDelegate.h"
  • #import "ASIHTTPRequestConfig.h"
  • #import "TBXML.h"
  • #import "TBXML+HTTP.h"
  • #import "TBXML+Compression.h"
  • #import "Config.h"
  • #import "EGORefreshTableHeaderView.h"
  • #import "DataSingleton.h"
  • #import "ImgRecord.h"
  • #import "IconDownloader.h"
  • #import "MBProgressHUD.h"
  • #import "GCDiscreetNotificationView.h"
  • #import "NdUncaughtExceptionHandler.h"
  • #import "JSNotifier.h"
  • #import "AFOSCClient.h"
  • #import "AFHTTPRequestOperation.h"
  • #import "AFXMLRequestOperation.h"
  • 復(fù)制代碼

    其實,這些文件特殊之處在于他們都是第三方類庫的頭文件,第三方類庫將一些對象進行高度封裝,留下接口,然后我們根據(jù)類庫接口直接調(diào)用就可以,這些第三方類庫一般都比iOS原生自帶的更加簡單易用,比如TBXML解析庫,比iOS自帶的NSXMLPaser解析器速度功能上都會好一些;



    還有一些宏定義都是比較常用方式的宏定義,比如定義的開源中國社區(qū)的api接口,這些接口變得當然很少了;


    然后就剩下最后面的

  • #ifdef DEBUG
  • #define debugLog(...) NSLog(__VA_ARGS__)
  • #define debugMethod() NSLog(@"%s", __func__)
  • #else
  • #define debugLog(...)
  • #define debugMethod()
  • #endif
  • 復(fù)制代碼

    工程有Debug Version和Release Version,Debug Version是程序開發(fā)過程中版本,它包含了所有調(diào)試信息,一些常用的NSLog打印日志,在程序調(diào)試過程工根據(jù)我們設(shè)置的調(diào)試信息可以看出什么地方出錯,我們在運行運行一個小程序的時候,會不會首先就想到進行斷點調(diào)試呢,應(yīng)該是首先想著NSLog一下,看看哪個函數(shù)方法沒執(zhí)行,看看是不是哪個數(shù)組的值沒取出來。Release Version是發(fā)布版本,不打印NSLog可以加快程序運行速度,減少內(nèi)存使用。? ?但是到一個大工程中,會有很多很多這樣的NSLog,在我們工程完美運行的時候,發(fā)布Release 版本的時候,難道我們?nèi)ヒ恍行械淖⑨屨{(diào)NSLog嗎?假如工程現(xiàn)在原來基礎(chǔ)上發(fā)布一個version 1.2版本的,我們在修改程序的時候豈不是還把原來注釋給取消,那就很麻煩很麻煩了。

    所以,此處用到了宏指令


    上段代碼的意思就是 用宏指令做一個判斷,如果DEBUG為真,則編譯#ifdef到#endif宏定義,否則編譯器就不編譯;
    這個DEBUG在哪設(shè)置呢,
    在 "Target > Build Settings > Preprocessor Macros > Debug" 里有一個"DEBUG=1"。



    現(xiàn)在我們來做一個測試:
    取一個宏指令放到OSAppDelegate.m的application:didFinishLaunchingWithOptions:方法中,并用同一個NSLog做一個對比;


    NSLog(@"%s", __func__);

    debugMethod();


    首先設(shè)置為Debug模式下,Product-->Edit Scheme


    跳轉(zhuǎn)到這個界面


    當我設(shè)置Build Configuration成Debug時,打印效果圖


    當我設(shè)置Build Configuration成Release的,打印時效果圖


    當Run??Test??Profile??Analyze??Archive的時候,都可以根據(jù)需要設(shè)置Debug和Release兩個模式運行;
    所以我們完全可以用一個宏指令來設(shè)置是否打印調(diào)試信息;

    轉(zhuǎn)載于:https://www.cnblogs.com/xubojoy/p/3934653.html

    總結(jié)

    以上是生活随笔為你收集整理的ios开发之.pch文件的使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 日日噜噜夜夜爽爽 | 极品尤物一区二区 | 波多野结衣在线一区二区 | 国产精品av一区二区 | 成人免费在线视频观看 | 男人和女人日b视频 | 日本天天色 | www狠狠操 | 国产在线看片 | 国产精品揄拍100视频 | 日韩精品欧美在线 | 神马影院午夜伦理片 | 好吊色视频在线观看 | 久久无码人妻一区二区三区 | av在线免播放器 | 91精品国产麻豆国产自产在线 | 午夜在线免费视频 | 中文字幕在线观看视频一区二区 | 国内自拍偷拍视频 | 欧美天堂久久 | 免费在线观看黄色av | 先锋av网| 欧洲一区二区在线观看 | 极品久久| 欧美在线你懂的 | 公侵犯一区二区三区四区中文字幕 | 欧美日韩在线第一页 | 在线黄网站 | 亚洲最大中文字幕 | 超碰综合网 | 欧美激情黄色 | 人人爽人人爱 | 国产在线拍揄自揄拍无码视频 | 黄色三级a | 中文在线免费观看 | 亚洲精品网址 | 九九自拍| 72成人网| 禁止18在线观看 | 草久在线观看 | 给我免费观看片在线电影的 | 99re99热| 中文字幕在线观看国产 | 免费观看污 | 8x8x最新网址 | 亚洲欧美偷拍一区 | www.黄色网 | 91国产丝袜在线播放 | 黑帮大佬和我的365日第二部 | 一级做a爱片久久毛片 | 天堂a在线 | 91香蕉视频污污 | 久久网站免费看 | 华人永久免费 | 日本久久激情 | www.日韩一区 | 欧美日韩亚洲二区 | 麻豆婷婷 | 四虎免费看黄 | 精品人妻无码一区二区性色 | 亚洲无限av | 91视频黄色| 四川丰满妇女毛片四川话 | 国产网红女主播精品视频 | 黄色片91 | 深夜国产在线 | 日韩色网站 | 日韩精品一区二区三区国语自制 | 日韩精品在线一区二区三区 | 免费麻豆国产一区二区三区四区 | 碧蓝之海动漫在线观看免费高清 | 日本囗交做爰视频 | 毛片内射| 久久久久亚洲av片无码 | 日韩欧美在线视频免费观看 | 伊人情人综合网 | 91黄色免费网站 | 日本午夜视频在线观看 | 性欧美长视频 | 亚洲激情成人网 | 国产一区日韩 | 美女av一区二区 | 免费大片黄在线观看 | 二区三区偷拍浴室洗澡视频 | 欧美亚洲天堂网 | 欧美一区二区影院 | 老司机精品福利导航 | 97精品人妻麻豆一区二区 | 日韩操| 老司机精品视频在线播放 | 成人欧美一级特黄 | av国产一区 | 亚洲国产精品免费在线观看 | 国产一区二区三区免费看 | 国产精品一区二区电影 | 亚洲欧美专区 | av中文在线观看 | 精品在线免费播放 | 96日本xxxxxⅹxxx70 |