{"id":590,"date":"2016-07-14T20:50:50","date_gmt":"2016-07-14T12:50:50","guid":{"rendered":"http:\/\/www.olinone.com\/?p=590"},"modified":"2019-10-29T20:49:34","modified_gmt":"2019-10-29T12:49:34","slug":"reactnative%e6%ba%90%e7%a0%81%e7%ac%94%e8%ae%b0-%e4%bd%a0%e7%9f%a5%e9%81%93%e5%87%a0%e6%9d%a1%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/www.olinone.com\/?p=590","title":{"rendered":"ReactNative\u6e90\u7801\u7b14\u8bb0\u2014\u2014\u4f60\u77e5\u9053\u51e0\u6761\uff1f"},"content":{"rendered":"<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\uff1a<a title=\"http:\/\/www.olinone.com\/\" href=\"http:\/\/www.olinone.com\/\">http:\/\/www.olinone.com\/<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/facebook\/react-native\">ReactNative<\/a>\u662fFacebook\u5f00\u6e90\u7684\u4e00\u79cd\u5b9e\u73b0\u79fb\u52a8\u8de8\u5e73\u53f0\u5f00\u53d1\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u76ee\u524d\u5728\u4e1a\u754c\u5f97\u5230\u5e7f\u6cdb\u5e94\u7528\uff0c<a href=\"http:\/\/reactnative.cn\/\">\u8fd9\u91cc<\/a>\u6709\u975e\u5e38\u8be6\u7ec6\u7684\u4e2d\u6587\u4f7f\u7528\u6307\u5357\u3002\u672c\u6587\u4e3b\u8981\u5206\u4eabRN\u6e90\u7801\u4e2d\u4e00\u4e9b\u503c\u5f97\u5927\u5bb6\u5b66\u4e60\u6216\u8005\u501f\u9274\u7684\u4ee3\u7801\u6216\u8005\u7f16\u5199\u6280\u5de7\u7b49\uff0c\u4f9b\u5927\u5bb6\u5b66\u4e60\u53c2\u8003<\/p>\n<p>\u6574\u4e2aRN\u5e93\u5305\u542b10\u591a\u4e2a\u5de5\u7a0b\uff0c\u6709\u5174\u8da3\u7684\u7ae5\u978b\u53ef\u4ee5\u4e0b\u8f7d<a href=\"https:\/\/github.com\/facebook\/react-native\">\u6e90\u7801<\/a>\u67e5\u770b\u5177\u4f53\u7ec6\u8282\uff0c\u5728\u6b64\u4e0d\u518d\u5c55\u5f00<\/p>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/cdn.olinone.com\/rnproject.png\" alt=\"\" width=\"400\" \/><\/p>\n<h2><strong>\u5b8f\u5b9a\u4e49\u5de7\u7528<\/strong><\/h2>\n<p>\u6574\u4e2aReactNative\u6e90\u7801\u5de5\u7a0b\u4e2d\u7528\u5230\u4e86\u5927\u91cf\u7684\u5b8f\u5b9a\u4e49\uff0c\u5305\u62ecRCT_EXTERN\u3001RCT_NOT_IMPLEMENTED\u3001RCT_EXPORT_METHOD\u4ee5\u53caRCT_EXPORT_MODULE\u7b49\u7533\u660e\u5b8f\u6216\u8005\u529f\u80fd\u5b8f\u3002\u901a\u8fc7\u5b8f\u5b9a\u4e49\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5d4c\u5165\u529f\u80fd\u4ee3\u7801\u6216\u8005\u903b\u8f91\u5b9e\u73b0\uff0c\u91cd\u7528\u4ee3\u7801\u7684\u540c\u65f6\u53c8\u4fdd\u6301\u4e86\u4ee3\u7801\u7684\u6574\u6d01\u6027<\/p>\n<p>\u6bd4\u5982\uff0c<a href=\"https:\/\/github.com\/forkingdog\/ProtocolKit\">ProtocolKit<\/a>\u5de5\u7a0b\u4e2d\uff0c\u4f5c\u8005\u901a\u8fc7\u5b8f\u5b9a\u4e49@defs\u5c06Protocol\u63a5\u53e3\u5de7\u5999\u7684\u5b9e\u73b0\u5728.h\u6587\u4ef6\u4e2d\uff0c\u4ee3\u7801\u7b80\u4ecb\u660e\u4e86\uff0c\u53c8\u4e0d\u5931\u529f\u80fd\u5b8c\u6574\u6027\u3002\u5f53\u7136\uff0cRN\u5de5\u7a0b\u4e2d\uff0cRCT_NOT_IMPLEMENTED\u5b8f\u4e5f\u6709\u76f8\u4f3c\u4f5c\u7528\uff0c\u5b9e\u9645\u9879\u76ee\u4e2d\u5404\u4f4d\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\u901a\u8fc7\u5b8f\u5b9a\u4e49\u5b9e\u73b0\u4e00\u4e9b\u5e38\u7528\u529f\u80fd\u6a21\u5757<\/p>\n<p>\u5173\u4e8eiOS\u5b8f\u5b9a\u4e49\u7684\u6587\u7ae0\u6709\u5f88\u591a\uff0c\u5728\u6b64\u63a8\u8350\u4e24\u7bc7\u975e\u5e38\u4e0d\u9519\u7684\u6587\u7ae0\uff1a<a href=\"http:\/\/www.cocoachina.com\/industry\/20140621\/8905.html\">RAC\u4e2d\u5fc5\u987b\u8981\u77e5\u9053\u7684\u5b8f<\/a>\u3001<a href=\"http:\/\/liuyanwei.jumppo.com\/2015\/09\/20\/ios-macro.html\">ios\u5b8f\u7684\u4f7f\u7528\u548c\u6280\u5de7<\/a><\/p>\n<h2>\u73af\u5883\u53d8\u91cf<\/h2>\n<p>iOS\u5f00\u53d1\u4e2d\uff0c\u5404\u4f4d\u5bf9#ifdef DEBUG\u5e94\u8be5\u975e\u5e38\u719f\u6089\uff0c\u901a\u8fc7\u5224\u65ad\u8be5\u6761\u4ef6\uff0c\u53ef\u4ee5\u533a\u522b\u5f53\u524d\u8fd0\u884c\u73af\u5883\u662fDebug\u73af\u5883\u8fd8\u662fRelease\u73af\u5883\u3002\u6bd4\u5982Release\u73af\u5883\u4e0b\u901a\u8fc7\u91cd\u5b9a\u4e49NSLog\u4ee5\u5c4f\u853d\u6240\u6709\u65e5\u5fd7\u8f93\u51fa<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">#ifdef DEBUG  \r\n#define NSLog(...) NSLog(__VA_ARGS__)  \r\n#else  \r\n#define NSLog(...) {}  \r\n#endif<\/pre>\n<p>\u8fdb\u4e00\u6b65\uff0c\u662f\u5426\u53ef\u4ee5\u8003\u8651\u53ea\u5728\u8054\u673a\u8c03\u8bd5\u73af\u5883\u4e0b\u8f93\u51fa\u65e5\u5fd7\uff1f\u6b64\u65f6\u5c31\u6d89\u53ca\u8054\u673a\u8c03\u8bd5\u73af\u5883\u7684\u5224\u65ad\uff0c\u73af\u5883\u53d8\u91cf\u6b63\u597d\u53ef\u4ee5\u89e3\u51b3\u8be5\u95ee\u9898<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone\" src=\"http:\/\/cdn.olinone.com\/EnVar.png\" alt=\"\" width=\"439\" height=\"227\" \/><\/p>\n<p>Xcode\u53ef\u4ee5\u5728\u4e0d\u540c\u73af\u5883\u4e0b\u81ea\u5b9a\u4e49\u73af\u5883\u53d8\u91cfEnvironment Variables\uff0c\u901a\u8fc7\u5728\u8fd0\u884c\u73af\u5883Run\u4e2d\u81ea\u5b9a\u4e49\u53d8\u91cfCI_USE_PACKAGER\uff0c\u6b64\u65f6\u4fbf\u53ef\u5728\u9879\u76ee\u4ee3\u7801\u4e2d\u901a\u8fc7getenv()\u51fd\u6570\u5224\u65ad\u5f53\u524d\u8fd0\u884c\u73af\u5883<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">if (getenv(\"CI_USE_PACKAGER\")) {\r\n  \/\/ to do...\r\n}<\/pre>\n<h2><strong>\u88ab\u5ffd\u7565\u7684\u786c\u952e\u76d8<\/strong><\/h2>\n<p>\u76f8\u8f83\u4e8e\u8f6f\u952e\u76d8\u6587\u5b57\u7b26\u53f7\u7684\u8f93\u5165\uff0c\u5bf9\u4e8eAPP\u6765\u8bf4\uff0c\u786c\u952e\u76d8\u7684\u5e94\u7528\u5f00\u53d1\u4f3c\u4e4e\u5f88\u5bb9\u6613\u88ab\u5ffd\u89c6\uff0c\u6bd5\u7adf\uff0c\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u786c\u952e\u76d8\u8f93\u5165\u53ea\u4f1a\u51fa\u73b0\u5728\u6a21\u62df\u5668\u73af\u5883\u4e0b<\/p>\n<p>iOS7\u4ee5\u540e\uff0c\u7cfb\u7edf\u5b9a\u4e49\u6709\u786c\u952e\u76d8\u54cd\u5e94\u4ea4\u4e92\u7c7bUIKeyCommand\uff0c\u901a\u8fc7UIKeyCommand\uff0cAPP\u80fd\u591f\u76d1\u542c\u786c\u952e\u76d8\u7684\u7279\u5b9a\u8f93\u5165\u54cd\u5e94\uff0c\u6bd4\u5982Command+D\u7b49\uff0c\u5f53\u7136\uff0c\u524d\u63d0\u662fAPP\u9700\u8981\u9996\u5148\u76d1\u542c\u8be5\u8f93\u5165\u547d\u4ee4<\/p>\n<p>UIKeyCommand\u7684\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u5f53\u9700\u8981\u5728\u7279\u5b9a\u573a\u666f\u89e6\u53d1\u67d0\u4e00\u4e8b\u4ef6\uff0c\u4f46\u53c8\u4e0d\u60f3\u5f71\u54cd\u754c\u9762\u663e\u793a\u7684\u65f6\u5019\uff0c\u4e0d\u59a8\u8bd5\u8bd5UIKeyCommand\uff0c\u5177\u4f53\u4f7f\u7528\u53ef\u4ee5\u770b\u770b\u8fd9\u7bc7<a href=\"http:\/\/nshipster.cn\/uikeycommand\/\">\u6587\u7ae0<\/a><\/p>\n<h2><strong>_cmd<\/strong><\/h2>\n<p>iOS\u5b98\u65b9\u6587\u6863\u4e2d\uff0c_cmd\u8868\u793a\u5f53\u524d\u65b9\u6cd5\u7684selector\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u4ee3\u7801\u6253\u5370\u8f93\u51fa\u5f53\u524d\u51fd\u6570\u540d<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">NSLog(@\"Current method: %@\", NSStringFromSelector(_cmd));\r\n<\/pre>\n<p>\u5f53\u7136\uff0c\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u8fd9\u6837\u4f7f\u7528<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">NSNumber *rootTag = objc_getAssociatedObject(self, _cmd) ?: @1;\r\nobjc_setAssociatedObject(self, _cmd, @(rootTag.integerValue + 10), OBJC_ASSOCIATION_RETAIN_NONATOMIC);<\/pre>\n<p>\u77a7\uff0c\u662f\u4e0d\u662f\u6709\u70b9\u610f\u601d\uff01<\/p>\n<h2><strong>kCFNull<\/strong><\/h2>\n<p>\u76f8\u5bf9\u4e8enil NSNull\u800c\u8a00\uff0ckCFNull\u7b14\u8005\u63a5\u89e6\u8f83\u5c11\uff0ckCFNull\u53ef\u4ee5\u7406\u89e3\u4e3aNSNull\u5355\u4f8b\u5bf9\u8c61<\/p>\n<pre class=\"lang:objc highlight:0 decode:true \">id null1 = (id)kCFNull;\r\nid null2 = [NSNull null];<\/pre>\n<p>\u6253\u5370\u5730\u5740<\/p>\n<pre class=\"lang:default decode:true \">null1=(NSNull *)0x10426eaf0\r\nnull2=(NSNull *)0x10426eaf0<\/pre>\n<p>\u4ece\u4e0a\u9762\u6d4b\u8bd5\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\u5b83\u4eec\u5176\u5b9e\u6307\u5411\u540c\u4e00\u5730\u5740\uff0c \u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a kCFNull === [NSNull null]<\/p>\n<h2>\u6587\u672c\u9634\u5f71NSShadow<\/h2>\n<p>APP\u5f00\u53d1\u4e2d\uff0c\u7a0b\u5e8f\u733f\u53ef\u80fd\u7ecf\u5e38\u9700\u8981\u5728\u56fe\u7247\u6216\u89c6\u9891\u4e0a\u663e\u793a\u6587\u5b57\uff0c\u7531\u4e8e\u80cc\u666f\u989c\u8272\u8ddf\u6587\u5b57\u989c\u8272\u76f8\u8fd1\uff0c\u5bfc\u81f4\u6587\u5b57\u770b\u4e0d\u6e05\uff0c\u6bd4\u5982\u65f6\u4e0b\u706b\u70ed\u7684\u76f4\u64ad\u5f39\u5e55\u663e\u793a\uff0c\u4e3a\u4e86\u786e\u4fdd\u6587\u5b57\u663e\u793a\u6e05\u6670\uff0c\u5f00\u53d1\u8005\u4e00\u822c\u4f1a\u914d\u4e0a\u9634\u5f71\u6216\u8005\u6587\u5b57\u63cf\u8fb9<\/p>\n<p>\u7ed9\u6587\u672c\u6dfb\u52a0\u9634\u5f71\u63cf\u8fb9\uff0c\u7cfb\u7edf\u63d0\u4f9b\u6709NSShadow\u7c7b\uff0c\u53ef\u4ee5\u8fd9\u6837\u4f7f\u7528<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">NSShadow *shadow = [NSShadow new];\r\nshadow.shadowOffset = CGSizeZero;\r\nshadow.shadowBlurRadius = 5.0f;\r\nshadow.shadowColor = [UIColor colorWithWhite:0.0f alpha:0.3f];\r\nNSAttributedString *attString = [[NSAttributedString alloc] initWithString:@\"www.olinone.com\" attributes:@{NSShadowAttributeName: shadow, NSForegroundColorAttributeName: [UIColor whiteColor]}];\r\nlbl.attributedText = attString;<\/pre>\n<p>\u5b9e\u9645\u6548\u679c\u662f\u8fd9\u6837\u7684\uff0cshadowBlurRadius\u503c\u8d8a\u5c0f\uff0c\u6587\u672c\u63cf\u8fb9\u8d8a\u6e05\u6670<\/p>\n<p><img decoding=\"async\" class=\"alignnone\" src=\"http:\/\/cdn.olinone.com\/NSShadow3.png\" alt=\"\" width=\"180\" \/><\/p>\n<h2><strong>\u4e3b\u7ebf\u7a0b\u5224\u65ad<\/strong><\/h2>\n<p>\u5224\u65ad\u5f53\u524d\u6267\u884c\u7ebf\u7a0b\u662f\u5426\u4e3a\u4e3b\u7ebf\u7a0b\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u6bd4\u5982<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">[NSThread isMainThread]\r\npthread_main_np<\/pre>\n<p>\u5728RN\u4e2d\uff0c\u5b83\u662f\u8fd9\u6837\u7684<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">BOOL RCTIsMainQueue() {\r\n  static void *mainQueueKey = &amp;mainQueueKey;\r\n  static dispatch_once_t onceToken;\r\n  dispatch_once(&amp;onceToken, ^{\r\n    dispatch_queue_set_specific(dispatch_get_main_queue(), mainQueueKey, mainQueueKey, NULL);\r\n  });\r\n  return dispatch_get_specific(mainQueueKey) == mainQueueKey;\r\n}<\/pre>\n<p>\u5f53\u7136\uff0c\u7531\u4e8e\u65e0\u6cd5\u67e5\u770bNSThread\u5185\u90e8\u5b9e\u73b0\u673a\u5236\uff0c\u6682\u65f6\u65e0\u6cd5\u4e86\u89e3\u5b70\u4f18\u5b70\u52a3\uff0c\u4e0d\u8fc7\uff0c[NSThread isMainThread]\u8c8c\u4f3c\u8db3\u77e3\uff01<\/p>\n<h2><b>volatile\u4e0d\u7b80\u5355<\/b><\/h2>\n<p>\u5728<a href=\"http:\/\/baike.baidu.com\/link?url=Dw71vreyT3rJfhw7EMr37t825T_amRt-qYiDmri2Y1vLvxd3jvVaEtMg_SQeA57zPMt1gh1dQLBCSVCHyYxUma\">\u767e\u79d1<\/a>\u4e2d\uff0c\u662f\u8fd9\u6837\u63cf\u8ff0\u5b83\u7684\uff1a\u5c31\u50cf\u5927\u5bb6\u66f4\u719f\u6089\u7684const\u4e00\u6837\uff0cvolatile\u662f\u4e00\u4e2a\u7c7b\u578b\u4fee\u9970\u7b26\uff0c\u5b83\u662f\u88ab\u8bbe\u8ba1\u7528\u6765\u4fee\u9970\u88ab\u4e0d\u540c\u7ebf\u7a0b\u8bbf\u95ee\u548c\u4fee\u6539\u7684\u53d8\u91cf\u3002\u4f5c\u4e3a\u6307\u4ee4\u5173\u952e\u5b57\uff0c\u786e\u4fdd\u672c\u6761\u6307\u4ee4\u4e0d\u4f1a\u56e0\u7f16\u8bd1\u5668\u7684\u4f18\u5316\u800c\u7701\u7565\uff0c\u4e14\u8981\u6c42\u6bcf\u6b21\u76f4\u63a5\u8bfb\u503c<\/p>\n<p>\u7b80\u5355\u8bf4\uff0c\u88abvolatile\u4fee\u9970\u7684\u53d8\u91cf\u662f\u591a\u7ebf\u7a0b\u5b89\u5168\u7684\uff0c\u5176\u6b21\uff0c\u4e0d\u4f1a\u56e0\u4e3a\u7f16\u8bd1\u5668\u4f18\u5316\u5bfc\u81f4\u8bfb\u503c\u51fa\u9519\u3002\u5173\u4e8e\u7f16\u8bd1\u5668\u7f16\u8bd1\u4f18\u5316\u53ef\u4ee5\u770b\u770b\u8fd9\u7bc7<a href=\"http:\/\/blog.csdn.net\/callinghl\/article\/details\/45742757\">\u6587\u7ae0<\/a><\/p>\n<p>iOS\u5f00\u53d1\u4e2d\u786e\u4fdd\u591a\u7ebf\u7a0b\u5b89\u5168\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u539f\u5b50\u64cd\u4f5c\u3001\u7ebf\u7a0b\u9501\u3001\u5355\u7ebf\u7a0b\u6267\u884c\u7b49\u7b49\uff0c\u672c\u4eba\u4e5f\u5199\u8fc7\u76f8\u5173\u6587\u7ae0<a href=\"http:\/\/www.olinone.com\/?p=250\">iOS\u5f00\u53d1\u591a\u7ebf\u7a0b\u540c\u6b65<\/a><\/p>\n<p>\u5728RN\u4e2d\uff0c\u901a\u8fc7volatile\u4fee\u9970\u7b26\uff0c\u5de7\u5999\u5b9e\u73b0\u4e86\u591a\u7ebf\u7a0b\u53d6\u6d88\u64cd\u4f5c<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">__block volatile uint32_t cancelled = 0;\r\nif (!cancelled) {\r\n   \/\/ to do...\r\n}\r\nOSAtomicOr32Barrier(1, &amp;cancelled);<\/pre>\n<p>\u901a\u8fc7\u539f\u5b50\u6027\u64cd\u4f5c\u8bbf\u95ee\u88abvolatile\u4fee\u9970\u7684cancelled\u5bf9\u8c61\u5373\u53ef\u4fdd\u969c\u51fd\u6570\u53ea\u6267\u884c\u4e00\u6b21\u3002\u60f3\u60f3\u5927\u5bb6\u719f\u6089\u7684\u5355\u4f8bdispatch_once_t\uff0c\u73b0\u5728\u8ba9\u4f60\u8bbe\u8ba1\u5355\u4f8b\u5bf9\u8c61\uff0c\u4f60\u53c8\u4f1a\u5982\u4f55\u8bbe\u8ba1\u4e86\uff1f<\/p>\n<pre class=\"lang:default highlight:0 decode:true\">+ (instancetype)sharedInstance {\r\n  static RCTWebSocketManager *sharedInstance = nil;\r\n  static dispatch_once_t onceToken;\r\n  dispatch_once(&amp;onceToken, ^{\r\n    sharedInstance = [self new];\r\n  });\r\n  return sharedInstance;\r\n}<\/pre>\n<h2>\u7ed3\u6784\u4f53Struct<\/h2>\n<p>\u8bf4\u8d77Struct\uff0c\u4e0d\u77e5\u5404\u4f4d\u5bf9\u5b83\u5370\u8c61\u5982\u4f55\uff1f\u5927\u5b66C\u8bfe\u672c\u4e2d\u5b66\u8fc7\uff1fNSObject\u7c7bclass\u539f\u578b\u8c8c\u4f3c\u6709\u8bb2\uff1f<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">struct iOSDev {\r\n    NSString *nickName;\r\n};<\/pre>\n<p>OC\u4e2d\u4e00\u4e2a\u7b80\u5355\u7684\u7ed3\u6784\u4f53\uff0c\u5728Swift\u4e2d\uff0cStruct\u4e5f\u53ef\u4ee5\u8fd9\u6837\u5199<\/p>\n<pre class=\"lang:swift highlight:0 decode:true \">struct iOSDev {\r\n    var nickName : String\r\n    func getBusinessCard() -&gt; String {\r\n        return \"\\(nickName)\uff0c\u5e7d\u9ed8\u7684iOS\u5f00\u53d1\u8005\uff01\"\r\n    }\r\n};\r\n\r\nlet iOSOlinone = iOSDev(nickName: \"olinone\")\r\nprint(iOSOlinone.getBusinessCard())<\/pre>\n<p>getBusinessCard\u4e3a\u7ed3\u6784\u4f53\u51fd\u6570\uff0c\u662f\u4e0d\u662f\u611f\u89c9\u5f88\u65b9\u4fbf\uff01\u5176\u5b9eOC\u4e2d\u4e5f\u53ef\u4ee5\u8fd9\u6837\u5199<\/p>\n<pre class=\"lang:objc highlight:0 decode:true\">struct iOSDev {\r\n    NSString *nickName;\r\n    NSString *getBusinessCard() {\r\n        return [NSString stringWithFormat:@\"%@\uff0c\u5e7d\u9ed8\u7684iOS\u5f00\u53d1\u8005\uff01\", nickName];\r\n    }\r\n};\r\n\r\niOSDev iosDev = iOSDev{@\"olinone\"};\r\nNSLog(@\"%@\", iosDev.getBusinessCard());<\/pre>\n<p>\u5f53\u7136\uff0c\u4e3aStruct\u6dfb\u52a0\u51fd\u6570\u5e76\u4e0d\u662fC\u8bed\u8a00\u7279\u6027\uff0c\u800c\u662fC++\u7279\u6027\uff0c\u56e0\u6b64\uff0c\u4e3a\u4e86\u7f16\u8bd1\u901a\u8fc7\uff0c\u4f60\u9700\u8981\u5c06.m\u6587\u4ef6\u4fee\u6539\u6210.mm\u6587\u4ef6<\/p>\n<p>Struct\u6709\u5176\u4f7f\u7528\u7684\u7279\u6b8a\u573a\u666f\uff0c\u76f8\u8f83\u4e8eClass\uff0c\u5408\u7406\u7684\u4f7f\u7528Struct\u53ef\u4ee5\u4f7f\u4ee3\u7801\u66f4\u52a0\u6574\u6d01\u3002\u540c\u65f6\uff0c\u4e3a\u4e86\u9002\u5e94Swift\u4e2dStruct\u5f3a\u5927\u7279\u6027\uff0c\u53ef\u4ee5\u8bd5\u7740\u5728OC\u9879\u76ee\u4e2d\u5c1d\u8bd5Struct<\/p>\n<p>\u6700\u540e\uff0c\u7ed9\u5927\u5bb6\u6765\u4e2a\u6bb5\u5b50\u5427\uff1a<\/p>\n<address><em>\u8bdd\u8bf4\u4e00\u7f8e\u5973\u8981\u5728\u4e24\u4e2a\u7537\u4eba\u4e4b\u95f4\u505a\u9009\u62e9\uff0c\u4e00\u4e2a\u5e74\u7eaa\u5927\uff0c\u957f\u7684\u4e11\uff0c\u662f\u4e2a\u5343\u4e07\u5bcc\u7fc1\uff0c\u53e6\u4e00\u4e2a\u5e74\u8f7b\uff0c\u5e05\u6c14\uff0ciOS\u5f00\u53d1\u7a0b\u5e8f\u733f\u3002 \u5979\u5bf9\u4ed6\u4eec\u8bf4\uff0c\u6211\u4f1a\u7ed9\u4f60\u4eec\u4e00\u4eba\u4e00\u5f20\u7eb8\u6761\uff0c\u5199\u7740\u6211\u613f\u610f\u7684\u90a3\u5f20\u5c31\u662f\u6211\u7684\u9009\u62e9\u3002 \u5bcc\u7fc1\u6253\u5f00\u7eb8\u6761\uff0c\u770b\u89c1\u4e0a\u9762\u5199\u7740\u6211\u613f\u610f\uff0c\u4e8e\u662f\u6402\u7740\u5979\uff0c\u5750\u4e0a\u8c6a\u8f66\u9ad8\u5174\u7684\u8d70\u4e86\u3002 \u5e74\u8f7b\u7684\u5c0f\u4f19\u5f88\u4f24\u5fc3\uff0c\u6253\u5f00\u7eb8\u6761\u770b\u89c1\u4e0a\u9762\u5199\u7740\uff1a\u201c\u7b49\u6211\u4e00\u4e2a\u6708~\u201d \u00a0^o^<\/em><\/address>\n<address>\u00a0<\/address>\n<hr \/>\n<p><em>\u5199\u5728\u6587\u540e\uff1a<\/em><\/p>\n<p><em>\u6709\u4e9b\u7ae5\u978b\u53ef\u80fd\u7ecf\u5e38\u4f1a\u95ee\u4e00\u4e2a\u95ee\u9898\uff0c\u611f\u89c9\u81ea\u5df1\u6280\u672f\u9047\u5230\u74f6\u9888\uff0c\u5982\u4f55\u624d\u80fd\u8fdb\u4e00\u6b65\u63d0\u5347\u81ea\u5df1\u6280\u672f\u80fd\u529b\uff1f\u5176\u5b9e\u8fd9\u4e2a\u95ee\u9898\uff0c\u672c\u4eba\u4e5f\u662f\u6478\u77f3\u5934\u8fc7\u6cb3\uff0c\u4e0d\u8fc7\u6709\u4e00\u70b9\u53ef\u4ee5\u786e\u5b9a\uff0c\u90a3\u5c31\u662f\u4fdd\u6301\u4e00\u9897\u4e0d\u65ad\u8fdb\u53d6\u7684\u5fc3\u5427<\/em><\/p>\n<p><em>\u65b0\u5efa\u4e86\u4e00\u4e2aiOS\u5f00\u53d1QQ\u4ea4\u6d41\u7fa4\uff08\u9996\u9875\u53f3\u4e0a\u89d2\u5165\u7fa4\uff09\uff0c\u6b22\u8fce\u5e7f\u5927iOS\u5f00\u53d1\u670b\u53cb\u4e00\u540c\u4ea4\u6d41\u5b66\u4e60\u3002\u5f53\u7136<em>\uff0c\u4f60\u4e5f\u53ef\u4ee5Follow\u672c\u4eba<a href=\"https:\/\/github.com\/panghaijiao\">GitHub<\/a>\uff0c\u6216\u8005\u5173\u6ce8\u6211\u7684<a href=\"http:\/\/weibo.com\/u\/5474633407\">\u65b0\u6d6a\u5fae\u535a<\/a>\uff0c\u611f\u8c22\u4f60\u7684\u6765\u8bbf\uff0c\u4e0b\u671f\u518d\u89c1\uff01<\/em><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\uff1ahttp:\/\/www.olinone.com\/ ReactNative\u662fFacebook\u5f00\u6e90\u7684\u2026 <span class=\"read-more\"><a href=\"http:\/\/www.olinone.com\/?p=590\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts\/590"}],"collection":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=590"}],"version-history":[{"count":47,"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts\/590\/revisions"}],"predecessor-version":[{"id":788,"href":"http:\/\/www.olinone.com\/index.php?rest_route=\/wp\/v2\/posts\/590\/revisions\/788"}],"wp:attachment":[{"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=590"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.olinone.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}