video: twitter in plain english
聽
聽
twitter is a service for friends, family, and co鈥搘orkers to聽communicate and stay connected through the exchange of quick, frequent answers to one simple question: what are you doing?
聽
聽
聽
鍩烘湰姒傚康
銆€銆€twitter 鏄嵆鏃朵俊鎭殑涓€涓彉绉嶏紝瀹冨厑璁哥敤鎴峰皢鑷繁鐨勬渶鏂板姩鎬佸拰鎯虫硶浠ョ煭淇℃伅鐨勫舰寮忓彂閫佺粰鎵嬫満鍜屼釜鎬у寲缃戠珯缇わ紝鑰屼笉浠呬粎鏄彂閫佺粰涓汉銆?006骞达紝鍗氬鎶€鏈厛椹眀logger 鍒涘浜哄焹鏂嚶峰▉寤夊鏂?evan williams)鍒涘缓鐨勬柊鍏村叕鍙窸bvious鎺ㄥ嚭浜員witter鏈嶅姟銆傚湪鏈€鍒濋樁娈碉紝杩欓」鏈嶅姟鍙槸鐢ㄤ簬鍚戝ソ鍙嬬殑鎵嬫満鍙戦€佹枃鏈俊鎭€?006骞村簳锛孫bvious瀵规湇鍔¤繘琛屼簡鍗囩骇锛岀敤鎴锋棤闇€杈撳叆鑷繁鐨勬墜鏈哄彿鐮侊紝鑰屽彲浠ラ€氳繃鍗虫椂淇℃伅鏈嶅姟鍜屼釜鎬у寲twitter缃戠珯鎺ユ敹鍜屽彂閫佷俊鎭€?
銆€銆€鐩墠鍥藉唴涔熷嚭鐜颁簡璁稿绫讳技twitter鐨勭綉绔欙紝姣斿璇磋 銆侀キ鍚?銆佸徑姝瓑绛夊崄浣欏缃戠珯銆傚叾涓昏浼樺娍鏄涓枃鐨勮壇濂芥敮鎸侊紝浠ュ強涓庡浗鍐呯щ鍔ㄩ€氳鏈嶅姟鍟嗐€佸嵆鏃惰亰澶╁伐鍏风殑缁戝畾銆?
銆€銆€灏辩洰鍓嶈€岃█锛孴witter瀛樺湪鐨勬渶澶ч棶棰樻槸淇℃伅娉涙互銆傝鎻愬崌鑷韩鐨勪环鍊硷紝twitter搴斿綋鍔犲叆杩囨护鍔熻兘銆傛兂璞′竴涓嬶紝濡傛灉鐢ㄦ埛鍙互閫夋嫨鎬у湴鍚戠壒瀹氱粍缇ゅ彂閫佷俊鎭紝鑰屼笖杩樺彲浠ユ牴鎹壒瀹氫富棰樿繃婊ゆ帴鏀朵汉锛孴witter宸ュ叿灏嗕細鏇村揩鍦版櫘鍙娿€俆witter涔熻浼氫簬浠婂勾鍐呮秷澶憋紝浣嗘棤璁哄浣曪紝瀹冭儗鍚庣殑鍒涙剰灏嗕細寤剁画涓嬪幓锛屽苟浜х敓鏇撮珮鏁堢殑搴旂敤銆?
銆€銆€twitter鏄竴涓彲璁╀綘鎾姤鐭秷鎭粰浣犵殑鏈嬪弸鎴栤€渇ollowers锛堣窡闅忚€咃級鈥濈殑涓€涓湪绾挎湇鍔★紝瀹冧篃鍚屾牱鍙厑璁镐綘鎸囧畾鍝釜浣犳兂璺熼殢鐨凾witter鐢ㄦ埛锛岃繖鏍蜂綘鍙互鍦ㄤ竴涓〉闈笂灏辫兘璇诲彇浠栦滑鍙戝竷鐨勪俊鎭€?
銆€銆€twitter鏈€鍒濊鍒掓槸鍦ㄦ墜鏈轰笂浣跨敤锛屽苟涓斾笌鐢佃剳涓€鏍锋柟渚夸娇鐢ㄣ€傛墍鏈夌殑twitter娑堟伅閮借闄愬埗鍦?40涓瓧绗︿箣鍐咃紝鍥犳姣忎竴鏉℃秷鎭兘鍙互浣滀负涓€鏉ms鐭秷鎭彂閫併€傝繖灏辨槸twitter杩蜂汉涔嬪鐨勪竴閮ㄥ垎銆?
銆€銆€twitter瀵逛簬缁勭粐涓ュ瘑鐨勫皬缁勬潵璇存槸闈炲父鏈夌敤鐨勶紙灏界twitter涓婁篃鍚屾牱瀛樺ぇ鐫€鏁伴噺鐩稿綋澶х殑涔屽悎涔嬩紬锛夈€傚亣濡備綘璺熼殢浣犵殑鏈嬪弸锛屽苟涓斾粬浠繕璺熼殢鐫€鍙﹀鐨勪汉锛屼綘灏卞彲浠ヨ繘琛屽揩閫熸矡閫氥€備粠姒傚康涓婃潵鐪嬶紝twitter涓嶥odgeball闈炲父鐨勭被浼硷紝浣嗗畠鏇村鏄撲娇鐢ㄣ€?
銆€銆€鍋囧浣犲湪twitter涓緭鍏ヤ竴涓」鐩紝瀹冧滑鍙互鏄鏈夌殑锛屽彧鏈夊綋浣犵殑鏈嬪弸鑾峰緱浣犵殑鍏佽鎵嶈兘鏌ョ湅锛屾垨鑰呬篃鍙互鏄叕寮€鐨勶紝涔熷氨鏄鎵€鏈夌煡閬撲綘twitter id鐨勪汉閮藉彲浠ヨ鍙栨垨璁㈤槄浣犲彂甯冪殑娑堟伅銆?
銆€銆€鍙﹀杩樻湁寰堥噸瑕佺殑涓€鐐瑰氨鏄紝twitter鏄畬鍏ㄥ厤璐圭殑銆?/p>
聽
濡備綍浣跨敤
銆€銆€杩涘叆twitter 鐐瑰嚮鈥淛oin for free鈥濄€傛渶濂芥槸鍒╃敤浣犵殑鐪熷疄濮撳悕鎴栧父鐢↖d鏉ユ敞鍐岋紝鍚﹀垯浣犵殑鏈嬪弸鏃犳硶瀹规槗鐨勬壘鍒颁綘锛屽彟澶栦笂浼犱竴涓収鐗囧悓鏍峰浣犳湁鎵€甯姪銆傞渶娉ㄦ剰鐨勬槸锛屽亣濡備綘閫夋嫨鈥淧rotect my updates鈥濋€夐」鐨勮瘽锛屽叾浠栦汉灏辨棤娉曞湪娌℃湁鍙栧緱浣犺璇佺殑鎯呭喌鏌ョ湅浣犵殑淇℃伅銆?
銆€銆€鐜板湪锛屽綋浣犳嫢鏈変竴涓猅witter甯愬彿鍚庯紝灏卞彲鎶婁綘鐨勭敤鎴峰悕鍛婅瘔浣犵殑鏈嬪弸锛屾垨鑰呭彂閫佷綘浣嶄簬twitter涓汉椤甸潰閾炬帴缁欎粬浠€傚綋鐒讹紝鎵€鏈夌殑鐢ㄦ埛閮戒細鏈夎嚜宸辩殑涓汉椤甸潰锛屽舰寮忕殑鏄繖鏍风殑锛歵witter /鐢ㄦ埛鍚?/p>
聽
鎵嬫満涓嶪m
銆€銆€鍋囧褰撲綘娌℃湁浣跨敤鐢佃剳鎴栨病鏈夋祻瑙堢綉椤电殑鏃跺€欙紝twitter鏈嶅姟渚濈劧鏄彲浠ヤ负浣犲伐浣滅殑銆備竴鏃﹀綋浣犳敞鍐屽悗锛屼綘灏卞彲閫氳繃鎵嬫満鎴朓m甯愬彿涓嶵witter閾炬帴銆傝繘鍏?seetings鈥?phone and im閫夐」锛岃繛鎺ユ墜鏈哄拰im绋嬪簭鍒癟witter甯愬彿涓槸闈炲父绠€鍗曠殑銆傞渶娉ㄦ剰鐨勬槸锛屼綘浼氬湪鎵嬫満涓婄湅鍒颁竴鏉℃秷鎭垨鍦↖m涓婃帴鏀跺埌娑堟伅锛屽悓鏃禩witter涓汉椤甸潰涓婁篃浼氱暀涓嬬浉搴旂殑娑堟伅銆?
銆€銆€浣犲彲浠ュ湪涓€涓猅witter娑堟伅鍚庨潰杩涜鍥炲锛岃繖鏄潪甯告湁瓒g殑锛屼絾濡傛灉浣犳湁寰堝璺熼殢鑰呯殑璇濓紝杩欎篃璁镐細褰卞搷鍒板叾浠栦汉锛屾墍浠ヤ綘鍙互鍦ㄩ€氱煡閫夐」涓€夋嫨鈥淒irect message鈥濄€傝繖鏍风殑璇濓紝褰撳叾浠栫敤鎴峰彂閫佺洿鎺ユ秷鎭粰浣犱竴涓汉鐨勬椂鍊欙紝浣犱粛鐒跺彲浠ュ湪浣犵殑鎵嬫満鎴朓m涓敹鍒版彁閱掋€傘€€銆€
聽
娑堟伅鍙戦€?/p>
銆€銆€浣犲彲浠ヤ粠浠讳綍浣犳敞鍐岃繃鐨勮澶囦腑鍙戦€乀witter娑堟伅銆?
銆€銆€(1) 鍦╓eb椤典笂锛屽湪浣嶄簬椤甸潰椤堕儴鐨勮緭鍏ョ獥鍙d腑杈撳叆娑堟伅銆?
銆€銆€(2) 鍦ㄦ墜鏈轰腑锛屽彂閫佷竴鏉ms鐭秷鎭埌40404锛岀敱浜庝綘鐨勬墜鏈哄懠鍙獻d宸茬粦瀹氬埌浣犵殑twitter甯愭埛涓紝鍥犳绯荤粺鍙互鑷姩璇嗗埆鍑鸿繖鏄潵鑷簬浣犵殑娑堟伅銆?
銆€銆€(3) 鍦↖m涓紝鍋囧浣犱娇鐢ㄧ殑鏄疉ol鐨勮瘽鍙戦€佹秷鎭埌 twitter im锛屽鏋滄槸gtalk鎴朖abber鐨勮瘽锛屽彂閫佸埌twitter@twitter 涓€?
銆€銆€鍦ㄨ繖浜涙渚嬩腑锛屼綘鎵€鏈夌殑璺熼殢鑰咃紙followers锛夊皢浼氬湪浠栦滑鐨勪釜浜篢witter椤甸潰鐪嬪埌浣犲彂閫佺殑娑堟伅锛屾垨鑰呭湪浠栦滑鐨勭щ鍔ㄨ澶囦腑涔熷彲浠ョ湅鍒般€?/p>
聽
璺熼殢閾炬帴
銆€銆€褰撲綘瀛︿細濡備綍鍦═witter绯荤粺涓彂閫佹秷鎭悗锛屼綘鐨勬湅鍙嬪氨鍙互璺熻釜浣犵殑鏇存柊浜嗭紝涓嬮潰鏁欎綘濡備綍鏌ョ湅鍏朵粬浜虹殑娑堟伅銆?
銆€銆€鍦ㄧ綉椤典笂锛氭坊鍔犱竴浣嶆湅鍙嬶紝鍓嶆彁鏄綘蹇呴』鍏堢櫥褰曚綘鐨勫笎鎴枫€傜劧鍚庡埌鏈嬪弸鐨凾witter涓汉椤甸潰涓婄殑鈥淎ction鈥濇爮涓偣鈥淎dd鈥濋摼鎺ャ€傚鏋滄兂瑕佹悳绱㈢敤鎴烽〉闈㈢殑璇濓紝鍦ㄤ綘鐨勪釜浜洪〉闈笂浣跨敤鎼滅储鏍忥紝鍙€氳繃鐢ㄦ埛鍚嶃€丒mail鍦板潃鍙婃墜鏈哄彿鏉ユ煡鎵俱€?
銆€銆€涓€鏃︿綘鐐瑰嚮鈥淎dd鈥濆悗锛屽亣濡傝鐢ㄦ埛璁剧疆鐨勬槸鍏紑璁块棶锛岄偅涔堜綘灏卞彲浠ュ湪浣犵殑鑱旂郴浜哄垪琛ㄤ腑鐪嬪埌浠栫殑澶村儚銆傚鏋滆鐢ㄦ埛璁剧疆鐨勬槸绉佹湁灞炴€х殑璇濓紝绯荤粺浼氬彂閫佷竴涓弸濂借姹傦紝褰撹璇ョ敤鎴峰厑璁稿悗浣犳墠浼氱湅鍒颁粬鐨勬洿鏂般€?
銆€銆€浣犱篃鍚屾牱鍙互鏌ョ湅浣犵殑鏈嬪弸鐨勮窡闅忚€咃紝閫氳繃鎶婇紶鏍囨斁鍦ㄤ綅浜庡彸渚ф爮鐨勫ご鍍忎笂灏卞彲寰楃煡鍏剁敤鎴峰悕銆傚亣浣犱綘鍦ㄤ綘鏈嬪弸鐨勮窡闅忚€呬笂鐐瑰嚮鐨勮瘽锛屽氨浼氳繘鍏ヤ粬浠殑鐢ㄦ埛椤甸潰锛屽悓鏍蜂綘鍙互娣诲姞浠栦滑鍒颁綘鐨勬湅鍙嬪垪琛ㄤ腑銆?
銆€銆€浣犱篃鍙互鏌ョ湅鍏朵粬鐢ㄦ埛鐨勬潵鑷簬鏈嬪弸鐨勬秷鎭紝鍙鐐瑰嚮娑堟伅绐楀彛涓嬬殑鈥淲ith friends鈥濇爣绛惧氨鍙互浜嗭紝鎴栬€呬綘涔熷彲浠ョ偣鍑烩€淧revious鈥濇爣绛撅紝浠庤€屽彧鏌ョ湅浠栦釜浜虹殑娑堟伅銆?
銆€銆€鍦ㄦ墜鏈烘垨im涓婏細鐧诲綍鍒版墜鏈烘垨im甯愭埛涓紝鍙戦€佷竴涓?follow username 鍛戒护锛岃繖鏍峰氨鍙帴鍙楁潵鑷簬璇ョ敤鎴风殑娑堟伅浜嗐€備綘涔熷彲浠ラ€氳繃鍙戦€佺煭娑堟伅 add phonenumber 鍒?0404鏉ラ個璇锋湅鍙嬶紝鍚屾椂浣犱篃浼氭垚涓鸿鐢ㄦ埛鐨勮窡闅忚€呫€傚鏋滆鐢ㄦ埛杩樻病娉ㄥ唽鐨勮瘽锛屼粬灏变細鎺ュ彈鍒伴個璇蜂俊鎭悗鍔犲叆杩涙潵銆?
銆€銆€鍦╓eb娴忚鍣ㄤ腑绠$悊浣犵殑鏈嬪弸鏄潪甯告柟渚跨殑锛屼絾濡傛灉浣犳兂鍦ㄦ墜鏈轰腑杩涜绠$悊鐨勮瘽鍚屾牱鏄潪甯告柟渚跨殑锛屽叿浣撳彲鏌ョ湅twitter鐨勫府鍔╅〉锛屽彲鑾峰彇鏇村鐨勫懡浠ゅ強鍏惰鎯呫€?/p>
聽
鏁板瓧鏄剧ず
銆€銆€鍦ㄤ綘鐨凾witter椤甸潰涓婃湁涓€浜涙暟瀛楋紝杩欎簺閮芥槸闈炲父閲嶈鐨勬弿杩帮細
銆€銆€1銆乫ollowers鍓嶉潰鐨勬暟瀛楄〃绀烘湁澶氬皯浜烘鍦ㄨ窡闅忥紙follow锛変綘銆?
銆€銆€2銆乫riends鍓嶉潰鐨勬暟瀛楄〃绀轰綘璺熼殢(follow)浜嗗灏戜汉銆?
銆€銆€3銆丏irect messages鍓嶉潰鐨勬暟瀛楄〃绀轰綘鎺ユ敹鍒颁簡澶氬皯鏉ヨ嚜浜庢湅鍙嬬殑鐩存帴鍙戦€佺殑娑堟伅锛岀偣鍑昏閾炬帴灏卞彲鏌ョ湅鍒拌繖浜涙秷鎭殑璇︽儏銆?
銆€銆€4銆丗avorites鍓嶉潰鐨勬暟瀛楄〃绀轰綘鏀惰棌浜嗗灏戞潯鐩紝鐐瑰嚮璇ラ摼鎺ュ氨鍙湅鍒版瘡鏉℃敹钘忔潯鐩€傛垜浠彲浠ョ湅鍒帮紝鍦ㄦ瘡鏉℃秷鎭悗闈㈤兘鏈変竴涓€滄槦鍙封€濃€滃浘鏍囷紝褰撶偣鍑昏鏄熷彿鍚庤鏄庤繖鏉℃秷鎭氨鏄綘鏀惰棌鐨勪簡銆?
銆€銆€5銆乁pdates鍓嶉潰鐨勬暟瀛楄〃绀轰綘鍙戦€佽繃澶氬皯鏉℃秷鎭€?/p>
聽
娑堟伅浼犻€?/p>
銆€銆€浣犲彲浠ヤ娇鐢?direct 鍛戒护鏉ョ洿鎺ュ彂閫佹秷鎭粰鍏跺畠鐢ㄦ埛锛岃緭鍏?d username message 鍛戒护銆傚湪浣犵殑涓汉椤甸潰涓婏紝鐐瑰嚮direct messages鍚庯紝涓婇潰鐨勬秷鎭緭鍏ユ灏卞叿澶囦簡鐩存帴鍒版寚瀹氭湅鍙嬬殑鍔熻兘锛屼綘鍙互閫夋嫨鍏朵腑鐨勪竴涓敤鎴凤紝杩涜鐩存帴鍙戦€併€?/p>
聽
鍏抽棴鏂规硶
銆€銆€twitter娑堟伅涔熻浼氶獨鎵板埌浣狅紝濡傛灉浣犳兂鍏抽棴瀹冪殑璇濓紝閭d箞浣犲彲鍙戦€佷竴涓€渙ff鈥濄€佲€淪leep鈥?鎴?鈥淪top鈥濆懡浠わ紝濡傛灉鎯宠浠栨仮澶嶈繃鏉ョ殑璇濆彲浠ュ彂閫?鈥渙n鈥濄€?鈥淲ake鈥濇垨鈥渟tart鈥濆懡浠ゃ€?/p>
聽
聽
聽
浣犺鐢═witter鍚楋紵
聽
濡傛灉浣犱笉鐭ラ亾twitter锛屼綘鏈夌偣钀藉悗浜庢疆娴佷簡銆傝繖鏄璋锋渶鐏垎鐨勪簰鑱旂綉鐜╂剰锛屼篃鏄偅浜涘湪鍖椾含鍗磋繃纭呰胺鏃堕棿鐨勪汉鐨勬柊鐜╁叿銆備笉杩囦笉鐭ラ亾涔熸病浠€涔堝ぇ涓嶄簡鐨勶紝鍦ㄤ竴涓湀鍓嶏紝鍙兘鏍规湰娌′汉鐭ラ亾瀹冦€?/p>
聽
twitter鏄粈涔堝憿锛?/p>
twitter鑷繁鐨勭綉绔欓椤佃锛屸€滃湪杩欎釜鐢辨湅鍙嬪拰闄岀敓浜虹粍鎴愮殑鍏ㄧ悆绀惧尯涓紝鎵€鏈変汉閮藉湪鍥炵瓟鍚屼竴涓棶棰橈細浣犲湪鍋氫粈涔堬紵蹇€氳繃鎵嬫満鐭俊銆佸嵆鏃堕€氳杞欢鎴栬€呯綉椤垫彁浜ょ瓟妗堝惂锛佲€?/p>
ft涓枃缃戝瀹冪殑浠嬬粛鐩存帴浜嗗綋锛屸€滄墜鏈鸿糠浣犲崥瀹㈡湇鍔witter銆傗€?/p>
鏋楀槈婢嶇殑瑙i噴鏄弿缁樹簡涓€涓嬩粬鐨勬ⅵ鎯筹紝鈥滄垜涓€鐩存啩鎲潃杩欎箞涓€娆句骇鍝佲€斺€旇剳瀛愰噷闈㈠伓灏旈棯杩囩殑蹇靛ご鍙互璐村湪缃戜笂锛屽彫鍛婂ぉ涓嬨€傛瘮濡傝鈥滅珯寰楅珮銆佸翱寰楄繙鈥濄€佲€滃瓩鐕曞э鐨勬柊涓撹緫闅惧惉寰椾护浜哄彂鎸団€濄€佲€滃寳浜粖鏃ラ粍澶╁帤鍦熲€濅簯浜戙€傝繖浜涗笢瑗胯鎵╁厖鎴恇log涓婄殑涓€绡囧笘瀛愬疄鍦ㄦ病浠€涔堝繀瑕侊紝浣嗘垜浠嵈鎬讳細璺熻韩杈圭殑瀹朵紮浠嫾鍛藉彣鍜曞嚑涓嬶紝鎴栬€呭啓鍒癕sn鏄电о涓婇潰鍘汇€傗€︹€﹀鏋滀綘涓嶆槑鐧芥垜闀挎湡浠ユ潵鎲ф啲鐨勬槸涓粈涔堜笢瑗匡紝閭d箞浣犲彲浠ョ湅鐪嬭繖涓〉闈€傛槑鐧戒簡鍚э紝杩欎釜灏辨槸twitter鈥︹€︹€?/p>
瑭硅啈鐨勮в閲婃槸锛宼witter鍙仛浜嗕竴浠朵簨鎯咃紝灏辨槸璁╁ソ鍙嬪彲浠ヤ互鍙﹀鐨勬柟寮忎繚鎸佹矡閫氾紝鍒嗕韩鐜板湪鍦ㄥ仛鐨勪簨鎯呫€?/p>
涓婂懆鍚曟娆g粰澶у璁瞭witter鐨勭敤澶勶紝浠栬锛堝ぇ鎰忥級锛屾瘮鏂硅鎴戣寮€浼氾紝灏卞彂涓€涓紝鍛婅瘔澶у鎴戝紑浼氫簡锛岃繖涓秷鎭彲浠ョ敤鐭俊鍙戠粰鎵€鏈夌殑鏈嬪弸杩涜鎻愰啋锛屽埆鎵撴壈鎴戙€傛垜鑴卞彛鑰屽嚭锛屼綘杩欎笉鎵撴壈鎴戜簡锛燂紙浠栨嬁鍟嗗姟浣滀緥瀛愮殑纭鏄撹瑙o紝twitter鐜板湪鐪嬭繕鏄棤鑱婁骇涓氱殑涓滆タ銆傦級
鏈夋椂鍊欙紝浼氬彂鐭俊缁欐湅鍙嬶紝绠€鍗曞嚑涓瓧锛屸€滃湪鍋氫粈涔堬紵鈥濆叾瀹炲氨璺熻繃鍘绘墦鎷涘懠閮界壒鍏冲績瀵规柟鈥滃悆浜嗗悧锛熲€濅竴鏍凤紝涓嶆槸鐪熼棶鍦ㄥ仛浠€涔堛€傚鏋滀篃鏈変汉鍦ㄥ浗鍐呮嫹璐濅竴涓猼witter锛屼互鍚庢敹鍒扮殑鍥炲澶ф閮芥槸锛岀湅鎴憈witter銆?/p>
鎸夋垜鐨勭悊瑙o紝twitter鍏跺疄鍖呮嫭涓や釜姒傚康锛氱涓€锛屼竴鍙ヨ瘽鍗氬锛堣嫳鏂?40涓瓧姣嶄互鍐咃級銆傝繖涓崥瀹紝鍔熻兘姣旇緝寮猴紝鍙互鐢ㄦ墜鏈?im鍐欙紝涔熷彲浠ュ彂鍒板ソ鍙嬬殑鎵嬫満/im涓婂幓銆傜浜岋紝鎺ㄩ€佸埌鎵嬫満鍜孖m鐨勫姛鑳斤紝鑳戒富鍔ㄥ憡璇夊埆浜烘垜鍦ㄥ仛浠€涔堬紝涓庝汉淇濇寔娌熼€氱殑鐘舵€併€傚綋鐒朵簡锛岃繖鑳屽悗杩樻槸涓€涓ぞ鍖烘垨sns锛堢ぞ浼氬叧绯荤綉缁滐級銆?/p>
鍙槸锛屼綘浼氱敤twitter鍚楋紵
浠庡啓鐨勪汉鐪嬶紝鎶婅繖浜涗釜鈥滀竴鍙ヨ瘽鈥濆啓涓嬫潵锛屾湁蹇呰鍚楋紵濡傛灉鎬诲湪鍐欒繖浜涚悙纰庣殑涓滆タ锛岃繕鏈夌簿鍔涘共鍒殑鍚楋紵鎸夌収蹇冪悊瀛﹂『娴佹硶鍒欙紝鎬濊矾琚矓寮€锛屽ぇ姒傞渶瑕?5鍒嗛挓鍥炲埌鍘熷厛鐨勪富棰樹笂鍘汇€?/p>
浠庢敹鐨勪汉鐪嬶紝鏈夊繀瑕佺煡閬撻偅浜涗釜鈥滀竴鍙ヨ瘽鈥濆悧锛熸湁蹇呰涓庡ぇ閲忔湅鍙嬩繚鎸佽繖绉嶉殢鏃剁浉鑱旂殑鐘舵€佸悧锛熺敱姝や骇鐢熺殑淇℃伅鐖嗙偢锛屼篃鏄浉褰撳彲鎬曠殑浜嬫儏銆?/p>
鍙﹀锛屾垜杩樻湁涓€涓枒闂細涓嶅皯浜哄凡缁忎範鎯簡鍦ㄤ笌浜哄綋闈㈣皥璇濇椂鎺ュ惉鎵嬫満鎴栨敹鍙戠煭淇★紝鍙槸锛岄毦閬撳湪杩欎竴鍒婚潰鍓嶇殑杩欎釜浜轰笉姣旂嚎閭g鐨勯偅涓汉鏇撮噸瑕侊紵
鎴戣偗瀹氫笉浼氱敤銆備笉杩囷紝涔熻兘鐞嗚в涓轰粈涔堟湁浜洪渶瑕佽繖绉嶆湇鍔°€傛湁涓や釜渚嬪瓙鍙互鏉ュ弬鐓э細
涓€鏄疢sn銆傚湪鍔炲叕瀹や笉灏戜汉涓€鐩村紑鐫€msn锛屽悓鏃朵笌澶氫釜浜鸿亰澶┿€傝櫧鐒剁敤msn鑱婂ぉ娌熼€氫簨鍔$殑鏁堢巼涓嶉珮锛屼竴涓簨鎯匨sn涓婅鍗婁釜灏忔椂锛屼竴涓數璇濇垨褰撻潰鍑犲彞璇濆氨鎼炲畾锛屼絾鏄紝杩欑鎸佺画鐨凪sn娌熼€氾紝鐨勭‘鍥犱负娌熼€氭垚鏈綆锛屽ぇ澶ф彁楂樺叧绯荤綉涓妭鐐圭殑鏁扮洰銆傚氨鍏崇郴鑰岃█锛屽畠涓嶆槸寤虹珛寮洪摼鎺ョ殑宸ュ叿锛屽嵈鏄緢濂界殑缁存姢寮遍摼鎺ョ殑宸ュ叿銆?/p>
浜屾槸blackberry榛戣帗鎵嬫満銆傚涓€澶?4灏忔椂涓嶆柇杩涜鐢靛瓙閭欢娌熼€氱殑杩欎釜鎯虫硶锛屾垜鍑犱箮澶╃劧鍦板弽鎰燂紝瑙夊緱鍏徃涓洪珮绠¢厤榛戣帗锛屾槸瀹冧滑鍘嬫θ楂樼鐨勬柟寮忋€備笉杩囧湪鐪嬩簡娴峰路钀ㄧ彮鐨勪竴娈靛璇濅箣鍚庯紝杩欎釜鎯虫硶鏈夌偣鍔ㄦ憞銆備粬鏄浗闄呮姇璧勫叕鍙窼aban capital闆嗗洟鐨凜eo锛屼粬鏄粦鑾撶埍濂借€咃紝涔熸槸绗竴涓负鏁翠釜楂樼骇绠$悊鍥㈤槦寮哄埗閰嶅榛戣帗鐨凜eo銆?/p>
浠栬锛屸€滄垜鍠滄绔嬪埢澶勭悊闂锛岃繖鍙槸鎴戠殑涓汉椋庢牸锛岄粦鑾撳苟娌℃湁璁╂垜鎰熷埌鍘嬪姏鏇村ぇ锛屽疄闄呬笂鍙嶈€屽噺杞讳簡鍘嬪姏銆傗€濈珛鍒诲鐞嗛棶棰橈紝鐗瑰埆鏄偅浜涚悙纰庣殑闂锛岀殑纭槸鐣欏嚭绮惧姏鏉ュ簲瀵归噸澶ч棶棰樼殑鏈€浣虫柟寮忋€傛垜鐚滄兂锛屼粬搴旇涔熶笉浼氭敹鍒伴偖浠跺氨绔嬪埢鍥烇紝鑰屽彲鑳芥槸鍏堝鐞嗗畬鎵嬩笂姝e仛鐨勪换鍔★紝涔熷氨鏄偅浜涢€氳繃榛戣帗鏉ョ殑鐢靛瓙閭欢锛屼笉浼氭帓鍦ㄤ簨鍔′紭鍏堣〃鐨勬渶椤剁銆?/p>
浠栬繕璇达紝鈥滆繃鍘伙紝鎴戜竴鏅氫笂閮藉湪鍙戠數瀛愰偖浠讹紝鐜板湪锛屾垜鍙互鐧藉ぉ鍋氳繖浜涗簨锛屾棤璁烘垜鍦ㄥ摢閲屻€傛崲鍙ヨ瘽璇达紝榛戣帗骞舵湭浣挎垜绂荤兢绱㈠眳锛屾伆鎭扮浉鍙嶏紝瀹冩敼鍠勪簡鎴戠殑娌熼€氳兘鍔涳紝鍒涢€犲嚭鏇村鐨勯潰瀵归潰浜洪檯浜ゅ線鐨勬満浼氥€傗€?/p>
杩欑瘒鏂囩珷涓昏浠嬬粛浜嗚嫻鏋滄墜鏈烘€庝箞鐢ㄨ摑鐗欎紶鐓х墖鍒板畨鍗撴墜鏈猴紝鍏锋湁涓€瀹氬€熼壌浠峰€硷紝闇€瑕佺殑鏈嬪弸鍙互鍙傝€冧笅銆傚笇鏈涘ぇ瀹堕槄璇诲畬杩欑瘒鏂囩珷鍚庡ぇ鏈夋敹鑾凤紝涓嬮潰璁╁皬缂栧甫鐫€澶у涓€璧蜂簡瑙d竴涓嬨€?/p>
2019鐙鍏戒紒涓氶噸閲戞嫑鑱楶ython宸ョ▼甯堟爣鍑?>>聽
璁╀綘鐨刬os搴旂敤绋嬪簭鏀寔杩愯javascript鑴氭湰锛欽avascriptcore妗嗘灦璇﹁в
聽 聽 璇村埌javascript鑴氭湰锛宨os寮€鍙戣€呴兘浼氭兂鍒颁竴涓悕鍙獼avascriptcore鐨勬鏋躲€傝繖涓鏋剁殑纭崄鍒嗗己澶э紝鍏朵腑灏佽浜嗕竴濂桱avascript杩愯鐜浠ュ強native涓嶫s鏁版嵁绫诲瀷涔嬮棿鐨勮浆鎹㈡ˉ姊佸揩鐮佽鏂囥€傛湰绡囧崥瀹富瑕佽璁哄浣曚娇鐢ㄦ妗嗘灦鏉ュ湪ios搴旂敤涓繍琛孞avascript鑴氭湰銆?/p>
涓€銆丣avascriptcore妗嗘灦缁撴瀯
聽 聽 鍦ㄥ涔犱竴涓鏋舵椂锛岄鍏堝簲璇ュ厛浜嗚в鏁翠釜妗嗘灦鐨勭粨鏋勶紝鎷縤os寮€鍙戞潵涓句緥锛屽浜庝竴涓檶鐢熺殑妗嗘灦锛岀涓€姝ラ渶瑕佸厛鎼炴竻妤氳繖閲岄潰閮藉寘鍚摢浜涚被锛屼釜鍚勭被涔嬮棿鏄€庢牱鐨勫叧绯伙紝杩欎釜妗嗘灦鍜屽叾浠栫殑妗嗘灦闂存湁鏃犺仈绯讳互鍙婃€庢牱浜х敓鐨勮仈绯汇€傚皢浜涢棶棰樻悶娓呮锛屾湁浜嗗ぇ浣撲笂鐨勮璇嗗悗锛屾垜浠啀鏉ュ涔犲叾涓殑姣忎釜绫诲嵆鍏朵粬缁嗚妭鐨勫簲鐢ㄥ皢闈炲父瀹规槗銆傛垜浠厛鏉ョ湅涓€寮燡avascriptcore妗嗘灦鐨勭粨鏋勫浘锛?/p>
杩欏紶鍥炬槸鎴戞墜宸ョ敾鐨勶紝涓嶆槸閭d箞缇庤骞朵笖娌℃湁鏂囧瓧鐨勮в閲婏紝浣嗘槸鎴戣寰楀畠鑳介潪甯哥洿瑙傜殑琛ㄨ揪javascriptcore涓寘鍚殑绫讳箣闂寸殑鍏崇郴銆備笅闈㈡垜鏉ュ悜浣犺в閲婅繖寮犲浘绌剁珶琛ㄨ揪浜嗕粈涔堟剰鎬濓紝棣栧厛鍘熺敓鐨刬os搴旂敤鏄敮鎸佸绾跨▼鎵ц浠诲姟鐨勶紝鎴戜滑鐭ラ亾javascript鏄崟绾跨▼锛屼絾杩欏苟涓嶄唬琛ㄦ垜浠笉鑳藉湪native涓紓姝ユ墽琛屼笉鍚岀殑javascript浠g爜銆?/p>
1.jsvirtualmachine鈥斺€擩avascript鐨勮櫄鎷熸満
聽聽聽聽javascriptcore涓彁渚涗簡涓€涓悕涓篔svirtualmachine鐨勭被锛岄【鍚嶆€濅箟锛岃繖涓被鍙互鐞嗚в涓轰竴涓狫s铏氭嫙鏈恒€傚湪native涓紝鍙浣犳効鎰忥紝浣犲彲浠ュ垱寤轰换鎰忓涓狫svirtualmachine瀵硅薄锛屽悇涓狫sviretualmachine瀵硅薄闂存槸鐩镐簰鐙珛鐨勶紝浠栦滑涔嬮棿涓嶈兘鍏变韩鏁版嵁涔熶笉鑳戒紶閫掓暟鎹紝濡傛灉浣犳妸浠栦滑鏀惧湪涓嶅悓鐨凬ative绾跨▼锛屼粬浠氨鍙互骞惰鐨勬墽琛屾棤鍏崇殑js浠诲姟銆?/p>
2.jscontext鈥斺€擩avascript杩愯鐜
聽 聽 jscontext涓婁笅鏂囧璞″彲浠ョ悊瑙d负鏄疛s鐨勮繍琛岀幆澧冿紝鍚屼竴涓狫svirtualmachine瀵硅薄鍙互鍏宠仈澶氫釜jscontext瀵硅薄锛屽苟涓斿湪webview涓瘡娆″埛鏂版搷浣滃悗锛屾webview鐨凧s杩愯鐜閮芥槸涓嶅悓鐨凧scontext瀵硅薄銆傚叾浣滅敤灏辨槸鐢ㄦ潵鎵цjs浠g爜锛屽湪native鍜孞s闂磋繘琛屾暟鎹殑浼犻€掋€?/p>
3.jsvalue鈥斺€擩avascript鍊煎璞?/p>
聽 聽 javascript鍜孫bjective-c铏界劧閮芥槸闈㈠悜瀵硅薄璇█锛屼絾鍏跺疄鐜版満鍒跺畬鍏ㄤ笉鍚岋紝oc鏄熀浜庣被鐨勶紝js鏄熀浜庡師鍨嬬殑锛屽苟涓斾粬浠殑鏁版嵁绫诲瀷闂翠篃瀛樺湪寰堝ぇ鐨勫樊寮傘€傚洜姝よ嫢瑕佸湪native鍜孞s闂存棤闅滅鐨勮繘琛屾暟鎹殑浼犻€掞紝灏遍渶瑕佷竴涓腑闂村璞″仛妗ユ帴锛岃繖涓璞″氨鏄疛svalue銆?/p>
4.jsexport
聽 聽 jsexport鏄竴涓崗璁紝native涓伒瀹堟瑙f瀽鐨勭被鍙互灏嗘柟娉曞拰灞炴€ц浆鎹负js鐨勬帴鍙d緵js璋冪敤銆?/p>
5.涓€浜涚敤浜嶤璇█鐨勭粨鏋?/p>
聽 聽 浣犱竴瀹氭敞鎰忓埌浜嗭紝涓婂浘鐨勫彸涓嬭杩樻湁涓€鍧楄铏氱嚎鍖呭洿鐨勫尯鍩燂紝鍏朵腑鐨?绫?閮芥槸c璇█椋庢牸锛孞avascriptcore妗嗘灦鏄敮鎸佸湪objective-c銆丼wift鍜孋涓夌璇█涓娇鐢ㄧ殑銆?/p>
浜屻€佸湪native涓繍琛孞avascript鑴氭湰浠g爜
聽 聽 鎴戜滑鍏堟潵缂栧啓涓€涓渶绠€鍗曠殑渚嬪瓙锛屼娇鐢∣c浠g爜鏉ユ墽琛屼竴娈礘s鑴氭湰銆傞鍏堟柊寤轰竴涓枃浠讹紝灏嗗叾鍚庣紑璁剧疆涓?js锛屾垜杩欓噷灏嗗畠鍛戒护涓簃ain.js锛屽湪鍏朵腑缂栧啓濡備笅浠g爜锛?/p>
(function(){
console.log("hello native");
})();
涓婇潰鏄竴涓嚜鎵ц鐨勫嚱鏁帮紝鍏朵腑鎵撳嵃浜嗏€淗ello native鈥濆瓧绗︿覆銆傚湪native涓紪鍐欏涓嬩唬鐮侊細
- (void)viewdidload {
[super viewdidload];
nsstring * path = [[nsbundle mainbundle] pathforresource:@"main" oftype:@"js"];
nsdata * jsdata = [[nsdata alloc]initwithcontentsoffile:path];
nsstring * jscode = [[nsstring alloc]initwithdata:jsdata encoding:nsutf8stringencoding];
self.jscontext = [[jscontext alloc]init];
[self.jscontext evaluatescript:jscode];
}
闇€瑕佹敞鎰忥紝鍏跺疄杩欓噷鎴戝皢鍒涘缓鐨凧scontext瀵硅薄浣滀负浜嗗綋鍓嶈鍥炬帶鍒跺櫒鐨勫睘鎬э紝杩欐牱鍋氱殑鐩殑浠呬粎鏄负浜嗘柟渚胯皟璇曪紝涓嶈繃涓嶅姝ontext瀵硅薄杩涜寮曠敤锛屽綋viewdidload鍑芥暟鎵ц瀹屾垚鍚庯紝js杩愯鐜涔熷皢琚攢姣侊紝鎴戜滑灏辨棤娉曞湪safari涓洿瑙傜殑鐪嬪埌js浠g爜鐨勬墽琛岀粨鏋滀簡銆?/p>
聽 聽 杩愯宸ョ▼锛岃寰楄鎵撳紑safari娴忚鍣ㄧ殑鑷姩鏄剧ずjscontent妫€鏌ュ櫒锛屽涓嬪浘锛?/p>
褰搃os妯℃嫙鍣ㄨ窇璧锋潵鍚庯紝safari浼氳嚜鍔ㄥ脊鍑哄紑鍙戣€呭伐鍏凤紝鍦ㄦ帶鍒跺彴閲岄潰鍙互鐪嬪埌鏉ヨ嚜javascript鐨勭湡鎸氶棶鍊欙細
鍒氭墠鎴戜滑鍙槸绠€鍗曚簡閫氳繃鍘熺敓璋冪敤浜嗕竴娈礘s浠g爜锛屼絾鏄鏋淣ative鍦ㄨ皟js鏂规硶鏃舵棤娉曚紶鍙傞偅涔熷おlow浜嗭紝鎴戜滑鍙互鐩存帴灏嗚浼犻€掔殑鍙傛暟鏍煎紡鍖栧埌瀛楃涓蹭腑锛屼慨鏀筸ain.js鏂囦欢濡備笅锛?/p>
function put(name){
console.log("hello " name);
};
put(%@);
鍐嶅皝瑁呬竴涓狾c鏂规硶濡備笅锛?/p>
-(void)runjs_hello:(nsstring *)name{
nsstring * path = [[nsbundle mainbundle] pathforresource:@"main" oftype:@"js"];
nsdata * jsdata = [[nsdata alloc]initwithcontentsoffile:path];
nsstring * jscode = [[nsstring alloc]initwithdata:jsdata encoding:nsutf8stringencoding];
nsstring * finistring = [nsstring stringwithformat:jscode,name];
[self.jscontext evaluatescript:finistring];
}
鍦╲iewdidload涓繘琛岃皟鐢紝濡備笅锛?/p>
- (void)viewdidload {
[super viewdidload];
self.jscontext = [[jscontext alloc]init];
[self runjs_hello:@"'闃垮嚒杈?"];
}
杩愯鍐嶇湅safari鎺у埗鍙扮殑缁撴灉锛岀紪绋嬩簡hello 闃垮嚒杈緙锛?/p>
鍏跺疄evaluatescript鍑芥暟鎵ц鍚庝細灏咼s浠g爜鐨勬墽琛岀粨鏋滆繘琛岃繑鍥烇紝鏄疛svalue绫诲瀷鐨勫璞★紝鍚庨潰浼氬啀浠嬬粛銆?/p>
涓夈€佸湪javascript涓皟鐢∟ative鏂规硶
聽 聽 鏈夋潵鏃犲線闈炲悰瀛愶紝鍚屾牱涔熷彲浠ュ湪鍘熺敓涓紪鍐欐柟娉曡js鏉ヨ皟鐢紝绀轰緥濡備笅锛?/p>
- (void)viewdidload {
[super viewdidload];
void(^block)() = ^(){
nslog(@"hello javascript");
};
self.jscontext = [[jscontext alloc]init];
[self.jscontext setobject:block forkeyedsub:@"oc_hello"];
}
涓婇潰setobject:forkeyedsub:鏂规硶鐢ㄦ潵鍚慗scontext鐜鐨勫叏灞€瀵硅薄涓坊鍔犲睘鎬э紝杩欓噷娣诲姞浜嗕竴涓嚱鏁板睘鎬э紝鍙栧悕涓簅c_hello銆傝繖閲孞avascriptcore浼氳嚜鍔ㄥ府鎴戜滑鎶婁竴浜涙暟鎹被鍨嬭繘琛岃浆鎹紝浼氬皢oc鐨勫嚱鏁拌浆鎹负js鐨勫嚱鏁帮紝杩愯宸ョ▼锛屽湪safari鐨勬帶鍒跺彴涓皟鐢╫c_hello鍑芥暟锛屽彲浠ョ湅鍒板湪xcode鎺у埗鍙拌緭鍑轰簡瀵笿avascript鐨勭湡鎸氶棶鍊欙紝濡備笅锛?/p>
鍚屾牱锛屽鏋滃0鏄庣殑block鏄甫鍙傛暟鐨勶紝js鍦ㄨ皟鐢ㄦoc鏂规硶鏃朵篃闇€瑕佷紶鍏ュ弬鏁帮紝濡傛灉block鏈夎繑鍥炲€硷紝鍒欏湪js涓篃鑳借幏鍙栧埌杩斿洖鍊硷紝渚嬪锛?/p>
bool (^block)(nsstring *) = ^(nsstring *name){
nslog(@"%@", [nsstring stringwithformat:@"hello %@",name]);
return yes;
};
self.jscontext = [[jscontext alloc]init];
[self.jscontext setobject:block forkeyedsub:@"oc_hello"];
鍥涖€佹繁鍏scontext绫?/p>
聽 聽 鐪嬪埌杩欙紝浣犲凡缁忓浼氭渶鍩虹鐨凮c涓嶫s浜掔浉闂ソ(浜や簰)銆備笅闈㈡垜浠啀鏉ユ繁鍏ョ湅涓婮scontext涓殑灞炴€у拰鏂规硶銆?/p>
聽 聽 鍒涘缓jscontext瀵硅薄鏈夊涓嬩袱绉嶆柟寮忥細
//鍒涘缓涓€涓柊鐨凧s杩愯鐜
- (instancetype)init;
//鍒涘缓涓€涓柊鐨凧s杩愯鐜 骞跺叧鑱斿埌鏌愪釜铏氭嫙鏈哄璞′笂
- (instancetype)initwithvirtualmachine:(jsvirtualmachine *)virtualmachine;
聽 聽 鎵цjs浠g爜鏈夊涓嬩袱涓柟娉曪細
//鎵цjs浠g爜 缁撴灉灏嗗皝瑁呮垚jsvalue瀵硅薄杩斿洖
- (jsvalue *)evaluatescript:(nsstring *);
//浣滅敤鍚屼笂
- (jsvalue *)evaluatescript:(nsstring *) withsourceurl:(nsurl *)sourceurl ns_available(10_10, 8_0);
聽 聽 涓嬮潰鐨勫睘鎬у拰鏂规硶鍙互鑾峰彇鍒癑s杩愯鐜涓殑涓€浜涗俊鎭細
//褰撳墠鐨凧s杩愯鐜 褰揓s璋冪敤oc鏂规硶鏃讹紝鍦∣c鏂规硶涓彲浠ョ敤姝ゆ柟娉曡幏鍙栧埌js杩愯鐜
(jscontext *)currentcontext;
//鑾峰彇褰撳墠鎵ц鐨凧s鍑芥暟锛屽綋js璋冪敤oc鏂规硶鏃讹紝鍦∣c鏂规硶涓彲浠ョ敤姝ゆ柟娉曡幏鍙栧埌鎵ц鐨勫嚱鏁?/p>
(jsvalue *)currentcallee;
//鑾峰彇褰撳墠鎵ц鐨凧s鍑芥暟涓殑this鎸囧悜鐨勫璞?/p>
(jsvalue *)currentthis;
//鑾峰彇褰撳墠鎵ц鍑芥暟鐨勫弬鏁板垪琛紝褰揓s璋冪敤oc鏂规硶鏃讹紝鍦∣c鏂规硶涓彲浠ョ敤姝ゆ柟娉曡幏鍙栧埌鎵ц鐨勫嚱鏁扮殑鍙傛暟鍒楄〃
(nsarray *)currentarguments;
//鑾峰彇褰撳墠js杩愯鐜鐨勫叏灞€瀵硅薄
@property (readonly, strong) jsvalue *globalobject;
//褰撹繍琛岀殑javascript浠g爜鎶涘嚭浜嗘湭鎹曡幏鐨勫紓甯告椂锛岃繖涓睘鎬т細琚祴鍊间负鎶涘嚭鐨勫紓甯?/p>
@property (strong) jsvalue *exception;
//璁剧疆涓轰竴涓紓甯告崟鑾风殑block锛屽鏋滃紓甯歌姝lock鎹曡幏锛宔xception灞炴€у氨涓嶅啀琚祴鍊间簡
@property (copy) void(^exceptionhandler)(jscontext *context, jsvalue *exception);
//褰撳墠杩愯鐜鎵€鍏宠仈鐨勮櫄鎷熸満
@property (readonly, strong) jsvirtualmachine *virtualmachine;
//褰撳墠杩愯鐜鍚嶇о
@property (copy) nsstring *name;
//鑾峰彇褰撳墠js杩愯鐜鍏ㄥ眬瀵硅薄涓婄殑鏌愪釜灞炴€?/p>
- (jsvalue *)objectforkeyedsub:(id)key;
//璁剧疆褰撳墠js杩愯鐜鍏ㄥ眬瀵硅薄涓婄殑灞炴€?/p>
- (void)setobject:(id)object forkeyedsub:(nsobject
//灏咰璇█鐜鐨凧s杩愯鐜杞崲涓篛c鐜鐨凧s杩愯鐜
(jscontext *)contextwithjsglobalcontextref:(jsglobalcontextref)jsglobalcontextref;
//c璇█鐜鐨凧s杩愯涓婁笅鏂?/p>
@property (readonly) jsglobalcontextref jsglobalcontextref;
浜斻€佹繁鍏svalue绫?/p>
聽 聽 jsvalue鏄疛avascript涓嶰bjective-c涔嬮棿鐨勬暟鎹ˉ姊併€傚湪objective-c涓皟鐢↗s鑴氭湰鎴栬€匤s璋冪敤oc鏂规硶閮藉彲浠ヤ娇鐢↗svalue鏉ヤ紶杈撴暟鎹€傚叾涓睘鎬у拰鏂规硶绀轰緥濡備笅锛?/p>
//鎵€瀵瑰簲鐨凧s杩愯鐜
@property (readonly, strong) jscontext *context;
//鍦ㄦ寚瀹氱殑js杩愯鐜涓垱寤轰竴涓狫svalue瀵硅薄
(jsvalue *)valuewithobject:(id)value incontext:(jscontext *)context;
//鍒涘缓甯冨皵鍊?/p>
(jsvalue *)valuewithbool:(bool)value incontext:(jscontext *)context;
//鍒涘缓娴偣鍊?/p>
(jsvalue *)valuewithdouble:(double)value incontext:(jscontext *)context;
//鍒涘缓32浣嶆暣鍨嬪€?/p>
(jsvalue *)valuewithint32:(int32_t)value incontext:(jscontext *)context;
//鍒涘缓32浣嶆棤绗﹀彿鏁村舰鍊?/p>
(jsvalue *)valuewithuint32:(uint32_t)value incontext:(jscontext *)context;
//鍒涘缓绌虹殑js瀵硅薄
(jsvalue *)valuewithnewobjectincontext:(jscontext *)context;
//鍒涘缓绌虹殑js鏁扮粍
(jsvalue *)valuewithnewarrayincontext:(jscontext *)context;
//鍒涘缓js姝e垯瀵硅薄
(jsvalue *)valuewithnewregularexpressionfrompattern:(nsstring *)pattern flags:(nsstring *)flags incontext:(jscontext *)context;
//鍒涘缓js閿欒淇℃伅
(jsvalue *)valuewithnewerrorfrommessage:(nsstring *)message incontext:(jscontext *)context;
//鍒涘缓js null鍊?/p>
(jsvalue *)valuewithnullincontext:(jscontext *)context;
//鍒涘缓js undefined鍊?/p>
(jsvalue *)valuewithundefinedincontext:(jscontext *)context;
javascript涓殑鏁版嵁绫诲瀷鍜孫bjective-c鐨勬暟鎹被鍨嬭繕鏄湁鐫€寰堝ぇ鐨勫樊寮傦紝鍏朵腑瀵瑰簲鍏崇郴濡備笅锛?/p>
objective-c聽javascriptnilundefinednsnullnullnsstringstringnsnumbernumber booleannsdictionary 聽聽objectnsarrayarraynsdatedate聽 聽blockfunctionidobjectclassobject
涓嬮潰杩欎簺鏂规硶鍙互灏咼svalue鍊艰浆鎹负objective-c涓殑鏁版嵁绫诲瀷锛?/p>
//灏咼svalue杞崲涓篛c瀵硅薄
- (id)toobject;
//灏咼svalue杞崲鎴愮壒瀹歄c绫荤殑瀵硅薄
- (id)toobjectofclass:(class)expectedclass;
//灏咼svalue杞崲鎴愬竷灏斿€?/p>
- (bool)tobool;
//灏咼svalue杞崲鎴愭诞鐐瑰€?/p>
- (double)todouble;
//灏咼svalue杞崲鎴?2浣嶆暣鍨嬪€?/p>
- (int32_t)toint32;
//灏咼svalue杞崲鎴?2浣嶆棤绗﹀彿鏁村瀷鍊?/p>
- (uint32_t)touint32;
//灏咼svalue杞崲鎴怤snumber鍊?/p>
- (nsnumber *)tonumber;
//灏咼svalue杞崲鎴怤sstring鍊?/p>
- (nsstring *)tostring;
//灏咼svalue杞崲鎴怤sdate鍊?/p>
- (nsdate *)todate;
//灏咼svalue杞崲鎴怤sarray鍊?/p>
- (nsarray *)toarray;
//灏咼svalue杞崲鎴怤sdictionary鍊?/p>
- (nsdictionary *)todictionary;
//鑾峰彇jsvalue瀵硅薄涓煇涓睘鎬х殑鍊?/p>
- (jsvalue *)valueforproperty:(nsstring *)property;
//璁剧疆jsvalue瀵硅薄涓煇涓睘鎬х殑鍊?/p>
- (void)setvalue:(id)value forproperty:(nsstring *)property;
//鍒犻櫎jsvalue瀵硅薄涓殑鏌愪釜灞炴€?/p>
- (bool)deleteproperty:(nsstring *)property;
//鍒ゆ柇jsvalue瀵硅薄涓槸鍚﹀寘鍚煇涓睘鎬?/p>
- (bool)hasproperty:(nsstring *)property;
//瀹氫箟jsvalue涓殑鏌愪釜灞炴€?杩欎釜鏂规硶鍜孞avascript涓璒bject鏋勯€犲嚱鏁扮殑defineproperty鏂规硶涓€鑷?/p>
/*
绗?涓弬鏁拌缃灞炴€х殑鎻忚堪淇℃伅 鍙互璁剧疆鐨勯敭鍊煎涓嬶細
nsstring * const jspropertydeorwritablekey;//璁剧疆甯冨皵鍊?鏄惁鍙啓
nsstring * const jspropertydeorenumerablekey;//璁剧疆甯冨皵鍊?鏄惁鍙灇涓?/p>
nsstring * const jspropertydeorconfigurablekey;//璁剧疆甯冨皵鍊?鏄惁鍙厤缃?/p>
nsstring * const jspropertydeorvaluekey;//璁剧疆姝ゅ睘鎬х殑鍊?/p>
nsstring * const jspropertydeorgetkey;//璁剧疆姝ゅ睘鎬х殑get鏂规硶
nsstring * const jspropertydeorsetkey;//璁剧疆姝ゅ睘鎬х殑set鏂规硶
浠ヤ笂set銆乬et鏂规硶鐨勯敭鍜寁alue銆佸彲鍐欐€х殑閿笉鑳藉悓鏃跺瓨鍦紝鍏惰娉曟槸javascript淇濇寔涓€鑷?/p>
*/
- (void)defineproperty:(nsstring *)property deor:(id)deor;
//鑾峰彇js鏁扮粍瀵硅薄鏌愪釜涓嬫爣鐨勫€?/p>
- (jsvalue *)valueatindex:(nsuinteger)index;
//璁剧疆js鏁扮粍瀵硅薄鏌愪釜涓嬫爣鐨勫€?/p>
- (void)setvalue:(id)value atindex:(nsuinteger)index;
//鍒ゆ柇姝ゅ璞℃槸鍚︿负undefined
@property (readonly) bool isundefined;
//鍒ゆ柇姝ゅ璞℃槸鍚︿负null
@property (readonly) bool isnull;
//鍒ゆ柇姝ゅ璞℃槸鍚︿负甯冨皵鍊?/p>
@property (readonly) bool isboolean;
//鍒ゆ柇姝ゅ璞℃槸鍚︿负鏁板€?/p>
@property (readonly) bool isnumber;
//鍒ゆ柇姝ゅ璞℃槸鍚︿负瀛楃涓?/p>
@property (readonly) bool isstring;
//鍒ゆ柇姝ゅ璞℃槸鍚︿负object瀵硅薄
@property (readonly) bool isobject;
//鍒ゆ柇姝ゅ璞℃槸鍚︿负鏁扮粍
@property (readonly) bool isarray;
//鍒ゆ柇姝ゅ璞℃槸鍚︿负鏃ユ湡瀵硅薄
@property (readonly) bool isdate;
//姣旇緝涓や釜jsvalue鏄惁鍏ㄧ浉绛?瀵瑰簲javascript涓殑===
- (bool)isequaltoobject:(id)value;
//姣旇緝涓や釜jsvalue瀵硅薄鐨勫€兼槸鍚︾浉绛?瀵瑰簲javascript涓殑==
- (bool)isequalwithtypecoerciontoobject:(id)value;
//鍒ゆ柇鏌愪釜瀵硅薄鏄惁鍦ㄥ綋鍓嶅璞$殑鍘熷瀷閾句笂
- (bool)isinstanceof:(id)value;
//濡傛灉jsvalue鏄疐unction瀵硅薄 鍙互璋冪敤姝ゆ柟娉?鍜孞avascript涓殑call鏂规硶涓€鑷?/p>
- (jsvalue *)callwitharguments:(nsarray *)arguments;
//濡傛灉jsvalue鏄竴涓瀯閫犳柟娉曞璞?鍙互璋冪敤姝ゆ柟娉?鍜孞avascript涓娇鐢╪ew鍏抽敭瀛椾竴鑷?/p>
- (jsvalue *)constructwitharguments:(nsarray *)arguments;
//鐢ㄦ瀵硅薄杩涜鍑芥暟鐨勮皟鐢?褰撳墠瀵硅薄浼氳缁戝畾鍒皌his涓?/p>
- (jsvalue *)invokemethod:(nsstring *)method witharguments:(nsarray *)arguments;
//灏咰gpoint杞崲涓篔svalue瀵硅薄
(jsvalue *)valuewithpoint:(cgpoint)point incontext:(jscontext *)context;
//灏哊srange杞崲涓篔svalue瀵硅薄
(jsvalue *)valuewithrange:(nsrange)range incontext:(jscontext *)context;
//灏咰grect杞崲涓篔svalue瀵硅薄
(jsvalue *)valuewithrect:(cgrect)rect incontext:(jscontext *)context;
//灏咰gsize杞崲涓篔svalue瀵硅薄
(jsvalue *)valuewithsize:(cgsize)size incontext:(jscontext *)context;
//杞崲鎴怌gpoint鏁版嵁
- (cgpoint)topoint;
//杞崲鎴怤srange鏁版嵁
- (nsrange)torange;
//杞崲鎴怌grect鏁版嵁
- (cgrect)torect;
//杞崲涓篊gsize鏁版嵁
- (cgsize)tosize;
//灏咰椋庢牸鐨凧svalueref瀵硅薄杞崲涓篔svalue瀵硅薄
(jsvalue *)valuewithjsvalueref:(jsvalueref)value incontext:(jscontext *)context;
鍏跺疄鍦↗avascriptcore妗嗘灦涓繕鏈変竴涓狫smanagervalue绫伙紝杩欎釜鐨勪富瑕佷綔鐢ㄦ槸绠$悊鍐呭瓨銆傝櫧鐒舵垜浠湪缂栧啓objective-c浠g爜鏃舵湁寮哄ぇ鐨勮嚜鍔ㄥ紩鐢ㄦ妧鏈?arc鎶€鏈?锛屾垜浠竴鑸棤闇€鍏冲績瀵硅薄鐨勫唴瀛橀棶棰橈紝鍦ㄧ紪鍐橨avascript浠g爜鏃朵篃鏈夊己澶х殑鍨冨溇鍥炴敹鏈哄埗(杩欑鏈哄埗涓嬬敋鑷宠繛寰幆寮曠敤閮戒笉鏄棶棰?锛屼絾鏄湪oc鍜孞s娣峰悎寮€鍙戞椂锛屽氨寰堝鏄撳嚭鐜伴棶棰樹簡锛屾瘮濡備竴涓狫s鍨冨溇鍥炴敹鏈哄埗閲婃斁鎺夌殑瀵硅薄oc涓嵈杩樺湪鐢紝鍙嶈繃鏉ヤ篃鏄竴鏍枫€侸smanagervalue瀵笿svalue杩涜浜嗕竴灞傚寘瑁咃紝瀹冨彲浠ヤ繚璇佸湪閫傚悎鏃跺€欎娇鐢ㄨ繖涓璞℃椂瀵硅薄閮戒笉浼氳閲婃斁锛屽叾涓柟娉曞涓嬶細
//鍒涘缓jsvlaue瀵硅薄鐨勫寘瑁匤smanagervalue
(jsmanagedvalue *)managedvaluewithvalue:(jsvalue *)value;
(jsmanagedvalue *)managedvaluewithvalue:(jsvalue *)value andowner:(id)owner;
- (instancetype)initwithvalue:(jsvalue *)value;
//鑾峰彇鎵€鍖呰鐨凧svalue瀵硅薄
@property (readonly, strong) jsvalue *value;
鍏€丱bjective-c涓嶫avascript澶嶆潅瀵硅薄鐨勬槧灏?/p>
聽 聽 鎴戜滑鍦ㄤ娇鐢↗avascript璋冪敤objective-c鏂规硶鐨勫疄璐ㄦ槸灏嗕竴涓狾c鍑芥暟璁剧疆涓轰簡js鍏ㄥ眬瀵硅薄鐨勪竴涓睘鎬э紝褰撶劧鎴戜滑涔熷彲浠ヨ缃潪鍑芥暟鐨勫睘鎬ф垨鑰呬换鎰廕svalue(鎴栬€呭彲浠ヨ浆鎹负jsvalue)鐨勫€笺€備緥濡傦細
self.jscontext = [[jscontext alloc]init];
//鍚慗s鍏ㄥ眬瀵硅薄涓坊鍔犱竴涓幏鍙栧綋鍓峃ative璁惧绫诲瀷鐨勫睘鎬?/p>
[self.jscontext setobject:@"ios" forkeyedsub:@"devicetype"];
浣嗘槸濡傛灉鎴戜滑鎯虫妸oc鑷畾涔夌殑涓€涓被鐨勫璞¤缃负js鍏ㄥ眬瀵硅薄鐨勬煇涓睘鎬э紝js鍜孫c鏈夌潃瀹屽叏涓嶅悓鐨勫璞″師鐞嗭紝濡傛灉涓嶅仛浠讳綍澶勭悊锛孞s鏄帴鏀朵笉鍒癘c瀵硅薄涓畾涔夌殑灞炴€у拰鏂规硶鐨勩€傝繖鏃跺氨闇€瑕佷娇鐢ㄥ埌鍓嶉潰鎻愬埌鐨凧sexport鍗忚锛岄渶瑕佹敞鎰忥紝杩欎釜鍗忚涓嶆槸鐢ㄦ潵琚被閬靛畧鐨勶紝瀹冮噷闈㈡病鏈夎瀹氫换浣曟柟娉曪紝鍏舵槸鐢ㄦ潵琚户鎵垮畾涔夋柊鐨勫崗璁殑锛岃嚜瀹氫箟鐨勫崗璁腑绾﹀畾鐨勬柟娉曞拰灞炴€у彲浠ュ湪js涓鑾峰彇鍒帮紝绀轰緥濡備笅:
oc涓柊寤轰竴涓嚜瀹氫箟鐨勭被锛?/p>
@protocol myobjectprotocol
@property(nonatomic,strong)nsstring * name;
@property(nonatomic,strong)nsstring * subject;
@property(nonatomic,assign)nsinteger age;
-(void)sayhi;
@end
@interface myobject : nsobject
@property(nonatomic,strong)nsstring * name;
@property(nonatomic,strong)nsstring * subject;
@property(nonatomic,assign)nsinteger age;
@end
@implementation myobject
-(void)sayhi{
nslog(@"hello javascript");
}
@end
娣诲姞鍒癑s鍏ㄥ眬瀵硅薄涓細
myobject* object = [myobject new];
object.name = @"jaki";
object.age = 25;
object.subject = @"oc";
[jscontext setobject:object forkeyedsub:@"deviceobject"];
鍦↗s杩愯鐜涓彲浠ュ畬鏁寸殑鍒癲eviceobject瀵硅薄锛屽涓嬶細
涓冦€丆璇█椋庢牸鐨凙pi瑙i噴
聽 聽 javascriptcore妗嗘灦涓櫎浜嗗寘鍚畬鏁寸殑objective-c鍜孲wift璇█鐨凙pi澶栵紝涔熸彁渚涗簡瀵笴璇█鐨勬敮鎸併€?/p>
聽 聽 涓嶫s杩愯鐜鐩稿叧鐨勬柟娉曞涓嬶細
//鍒涘缓涓€涓狫scontextref缁?/p>
/*
jscontextref鐩稿綋浜嶫scontext锛屽悓涓€缁勪腑鐨勬暟鎹彲浠ュ叡浜?/p>
*/
jscontextgroupref jscontextgroupcreate(void);
//鍐呭瓨寮曠敤
jscontextgroupref jscontextgroupretain(jscontextgroupref group);
//鍐呭瓨寮曠敤閲婃斁
void jscontextgrouprelease(jscontextgroupref group);
//鍒涘缓涓€涓叏灞€鐨勮繍琛岀幆澧?/p>
jsglobalcontextref jsglobalcontextcreate(jsclassref globalobjectclass);
//鍚屼笂
jsglobalcontextref jsglobalcontextcreateingroup(jscontextgroupref group, jsclassref globalobjectclass);
//鍐呭瓨寮曠敤
jsglobalcontextref jsglobalcontextretain(jsglobalcontextref ctx);
//鍐呭瓨寮曠敤閲婃斁
void jsglobalcontextrelease(jsglobalcontextref ctx);
//鑾峰彇鍏ㄥ眬瀵硅薄
jsobjectref jscontextgetglobalobject(jscontextref ctx);
//鑾峰彇jscontextref缁?/p>
jscontextgroupref jscontextgetgroup(jscontextref ctx);
//鑾峰彇鍏ㄥ眬鐨勮繍琛岀幆澧?/p>
jsglobalcontextref jscontextgetglobalcontext(jscontextref ctx);
//鑾峰彇杩愯鐜鍚?/p>
jsstringref jsglobalcontextcopyname(jsglobalcontextref ctx);
//璁剧疆杩愯鐜鍚?/p>
void jsglobalcontextsetname(jsglobalcontextref ctx, jsstringref name);
聽 聽 涓庡畾涔塉s瀵硅薄鐨勭浉鍏虫柟娉曞涓嬶細
//瀹氫箟js绫?/p>
/*
鍙傛暟jsclassdefinition鏄竴涓粨鏋勪綋 鍏朵腑鍙互瀹氫箟璁稿鍥炶皟
*/
jsclassref jsclasscreate(const jsclassdefinition* definition);
//寮曠敤鍐呭瓨
jsclassref jsclassretain(jsclassref jsclass);
//閲婃斁鍐呭瓨
void jsclassrelease(jsclassref jsclass);
//鍒涘缓涓€涓狫s瀵硅薄
jsobjectref jsobjectmake(jscontextref ctx, jsclassref jsclass, void* data);
//瀹氫箟js鍑芥暟
jsobjectref jsobjectmakefunctionwithcallback(jscontextref ctx, jsstringref name, jsobjectcallasfunctioncallback callasfunction);
//瀹氫箟鏋勯€犲嚱鏁?/p>
jsobjectref jsobjectmakeconstructor(jscontextref ctx, jsclassref jsclass, jsobjectcallasconstructorcallback callasconstructor);
//瀹氫箟鏁扮粍
jsobjectref jsobjectmakearray(jscontextref ctx, size_t argumentcount, const jsvalueref arguments[], jsvalueref* exception);
//瀹氫箟鏃ユ湡瀵硅薄
jsobjectref jsobjectmakedate(jscontextref ctx, size_t argumentcount, const jsvalueref arguments[], jsvalueref* exception);
//瀹氫箟寮傚父瀵硅薄
jsobjectref jsobjectmakeerror(jscontextref ctx, size_t argumentcount, const jsvalueref arguments[], jsvalueref* exception);
//瀹氫箟姝e垯瀵硅薄
jsobjectref jsobjectmakeregexp(jscontextref ctx, size_t argumentcount, const jsvalueref arguments[], jsvalueref* exception);
//瀹氫箟鍑芥暟瀵硅薄
jsobjectref jsobjectmakefunction(jscontextref ctx, jsstringref name, unsigned parametercount, const jsstringref parameternames[], jsstringref body, jsstringref sourceurl, int startinglinenumber, jsvalueref* exception);
//鑾峰彇瀵硅薄鐨勫睘鎬?/p>
jsvalueref jsobjectgetprototype(jscontextref ctx, jsobjectref object);
//璁剧疆瀵硅薄鐨勫睘鎬?/p>
void jsobjectsetprototype(jscontextref ctx, jsobjectref object, jsvalueref value);
//妫€鏌ュ璞℃槸鍚﹀寘鍚煇涓睘鎬?/p>
bool jsobjecthasproperty(jscontextref ctx, jsobjectref object, jsstringref propertyname);
//鑾峰彇瀵硅薄灞炴€?/p>
jsvalueref jsobjectgetproperty(jscontextref ctx, jsobjectref object, jsstringref propertyname, jsvalueref* exception);
//瀹氫箟瀵硅薄灞炴€?/p>
void jsobjectsetproperty(jscontextref ctx, jsobjectref object, jsstringref propertyname, jsvalueref value, jspropertyattributes attributes, jsvalueref* exception);
//鍒犻櫎瀵硅薄灞炴€?/p>
bool jsobjectdeleteproperty(jscontextref ctx, jsobjectref object, jsstringref propertyname, jsvalueref* exception);
//鑾峰彇鏁扮粍鍊?/p>
jsvalueref jsobjectgetpropertyatindex(jscontextref ctx, jsobjectref object, unsigned propertyindex, jsvalueref* exception);
//璁剧疆鏁扮粍鍊?/p>
void jsobjectsetpropertyatindex(jscontextref ctx, jsobjectref object, unsigned propertyindex, jsvalueref value, jsvalueref* exception);
//鑾峰彇绉佹湁鏁版嵁
void* jsobjectgetprivate(jsobjectref object);
//璁剧疆绉佹湁鏁版嵁
bool jsobjectsetprivate(jsobjectref object, void* data);
//鍒ゆ柇鏄惁涓哄嚱鏁?/p>
bool jsobjectisfunction(jscontextref ctx, jsobjectref object);
//灏嗗璞′綔涓哄嚱鏁版潵璋冪敤
jsvalueref jsobjectcallasfunction(jscontextref ctx, jsobjectref object, jsobjectref thisobject, size_t argumentcount, const jsvalueref arguments[], jsvalueref* exception);
//鍒ゆ柇鏄惁涓烘瀯閫犲嚱鏁?/p>
bool jsobjectisconstructor(jscontextref ctx, jsobjectref object);
//灏嗗璞′綔涓烘瀯閫犲嚱鏁版潵璋冪敤
jsobjectref jsobjectcallasconstructor(jscontextref ctx, jsobjectref object, size_t argumentcount, const jsvalueref arguments[], jsvalueref* exception);
//鑾峰彇鎵€鏈夊睘鎬у悕
jspropertynamearrayref jsobjectcopypropertynames(jscontextref ctx, jsobjectref object);
//杩涜鍐呭瓨寮曠敤
jspropertynamearrayref jspropertynamearrayretain(jspropertynamearrayref array);
//鍐呭瓨閲婃斁
void jspropertynamearrayrelease(jspropertynamearrayref array);
//鑾峰彇灞炴€т釜鏁?/p>
size_t jspropertynamearraygetcount(jspropertynamearrayref array);
//鍦ㄥ睘鎬у悕鏁扮粍涓彇鍊?/p>
jsstringref jspropertynamearraygetnameatindex(jspropertynamearrayref array, size_t index);
//娣诲姞灞炴€у悕
void jspropertynameaccumulatoraddname(jspropertynameaccumulatorref accumulator, jsstringref propertyname);
聽 聽 js鏁版嵁绫诲瀷鐩稿叧瀹氫箟鍦↗svalueref涓紝濡備笅锛?/p>
//鑾峰彇鍊肩殑绫诲瀷
/*
鏋氫妇濡備笅锛?/p>
typedef enum {
kjstypeundefined,
kjstypenull,
kjstypeboolean,
kjstypenumber,
kjstypestring,
kjstypeobject
} jstype;
*/
jstype jsvaluegettype(jscontextref ctx, jsvalueref);
//鍒ゆ柇鏄惁涓簎ndefined绫诲瀷
bool jsvalueisundefined(jscontextref ctx, jsvalueref value);
//鍒ゆ柇鏄惁涓簄ull绫诲瀷
bool jsvalueisnull(jscontextref ctx, jsvalueref value);
//鍒ゆ柇鏄惁涓哄竷灏旂被鍨?/p>
bool jsvalueisboolean(jscontextref ctx, jsvalueref value);
//鍒ゆ柇鏄惁涓烘暟鍊肩被鍨?/p>
bool jsvalueisnumber(jscontextref ctx, jsvalueref value);
//鍒ゆ柇鏄惁涓哄瓧绗︿覆绫诲瀷
bool jsvalueisstring(jscontextref ctx, jsvalueref value);
//鍒ゆ柇鏄惁涓哄璞$被鍨?/p>
bool jsvalueisobject(jscontextref ctx, jsvalueref value);
//鏄惁鏄被
bool jsvalueisobjectofclass(jscontextref ctx, jsvalueref value, jsclassref jsclass);
//鏄惁鏄暟缁?/p>
bool jsvalueisarray(jscontextref ctx, jsvalueref value);
//鏄惁鏄棩鏈?/p>
bool jsvalueisdate(jscontextref ctx, jsvalueref value);
//姣旇緝鍊兼槸鍚︾浉绛?/p>
bool jsvalueisequal(jscontextref ctx, jsvalueref a, jsvalueref b, jsvalueref* exception);
//姣旇緝鍊兼槸鍚﹀叏绛?/p>
bool jsvalueisstrictequal(jscontextref ctx, jsvalueref a, jsvalueref b);
//鏄惁鏄煇涓被鐨勫疄渚?/p>
bool jsvalueisinstanceofconstructor(jscontextref ctx, jsvalueref value, jsobjectref constructor, jsvalueref* exception);
//鍒涘缓undefined鍊?/p>
jsvalueref jsvaluemakeundefined(jscontextref ctx);
//鍒涘缓null鍊?/p>
jsvalueref jsvaluemakenull(jscontextref ctx);
//鍒涘缓甯冨皵鍊?/p>
jsvalueref jsvaluemakeboolean(jscontextref ctx, bool boolean);
//鍒涘缓鏁板€?/p>
jsvalueref jsvaluemakenumber(jscontextref ctx, double number);
//鍒涘缓瀛楃涓插€?/p>
jsvalueref jsvaluemakestring(jscontextref ctx, jsstringref string);
//閫氳繃json鍒涘缓瀵硅薄
jsvalueref jsvaluemakefromjsonstring(jscontextref ctx, jsstringref string);
//灏嗗璞¤浆涓篔son瀛楃涓?/p>
jsstringref jsvaluecreatejsonstring(jscontextref ctx, jsvalueref value, unsigned indent, jsvalueref* exception);
//杩涜甯冨皵鍊艰浆鎹?/p>
bool jsvaluetoboolean(jscontextref ctx, jsvalueref value);
//杩涜鏁板€艰浆鎹?/p>
double jsvaluetonumber(jscontextref ctx, jsvalueref value, jsvalueref* exception);
//瀛楃涓插€艰祴鍊?/p>
jsstringref jsvaluetostringcopy(jscontextref ctx, jsvalueref value, jsvalueref* exception);
//鍊间笌瀵硅薄鐨勮浆鎹?/p>
jsobjectref jsvaluetoobject(jscontextref ctx, jsvalueref value, jsvalueref* exception);
聽 聽 鍦–椋庢牸鐨凙pi涓紝瀛楃涓蹭篃琚寘瑁呮垚浜咼sstringref绫诲瀷锛屽叾涓柟娉曞涓嬶細
//鍒涘缓js瀛楃涓?/p>
jsstringref jsstringcreatewithcharacters(const jschar* chars, size_t numchars);
jsstringref jsstringcreatewithutf8cstring(const char* string);
//鍐呭瓨寮曠敤浜庨噴鏀?/p>
jsstringref jsstringretain(jsstringref string);
void jsstringrelease(jsstringref string);
//鑾峰彇瀛楃涓查暱搴?/p>
size_t jsstringgetlength(jsstringref string);
//杞垚utf8瀛楃涓?/p>
size_t jsstringgetutf8cstring(jsstringref string, char* buffer, size_t buffersize);
//瀛楃涓叉瘮杈?/p>
bool jsstringisequal(jsstringref a, jsstringref b);
bool jsstringisequaltoutf8cstring(jsstringref a, const char* b);
鍏€丠ybird app 鏋勫缓鎬濊矾
聽 聽 hybird app鏄寚娣峰悎妯″紡绉诲姩搴旂敤锛屽嵆鍏朵腑鏃㈠寘鍚師鐢熺殑缁撴瀯鏈夊唴宓屾湁web鐨勭粍浠躲€傝繖绉岮pp涓嶄粎鎬ц兘鍜岀敤鎴蜂綋楠屽彲浠ヨ揪鍒板拰鍘熺敓鎵€宸棤鍑犵殑绋嬪害锛屾洿澶х殑浼樺娍鍦ㄤ簬bug淇蹇紝鐗堟湰杩唬鏃犻渶鍙戠増銆?鏈?鏃ヨ嫻鏋滅粰璁稿寮€鍙戣€呭彂閫佷簡涓€灏佽鍛婇偖浠讹紝涓昏鏄彁绀哄紑鍙戣€呬笅杞借剼鏈姩鎬佹洿鏀笰pp鍘熸湰琛屼负鐨勫仛娉曞皢浼氳鎻愬鎷掔粷銆傚叾瀹炶繖娆¢偖浠舵墍鎻愬唴瀹瑰拰hybird app骞舵棤澶ぇ鍏崇郴(瀵筊eactnative涔熸病鏈夊奖鍝?锛岃嫻鏋滆鍛婄殑鏄綉缁滀笅鍙戣剼鏈苟涓斾娇鐢╮untime鍔ㄦ€佷慨鏀筃ative琛屼负鐨勫簲鐢紝hybird app鐨勫疄璐ㄥ苟娌℃湁淇敼鍘烴ative鐨勮涓猴紝鑰屾槸灏嗕笅鍙戠殑璧勬簮杩涜鍔犺浇鍜岀晫闈㈡覆鏌擄紝绫讳技webview銆?/p>
聽 聽 鍏充簬娣峰悎寮€鍙戯紝鎴戜滑鏈変袱绉嶆ā寮忥細
聽聽聽聽1.native鍐呭祵webview锛岄€氳繃js涓嶰c浜や簰瀹炵幇涓氬姟鏃犵紳鐨勮鎺ャ€?/p>
聽 聽 鏃犺鏄疷iwebview杩樻槸wkwebkit锛屾垜浠兘鍙互鍦ㄥ叾涓嬁鍒板綋鍓嶇殑jscontext锛岀劧鏄娇鐢ㄥ墠闈粙缁嶇殑鏂规硶渚垮彲浠ュ疄鐜版暟鎹簰閫氫笌浜や簰銆傝繖绉嶆柟寮忔槸鏈€绠€鍗曠殑娣峰悎寮€鍙戯紝浣嗗叾鎬ц兘鍜屽師鐢熺浉姣旇宸竴浜涖€傜ず鎰忓浘濡備笅锛?/p>
聽 聽 2.涓嬪彂js鑴氭湰锛屼娇鐢ㄧ被浼糝eactnative鐨勬鏋惰繘琛屽師鐢熸覆鏌?/p>
聽 聽 杩欐槸涓€绉嶆晥鐜囬潪甯搁珮鐨勬贩鍚堝紑鍙戞ā寮忥紝骞朵笖reactnative涔熸湰韬敮鎸乤ndroid鍜宨os鍏敤涓€濂椾唬鐮併€傛垜浠篃鍙互浣跨敤javascriptcore鑷繁瀹炵幇涓€濂楄в鏋愰€昏緫锛屼娇鐢↗avascript鏉ョ紪鍐橬ative搴旂敤锛岃瀹屾暣瀹炵幇杩欐牱涓€濂椾笢瑗垮お澶嶆潅浜嗭紝鎴戜滑涔熸病鏈夎兘鍔涘畬鎴愪竴涓姝ゅ簽澶х殑宸ョ▼锛屼絾鏄垜浠彲浠ュ仛涓€涓皬demo鏉ユā鎷熷叾鍘熺悊锛岃繖鏍峰彲浠ユ洿濂界殑甯姪鎴戜滑鐞嗚вhybird app鐨勬瀯寤哄師鐞嗐€?/p>
鎴戜滑鎵撶畻瀹炵幇杩欐牱鐨勫姛鑳斤細閫氳繃涓嬪彂js鑴氭湰鍒涘缓鍘熺敓鐨刄ilabel鏍囩涓嶶ibutton鎺т欢锛岄鍏堢紪鍐橨s浠g爜濡備笅锛?/p>
(function(){
console.log("progectinit");
//js鑴氭湰鍔犺浇瀹屾垚鍚?鑷姩render鐣岄潰
return render();
})();
//js鏍囩绫?/p>
function label(rect,text,color){
this.rect = rect;
this.text = text;
this.color = color;
this.typename = "label";
}
//js鎸夐挳绫?/p>
function button(rect,text,callfunc){
this.rect = rect;
this.text = text;
this.callfunc = callfunc;
this.typename = "button";
}
//js rect绫?/p>
function rect(x,y,width,height){
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
//js棰滆壊绫?/p>
function color(r,g,b,a){
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
//娓叉煋鏂规硶 鐣岄潰鐨勬覆鏌撳啓鍦ㄨ繖閲岄潰
function render(){
var rect = new rect(20,100,280,30);
var color = new color(1,0,0,1);
var label = new label(rect,"hello world",color);
var rect2 = new rect(20,150,280,30);
var color2 = new color(0,1,0,1);
var label2 = new label(rect2,"hello native",color2);
var rect3 = new rect(20,200,280,30);
var color3 = new color(0,0,1,1);
var label3 = new label(rect3,"hello javascript",color3);
var rect4 = new rect(20,240,280,30);
var button = new button(rect4,"鎴戞槸涓€涓寜閽?,function(){
var randcolor = new color(math.random(),math.random(),math.random(),1);
globle.changebackgroundcolor(randcolor);
});
//灏嗘帶浠朵互鏁扮粍褰㈠紡杩斿洖
return [label,label2,label3,button];
}
鍒涘缓涓€涓狾bjective-c绫荤粦瀹氬埌js鍏ㄥ眬瀵硅薄涓婏紝浣滀负oc鏂规硶鐨勬ˉ鎺ュ櫒锛?/p>
//.h
#import
#import
#import
@protocol globleprptocol
-(void)changebackgroundcolor:(jsvalue *)value;
@end
@interface globle : nsobject
@property(nonatomic,weak)uiviewcontroller * ownercontroller;
@end
//.m
#import "globle.h"
@implementation globle
-(void)changebackgroundcolor:(jsvalue *)value{
self.ownercontroller.view.backgroundcolor = [uicolor colorwithred:value[@"r"].todouble green:value[@"g"].todouble blue:value[@"b"].todouble alpha:value[@"a"].todouble];
}
@end
鍦╒iewcontroller涓疄鐜颁竴涓晫闈㈡覆鏌撶殑render瑙i噴鏂规硶锛屽苟寤虹珛鎸夐挳鐨勬柟娉曡浆鎹紝濡備笅锛?/p>
//
// viewcontroller.m
// javascriptcoretest
//
// created by vip on 17/3/6.
// 威尼斯人2299 copyright 漏 2017骞?jaki. all rights reserved.
//
#import "viewcontroller.h"
#import
#import "globle.h"
@interface viewcontroller ()
@property(nonatomic,strong)jscontext * jscontext;
@property(nonatomic,strong)nsmutablearray * actionarray;
@property(nonatomic,strong)globle * globle;
@end
@implementation viewcontroller
- (void)viewdidload {
[super viewdidload];
//鍒涘缓js杩愯鐜
self.jscontext = [jscontext new];
//缁戝畾妗ユ帴鍣?/p>
self.globle = [globle new];
self.globle.ownercontroller = self;
self.jscontext[@"globle"] = self.globle;
self.actionarray = [nsmutablearray array];
[self render];
}
//鐣岄潰娓叉煋瑙i噴鍣?/p>
-(void)render{
nsstring * path = [[nsbundle mainbundle] pathforresource:@"main" oftype:@"js"];
nsdata * jsdata = [[nsdata alloc]initwithcontentsoffile:path];
nsstring * jscode = [[nsstring alloc]initwithdata:jsdata encoding:nsutf8stringencoding];
jsvalue * jsvlaue = [self.jscontext evaluatescript:jscode];
for (int i=0; i
jsvalue * subvalue = [jsvlaue objectatindexedsub:i];
if ([[subvalue objectforkeyedsub:@"typename"].tostring isequaltostring:@"label"]) {
uilabel * label = [uilabel new];
label.frame = cgrectmake(subvalue[@"rect"][@"x"].todouble, subvalue[@"rect"][@"y"].todouble, subvalue[@"rect"][@"width"].todouble, subvalue[@"rect"][@"height"].todouble);
label.text = subvalue[@"text"].tostring;
label.textcolor = [uicolor colorwithred:subvalue[@"color"][@"r"].todouble green:subvalue[@"color"][@"g"].todouble blue:subvalue[@"color"][@"b"].todouble alpha:subvalue[@"color"][@"a"].todouble];
[self.view addsubview:label];
}else if ([[subvalue objectforkeyedsub:@"typename"].tostring isequaltostring:@"button"]){
uibutton * button = [uibutton buttonwithtype:uibuttontypesystem];
button.frame = cgrectmake(subvalue[@"rect"][@"x"].todouble, subvalue[@"rect"][@"y"].todouble, subvalue[@"rect"][@"width"].todouble, subvalue[@"rect"][@"height"].todouble);
[button settitle:subvalue[@"text"].tostring forstate:uicontrolstatenormal];
button.tag = self.actionarray.count;
[button addtarget:self action:@selector(buttonaction:) forcontrolevents:uicontroleventtouchupinside];
[self.actionarray addobject:subvalue[@"callfunc"]];
[self.view addsubview:button];
}
}
}
//鎸夐挳杞崲鏂规硶
-(void)buttonaction:(uibutton *)btn{
jsvalue * action = self.actionarray[btn.tag];
//鎵цjs鏂规硶
[action callwitharguments:nil];
}
@end
杩愯宸ョ▼锛屾晥鏋滃涓嬪浘鎵€绀猴紝鐐瑰嚮鎸夐挳鍗冲彲瀹炵幇绠€鍗曠殑鐣岄潰棰滆壊鍒囨崲锛?/p>
涓婇潰鐨勭ず渚嬪伐绋嬫垜鍙疄鐜颁簡uilabel绫讳笌uibutton绫荤殑js-oc杞崲锛屽鏋滃皢鍘熺敓鎺т欢鍜孞s瀵硅薄鍐嶈繘琛屼竴灞傜粦瀹氾紝骞朵笖瀹炵幇澶ч儴鍒咼s绫讳笌鍘熺敓绫诲拰浠栦滑鍐呴儴鐨勫睘鎬э紝鍒欐垜浠氨寮€鍙戜簡涓€濂桯ybird app寮€鍙戞鏋讹紝浣嗗苟娌℃湁杩欎釜蹇呰锛屽鏋滀綘瀵规洿澶氬叴瓒o紝鍙互娣卞叆瀛︿範涓婻eactnative銆?/p>
聽 聽 鏂囦腑鐨勭ず渚婦emo鎴戞斁鍦ㄤ簡github涓婏紝鍦板潃濡備笅锛欸ithub - zyhshao/demo-hybird: 娣峰悎寮€鍙戝湪ios涓殑鏋勫缓鎬濊矾demo銆?/p>
鍓嶇瀛︿範鏂颁汉锛屾湁蹇楀悓閬撳悎鐨勬湅鍙嬶紝娆㈣繋浜ゆ祦涓庢寚瀵硷紝qq缇?541458536
杞浇浜? my.oschina /u/2340880/blog/856321
鏂扮殑鐢熷懡鍗冲皢闄嶄复锛岀浉淇″緢澶氭柊鎵嬬埗姣嶉兘鏄棦鍏村鍙堝ソ濂囩殑锛?/p>
浜轰滑寰€寰€浼氭复鏈涙彁鍓嶄竴鐫瑰疂瀹濈殑闈㈠锛屾兂璞$潃瀛╁瓙鐨勭溂鐫涙槸鍚︿細鍍忕埗浜查偅鏍锋槑浜繁閭冿紝鎴栨槸缁ф壙姣嶄翰閭h糠浜虹殑閰掔獫鍜岀鎸虹殑榧绘銆傝繖浠藉鏂扮敓鍎块暱鐩哥殑濂藉锛屾槸姣忎竴瀵瑰噯鐖舵瘝鍐呭績娣卞鏃犳硶鎶楁嫆鐨勬儏鎰熸稛婕€?/p>
鐜板湪锛屽緢澶氳蒋浠跺彲浠ヤ负浣犱竴閿敓鎴愭湭鏉ュ疂瀹濋暱鐩搁娴嬬収鐗囷紝婊¤冻浣犺繖浠芥儏鎰熼渶姹傘€?/p>
鍒姽璞簡锛屽揩鏉ョ湅鐪嬩粈涔堣蒋浠惰兘璁╀綘鎻愬墠涓€鐫瑰疂瀹濈殑鍙埍妯℃牱鍚э紒
馃崈baby picture maker馃崈
猸愯蒋浠朵粙缁嶁瓙
涓€娆句笓闂ㄧ敤浜庨娴嬪疂瀹濋暱鐩哥殑杞欢銆傚畠閫氳繃鐖舵瘝鎻愪緵鐨勭収鐗囧拰瀹濆疂鐨勮偆鑹层€佹€у埆绛夌壒寰侊紝鍒╃敤浜哄伐鏅鸿兘鎶€鏈繘琛岄潰閮ㄨ瘑鍒拰鏁版嵁姣斿锛岀敓鎴愬疂瀹濇湭鏉ョ殑鍙兘闀跨浉銆?/p>
猸愭搷浣滄祦绋嬧瓙
1.鎵撳紑杞欢锛岄€夋嫨鈥淐reate new project鈥濆垱寤轰竴涓柊椤圭洰銆?/p>
2.鐐瑰嚮鈥淚mport鈥濇寜閽紝瀵煎叆瀹濆疂鐖舵瘝鐨勭収鐗囥€傝繖閲屾敞鎰忚涓婁紶姝i潰鐓х墖锛岄渶瑕佽兘鐪嬪埌浜斿畼銆?/p>
3.鐐瑰嚮鈥淐ontinue鈥濇寜閽悗锛岃蒋浠朵細鏍规嵁浣犲拰浼翠荆鐨勭収鐗囩敓鎴愬疂瀹濈殑鐓х墖銆?/p>
猸愬姛鑳戒紭鍔库瓙
鈶犱釜鎬у寲瀹氬埗锛氶櫎浜嗛粯璁ょ殑棰勬祴鍔熻兘澶栵紝璇ヨ蒋浠惰繕鍏佽鐢ㄦ埛鏍规嵁鐖舵瘝鐨勯潰閮ㄧ壒寰佽繘琛屼釜鎬у寲瀹氬埗锛屼娇棰勬祴缁撴灉鏇寸鍚堢敤鎴风殑鏈熸湜銆?/p>
鈶′繚瀛樺拰鍒嗕韩鍔熻兘锛氱敤鎴峰彲浠ュ皢鐢熸垚鐨勫疂瀹濋娴嬬収鐗囦繚瀛樹笅鏉ワ紝鐣欎綔绾康鎴栦笌浜插弸鍒嗕韩銆傝杞欢杩樻彁渚涗簡绀句氦濯掍綋鍒嗕韩鍔熻兘锛屾柟渚跨敤鎴峰皢瀹濆疂鐨勫彲鐖辨ā鏍峰垎浜粰鏇村浜恒€?/p>
馃崈nicepic馃崈
猸愯蒋浠朵粙缁嶁瓙
涓€娆鹃泦缇庨銆佹护闀溿€佷慨澶嶇瓑鍔熻兘浜庝竴浣撶殑搴旂敤锛岀壒鍒€傚悎鍠滄鎷嶇収骞跺笇鏈涘鑷繁鐨勭収鐗囪繘琛岀編鍖栧拰缂栬緫鐨勭敤鎴枫€傚畠鎻愪緵浜嗕赴瀵岀殑淇宸ュ叿鍜岀壒鏁堬紝鍖呮嫭鑰佺収鐗囦慨澶嶅拰鍥剧墖娴佸姩绛夈€傜敤鎴峰彲浠ラ€夋嫨涓嶅悓鐨勬晥鏋滃拰宸ュ叿锛屽鐓х墖杩涜缁嗚嚧鐨勮皟鏁村拰缇庡寲锛屼娇鐓х墖鏇村姞浜附銆佸姩浜恒€?/p>
猸愭搷浣滄祦绋嬧瓙
1.鍦ㄦ墜鏈轰笂鎵撳紑nicepic杞欢銆?/p>
2.鍦ㄨ蒋浠堕椤典腑锛屾壘鍒板苟鐐瑰嚮鈥滈娴嬪疂瀹濋暱鐩糕€濆姛鑳姐€?/p>
3.涓婁紶瀛╁瓙褰╄秴鐨勮繎鏈熺収鐗囧悗锛岀偣鍑烩€滀笅涓€姝モ€滄寜閽€?/p>
4.绛夊緟杞欢鐢熸垚棰勬祴鐨勫疂瀹濋暱鐩哥収鐗囧嵆鍙€?/p>
猸愬姛鑳戒紭鍔库瓙
鈶犵畝渚挎槗鐢細杩欎簺杞欢鐣岄潰鍙嬪ソ锛屾搷浣滅畝鍗曪紝鍙渶涓婁紶鐓х墖骞堕€夋嫨涓€浜涚壒寰侊紝鍗冲彲蹇€熺敓鎴愰娴嬬粨鏋溿€?/p>
鈶¢€肩湡搴︼細杞欢鍛堢幇鐨勫疂瀹濈収鐗囬潪甯搁€肩湡锛屽鍚岀湡瀹炵収鐗囦竴鏍凤紝璁╂柊鎵嬬埗姣嶅彲浠ユ竻鏅板湴鐪嬪埌鏈潵瀹濆疂鐨勬牱瀛愩€?/p>
鏈変簡杩欎袱娆捐兘澶熺敓鎴愭湭鏉ュ疂瀹濋暱鐩搁娴嬬収鐗囩殑杞欢锛屼笉浠呰兘婊¤冻鏂版墜鐖舵瘝鐨勫ソ濂囧績锛岃繕鑳藉娣绘洿澶氱殑鍠滄偊鍜屾湡寰呫€傝鎴戜滑涓€鍚屾湡寰呮柊鐢熷懡鐨勫埌鏉ュ惂锛?/p>
还没有评论,来说两句吧...