{"id":4026,"date":"2016-07-21T20:19:07","date_gmt":"2016-07-21T12:19:07","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4026"},"modified":"2016-07-21T22:13:17","modified_gmt":"2016-07-21T14:13:17","slug":"%e6%95%99%e7%a8%8b-%e6%89%8b%e5%8a%a8%e5%b0%86%e5%be%ae%e4%bf%a1%e5%bc%80%e6%94%be%e5%b9%b3%e5%8f%b0%e7%9a%84-ios-sdk-%e8%bd%ac%e6%8d%a2%e5%88%b0-delphi-%e6%8e%a5%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4026","title":{"rendered":"[\u6559\u7a0b] \u624b\u52a8\u5c06\u5fae\u4fe1\u5f00\u653e\u5e73\u53f0\u7684 iOS SDK \u8f6c\u6362\u5230 Delphi \u63a5\u53e3"},"content":{"rendered":"<p>1\u3001\u4e0b\u8f7d SDK\uff0c\u5f97\u5230\u76f8\u5e94\u7684\u5934\u6587\u4ef6\u548c\u9759\u6001\u94fe\u63a5\u5e93 .a\uff1b<\/p>\n<p>2\u3001\u6253\u5f00 *.h \uff0c\u7136\u540e\u6328\u4e2a\u7ffb\u8bd1\uff0c\u7ffb\u8bd1\u7684\u89c4\u5219\uff1a<\/p>\n<ul>\n<li>enum \u662f\u679a\u4e3e\u7c7b\u578b\uff0c\u76f4\u63a5\u7ffb\u8bd1\u6210 delphi \u5bf9\u5e94\u7684\u679a\u4e3e\u7c7b\u578b\u5c31\u53ef\u4ee5\u4e86<\/li>\n<li>NSENUM \u76f4\u63a5\u7ffb\u8bd1\u6210\u5bf9\u5e94\u7684\u5e38\u91cf\u5b9a\u4e49<\/li>\n<li>@interface \u58f0\u660e\u7684\u662f\u4e00\u4e2a\u63a5\u53e3\uff0c\u5728 Delphi \u4e2d\u9700\u8981\u505a\u7b80\u5355\u7684\u5bf9\u5e94\n<ul>\n<li>2.1\u3001\u58f0\u660e\u4e00\u4e2a\u5bf9\u5e94\u7684\u7c7b\u7684\u7c7b\u578b\uff0c\u5982\u679c interface \u7ee7\u627f\u81ea NSObject\uff0c\u90a3\u4e48\u8fd9\u4e2a\u7c7b\u578b\u7ee7\u627f\u81ea NSObjectClass\u3002\u6309 Delphi \u7684\u4e60\u60ef\uff0c\u5047\u8bbe @interface \u7684\u539f\u59cb\u540d\u4e3a A\uff0c\u5219\u58f0\u660e\u7684\u7c7b\u578b\u4e3a AClass\uff0c\u7ee7\u627f\u81ea\u00a0NSObjectClass\u3002\u7136\u540e\u6309\u4e0b Ctrl+Shift+G \u751f\u6210\u4e00\u4e2a\u552f\u4e00\u7684GUID\uff0c\u8fd9\u4e2a\u503c\u662f\u7ed9 Delphi \u81ea\u5df1\u73a9\u7684\uff0c\u6240\u4ee5\u4e0e\u539f\u59cb\u7684 interface \u65e0\u5173\uff0c\u81ea\u5df1\u751f\u6210\u5c31\u597d\u3002<\/li>\n<li>2.2\u3001\u58f0\u660e\u4e00\u4e2a\u5bf9\u5e94\u7684\u63a5\u53e3\u7c7b\u578b\uff0c\u8fd9\u4e2a\u7c7b\u578b\u540d\u548c @interface \u58f0\u660e\u7684\u7c7b\u578b\u540d\u4e00\u81f4\uff0c\u4e5f\u7ee7\u627f\u81ea\u540c\u6837\u7684\u5bf9\u8c61\uff0c\u5982NSObject\u3002\u540c\u4e0a\u751f\u6210\u4e00\u4e2a\u552f\u4e00\u7684\u63a5\u53e3 GUID\u3002<\/li>\n<li>2.3\u3001\u5c06 @interface \u00a0end \u4e4b\u524d\u7684\u6210\u5458\uff0c+ \u540e\u9762\u8ddf\u7684\u51fd\u6570\uff0c\u653e\u5230 2.1 \u4e2d\u5b9a\u4e49\u7c7b\u7684\u7c7b\u578b\u63a5\u53e3\u4e2d\uff0c- \u540e\u9762\u8ddf\u7684\u51fd\u6570\uff0c\u653e\u5230 2.2 \u4e2d\u5b9a\u4e49\u7684\u63a5\u53e3\u7c7b\u578b\u4e2d\uff0c@property \u540e\u9762\u7684\u6210\u5458\uff0c\u653e\u5230 2.2 \u5b9a\u4e49\u7684\u63a5\u53e3\u4e2d\u3002<\/li>\n<li>2.4\u3001@property \u7684\u6210\u5458\u653e\u7684\u65f6\u5019\uff0c\u8bf7\u6309\u4e0b\u9762\u7684\u89c4\u5219\u5904\u7406\uff1a<br \/>\n\uff081\uff09\u3001\u5982\u679c\u6ca1\u6709\u7279\u522b\u8bf4\u660e\uff0c\u5219\u5bf9\u5e94\u4e24\u4e2a\u51fd\u6570\uff0c\u4e00\u4e2a\u51fd\u6570\u548c\u5c5e\u6027\u7684\u540d\u79f0\u4e00\u81f4\uff0c\u53e6\u4e00\u4e2a\u51fd\u6570\u4e3a set+\u9996\u5b57\u6bcd\u5927\u5199\u7684\u5c5e\u6027\u540d\u79f0\u3002<br \/>\n\uff082\uff09\u3001\u5982\u679c\u6307\u5b9a\u4e86 getter \u548c setter \uff0c\u5219 getter \u5bf9\u5e94\u7684\u662f\u5c5e\u6027\u8bfb\u51fd\u6570\u7684\u540d\u79f0\uff0c setter \u5bf9\u5e94\u7684\u662f\u5c5e\u6027\u5199\u51fd\u6570\u7684\u540d\u79f0\u3002<br \/>\n\uff083\uff09\u3001\u5982\u679c\u6307\u5b9a\u7684 readonly\uff0c\u5219\u53ea\u6709\u8bfb\u51fd\u6570\uff0c\u6ca1\u6709\u5199\u51fd\u6570\u3002<\/li>\n<li>2.5\u3001\u63a5\u53e3\u4e2d\u7684\u6240\u6709\u51fd\u6570\u7684\u8c03\u7528\u89c4\u5219\u5168\u90e8\u4e3a cdecl\u3002<\/li>\n<li>2.6\u3001\u5728\u6bcf\u4e2a\u63a5\u53e3\u5b9e\u73b0\u5b8c\u6210\u540e\uff0c\u52a0\u5165 T+\u63a5\u53e3\u7c7b\u578b\u540d=class(TOCGenericImport&lt;2.1\u4e2d\u7684\u7c7b\u7684\u7c7b\u578b\u540d,2.2\u4e2d\u7684\u63a5\u53e3\u7c7b\u578b\u540d&gt;) end; \u8fd9\u4e00\u884c\u5b9a\u4e49\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u8ba9 Delphi \u81ea\u52a8\u5bfc\u5165\u5bf9\u5e94\u7684\u7c7b\u578b\u63a5\u53e3\u3002<\/li>\n<li>2.7\u3001\u5982\u679c .h \u6587\u4ef6\u4e2d\uff0c\u53d8\u91cf\u6216\u51fd\u6570\u540d\u4f7f\u7528\u4e86 Delphi \u4fdd\u7559\u7684\u5173\u952e\u5b57\uff0c\u5219\u5728\u524d\u9762\u52a0\u4e0a \u201c&amp;\u201d \u7b26\u53f7\uff0c\u5982 type \u8f6c\u6362\u4e3a &amp;type \u5373\u53ef\u3002<\/li>\n<li>2.8\u3001@protocol \u7684\u4e1c\u897f\u662f\u7ee7\u627f\u81ea IObjectiveC \u7684\u63a5\u53e3\uff0c\u5b83\u6ca1\u6709 2.2 \u7c7b\u4f3c\u7684\u90e8\u5206\u3002<\/li>\n<li>2.9\u3001\u51fd\u6570\u58f0\u660e\u4e2d\u5e26\u6709 XXX: \u53c2\u65701\u7c7b\u578b \u53c2\u65701 YYY: \u53c2\u65702\u7c7b\u578b \u53c2\u65702 \u8fd9\u6837\u5b50\u7684\uff0c\u9700\u8981\u7528[MethodName(&#8216;XXX:YYY:&#8217;)] \u8fd9\u6837\u5904\u7406<\/li>\n<\/ul>\n<\/li>\n<li>\u6ce8\u610f\u8981\u5f15\u5165\u76f8\u5173\u7684\u5355\u5143\uff0c\u6700\u57fa\u672c\u7684\u5355\u5143\u9700\u8981\u5f15\u5165\uff1aSystem.Classes, iOSapi.Foundation, Macapi.ObjectiveC\u3002\u5b9e\u9645\u5fae\u4fe1\u63a5\u53e3\u8fd8\u9700\u8981\u5f15\u5165 \u00a0iOSapi.UIKit \u5355\u5143\uff0c\u5177\u4f53\u7ffb\u8bd1\u5c31\u6839\u636e\u9700\u8981\u5f15\u5165\u3002<\/li>\n<\/ul>\n<p>\u5982\u6211\u4eec\u7ffb\u8bd1\u4e00\u6bb5\u7b80\u5355\u7684 Object C \u63a5\u53e3\uff1a<\/p>\n<pre class=\"lang:objc decode:true\">\/*! @brief \u8be5\u7c7b\u4e3a\u5fae\u4fe1\u7ec8\u7aefSDK\u6240\u6709\u8bf7\u6c42\u7c7b\u7684\u57fa\u7c7b\r\n *\r\n *\/\r\n@interface BaseReq : NSObject\r\n\r\n\/** \u8bf7\u6c42\u7c7b\u578b *\/\r\n@property (nonatomic, assign) int type;\r\n\/** \u7531\u7528\u6237\u5fae\u4fe1\u53f7\u548cAppID\u7ec4\u6210\u7684\u552f\u4e00\u6807\u8bc6\uff0c\u53d1\u9001\u8bf7\u6c42\u65f6\u7b2c\u4e09\u65b9\u7a0b\u5e8f\u5fc5\u987b\u586b\u5199\uff0c\u7528\u4e8e\u6821\u9a8c\u5fae\u4fe1\u7528\u6237\u662f\u5426\u6362\u53f7\u767b\u5f55*\/\r\n@property (nonatomic, retain) NSString* openID;\r\n\r\n@end<\/pre>\n<p>Delphi \u7ffb\u8bd1\u540e\u7ed3\u679c\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">  BaseReqClass = interface(NSObjectClass)\r\n    ['{06A21E95-7159-4F90-B535-9ED96E1DF375}']\r\n  end;\r\n\r\n  BaseReq = interface(NSObject)\r\n    ['{C36129E7-ABB1-47AA-A3B9-D70865DBAE24}']\r\n    { \u8bf7\u6c42\u7c7b\u578b }\r\n    function &amp;type: Integer; cdecl;\r\n    procedure setType(value: Integer); cdecl;\r\n    { \u7531\u7528\u6237\u5fae\u4fe1\u53f7\u548cAppID\u7ec4\u6210\u7684\u552f\u4e00\u6807\u8bc6\uff0c\u53d1\u9001\u8bf7\u6c42\u65f6\u7b2c\u4e09\u65b9\u7a0b\u5e8f\u5fc5\u987b\u586b\u5199\uff0c\u7528\u4e8e\u6821\u9a8c\u5fae\u4fe1\u7528\u6237\u662f\u5426\u6362\u53f7\u767b\u5f55 }\r\n    function openID: NSString; cdecl;\r\n    procedure setOpenID(value: NSString); cdecl;\r\n  end;\r\n\r\n  TBaseReq = class(TOCGenericImport&lt;BaseReqClass, BaseReq&gt;)\r\n  end;<\/pre>\n<p>\u7136\u540e\u5b9e\u9645\u4f7f\u7528\u65f6\uff0c\u6309\u7167 \u00a0Delphi \u7684\u89c4\u5219\u521b\u5efa TBaseReq \u76f8\u5173\u6210\u5458\u65b9\u6cd5\u53ca\u5c5e\u6027\u5c31\u597d\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4e0b\u8f7d SDK\uff0c\u5f97\u5230\u76f8\u5e94\u7684\u5934\u6587\u4ef6\u548c\u9759\u6001 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[69,8,603],"tags":[601,650,74,47],"class_list":["post-4026","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-603","tag-object-c","tag-650","tag-74","tag-47"],"views":8469,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4026","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4026"}],"version-history":[{"count":4,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4026\/revisions"}],"predecessor-version":[{"id":4032,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4026\/revisions\/4032"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}