手机推特怎么使用-威尼斯人2299

网络节点

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 *)key;

//灏咰璇█鐜鐨凧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>

文章威尼斯人2299的版权声明:除非注明,否则均为网络节点原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复: 表情:
addoilapplausebadlaughbombcoffeefabulousfacepalmfecesfrownheyhainsidiouskeepfightingnoprobpigheadshockedsinistersmileslapsocialsweattolaughwatermelonwittywowyeahyellowdog
评论列表 (暂无评论,23人围观)

还没有评论,来说两句吧...

网站地图