Best Mockingbird code snippet using NSObject
FoundationViewController.swift
Source:FoundationViewController.swift
...10class FoundationViewController: UIViewController {11 override func viewDidLoad() {12 super.viewDidLoad()13 // Do any additional setup after loading the view.14 //1.NSArray(Class-NSObject) 表示éææåºéåç对象ï¼ç¨äºå¨éè¦å¼ç¨è¯ä¹çæ
åµä¸ä»£æ¿æ°ç»å¸¸éã --Array(Generic Structure) ä¸ä¸ªæåºçãéæºè®¿é®çéåã15 //2.NSAttributedString(Class-NSObject) å
·æä¸å
¶ææ¬é¨åç¸å
³å±æ§(å¦è§è§æ ·å¼ãè¶
é¾æ¥æå¯è®¿é®æ§æ°æ®)çå符串ã16 //3.NSBundle(Class-NSObject) --Bundle(Class-NSObject) åå¨å¨ç£çä¸bundleç®å½ä¸ç代ç åèµæºç表示形å¼ã17 //4.NSByteCountFormatter(Class-NSFormatter) ä¸ç§æ ¼å¼åç¨åºï¼å®å°åè计æ°å¼è½¬æ¢ä¸ºä½¿ç¨éå½çåè修饰符(KBãMBãGBç)è¿è¡æ ¼å¼åçæ¬å°åæè¿°ã18 //5.NSByteOrder(enum) æå®åè顺åºæ ¼å¼ç常éã --ByteOrder(Enumeration-unsigned int) è¯å«æå®åè顺åºæ ¼å¼ç常éã19 //6.NSCache(Class-NSObject) ä¸ä¸ªå¯åéåï¼ç¨äºä¸´æ¶åå¨å¨èµæºä¸è¶³æ¶æ被驱éç临æ¶é®å¼å¯¹ã --Cache(Structure)20 //7.NSCalendar(Class-NSObject) ä¸ä¸ªå¯¹è±¡ï¼å®ä¹æ¥ååä½(å¦å¹´ä»£ã年份åå·¥ä½æ¥)åæ¶é´ç»å¯¹å¼ä¹é´çå
³ç³»ï¼æä¾è®¡ç®åæ¯è¾æ¥æçåè½ã --Calendar(Structure) å®ä¹æ¥ååä½(å¦å¹´ä»£ã年份åå·¥ä½æ¥)ä¸æ¶é´ç»å¯¹å¼ä¹é´çå
³ç³»ï¼æä¾è®¡ç®åæ¯è¾æ¥æçåè½ã21 //8.NSCharacterSet(Class-NSObject) 表示è¿æ¥å°å符éçä¸ç»åºå®Unicodeå符å¼ç对象;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSCharacterSetã --CharacterSet(Structure) ç¨äºæç´¢æä½çä¸ç»Unicodeå符å¼ã22 //9.NSCoder(Class-NSObject) ä¸ä¸ªæ½è±¡ç±»ï¼ä½ä¸ºå¯¹è±¡çåºç¡ï¼æ¯æ对å
¶ä»å¯¹è±¡è¿è¡å½æ¡£åååã23 //10.NSComparisonPredicate(Class-NSPredicate) ç¨äºæ¯è¾è¡¨è¾¾å¼çä¸ç¨è°è¯ã24 //11.NSCompoundPredicate(Class-NSPredicate) 计ç®å
¶ä»è°è¯é»è¾ç»åçä¸ç¨è°è¯ã25 //12.NSData(Class-NSObject) è¿æ¥å°æ°æ®çéæåèç¼å²åº;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSDataã --Data(Structure) å
åä¸çåèç¼å²åºã26 //13.NSDate(Class-NSObject) è¿æ¥å°æ¥æçç¹å®æ¶é´ç¹ç表示;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSDateã --Date(Structure) ä¸ä¸ªç¹å®çæ¶é´ç¹ï¼ç¬ç«äºä»»ä½æ¥åææ¶åºã27 //14.NSDateComponentsFormatter(Class-NSFormatter) å建æ¶é´éçå符串表示形å¼çæ ¼å¼åç¨åºã --DateComponentsFormatter(Class-Formatter) å建æ¶é´éçå符串表示形å¼çæ ¼å¼åç¨åºã28 //15.NSDateFormatter(Class-NSFormatter) å¨æ¥æåå
¶ææ¬è¡¨ç¤ºä¹é´è¿è¡è½¬æ¢çæ ¼å¼åç¨åºã --DateFormatter(Class-Formatter) å¨æ¥æåå
¶ææ¬è¡¨ç¤ºä¹é´è¿è¡è½¬æ¢çæ ¼å¼åç¨åºã29 //16.NSDateInterval(Class-NSObject) 表示è¿æ¥å°DateIntervalç两个æ¥æä¹é´çæ¶é´è·¨åº¦ç对象;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSDateIntervalã --DateInterval(Structure) ä»ç¹å®çå¼å§æ¥æå°ç»ææ¥æä¹é´çæ¶é´è·¨åº¦ã30 //17.NSDateIntervalFormatter(Class-NSFormatter) ä¸ç§æ ¼å¼åç¨åºï¼å®å建æ¶é´é´éçå符串表示形å¼ã --DateIntervalFormatter(Class-Formatter) ä¸ç§æ ¼å¼åç¨åºï¼å®å建æ¶é´é´éçå符串表示形å¼ã31 //18.NSDecimal(Structure) 表示以10为åºæ°çæ°åçç»æã --Decimal(Structure) 表示以10为åºæ°çæ°åçç»æã32 //19.NSDecimalNumber(Class-NSNumber) ä¸ç§å¯¹è±¡ï¼ç¨äºè¡¨ç¤ºåæ§è¡åºäºåè¿å¶çåè¿å¶æ°çç®æ¯;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSDecimalNumberã33 //20.NSDictionary(Class-NSObject) 表示é®å¼å¯¹çéæéåç对象ï¼ç¨äºå¨éè¦å¼ç¨è¯ä¹çæ
åµä¸ä»£æ¿åå
¸å¸¸éã --Dictionary(Generic Structure) å
ç´ æ¯é®å¼å¯¹çéåã34 //21.NSEnergyFormatter(Class-NSFormatter) æä¾è½éå¼æ¬å°åæè¿°çæ ¼å¼åç¨åºã --EnergyFormatter(Class-Formatter) æä¾è½éå¼æ¬å°åæè¿°çæ ¼å¼åç¨åºã35 //22.NSEnumerator(Class-NSObject) ä¸ä¸ªæ½è±¡ç±»ï¼å
¶åç±»æ举对象éåï¼å¦æ°ç»ååå
¸ã36 //23.NSError(Class-NSObject) æå
³é误æ¡ä»¶çä¿¡æ¯ï¼å
æ¬åãç¹å®äºåçé误代ç åç¹å®äºåºç¨ç¨åºçä¿¡æ¯ã --Error(Protocol) 表示å¯ä»¥æåºçé误å¼çç±»åã37 //24.NSException(Class-NSObject) 表示ä¸æç¨åºæ£å¸¸æ§è¡æµç¨çç¹æ®æ¡ä»¶ç对象ã38 //25.NSExpression(Class-NSObject) ç¨äºæ¯è¾è°è¯ä¸ç表达å¼ã39 //26.NSExtensionContext(Class-NSObject) è°ç¨åºç¨ç¨åºæ©å±ç宿主åºç¨ç¨åºä¸ä¸æã40 //27.NSExtensionItem(Class-NSObject) 表示æ©å±è¦æä½ç项çä¸åæ¹é¢çä¸å¯åå¼éåã41 //28.NSExtensionRequestHandling(Protocol) åºç¨ç¨åºæ©å±ç¨æ¥ååºæ¥èªä¸»æºåºç¨ç¨åºç请æ±çæ¥å£ã42 //29.NSFileCoordinator(Class-NSObject) åè°æ件æ¼ç¤ºç¨åºä¹é´æ件åç®å½ç读åååå
¥ç对象ã43 //30.NSFileHandle(Class-NSObject) æ件æ述符çé¢å对象å
è£
å¨ã --FileHandle æ件æ述符çé¢å对象å
è£
å¨ã44 //31.NSFileManager(Class-NSObject) ä¸ä¸ªæ¹ä¾¿çæ件系ç»å
容æ¥å£ï¼ä»¥åä¸ä¹äº¤äºç主è¦æ¹å¼ã --FileManager ä¸ä¸ªæ¹ä¾¿çæ件系ç»å
容æ¥å£ï¼ä»¥åä¸ä¹äº¤äºç主è¦æ¹å¼ã45 //32.NSFilePresenter(Protocol) æ件åè°å¨ç¨äºéç¥åç°æ件ç对象æå
³è¯¥æ件å¨ç³»ç»å
¶ä»å°æ¹æä½æ´æ¹çæ¥å£ã46 //33.NSFileVersion(Class-NSObject) æ件å¨ç¹å®æ¶é´ç¹çå¿«ç
§ã47 //34.NSFileWrapper(Class-NSObject) æ件系ç»ä¸èç¹(æ件ãç®å½æ符å·é¾æ¥)ç表示ã --FileWrapper(Class-NSObject) æ件系ç»ä¸èç¹(æ件ãç®å½æ符å·é¾æ¥)ç表示ã48 //35.NSFormatter(Class-NSObject) ä¸ä¸ªæ½è±¡ç±»ï¼ä¸ºå建ã解éåéªè¯å¼çææ¬è¡¨ç¤ºç对象声ææ¥å£ã --Formatter(Class-NSObject) ä¸ä¸ªæ½è±¡ç±»ï¼ä¸ºå建ã解éåéªè¯å¼çææ¬è¡¨ç¤ºç对象声ææ¥å£ã49 //36.NSHTTPCookie(Class-NSObject) 代表ä¸ä¸ªHTTP cookieã --HTTPCookie(Class-NSObject) 代表ä¸ä¸ªHTTP cookieã50 //37.NSHTTPCookieStorage(Class-NSObject) 管çcookieåå¨ç容å¨ã --HTTPCookieStorage(Class-NSObject) 管çcookieåå¨ç容å¨ã51 //38.NSHashTable(Generic Class-NSObject) 类似äºéåçéåï¼ä½å
·ææ´å¹¿æ³çå¯ç¨å
åè¯ä¹ã52 //39.NSISO8601DateFormatter(Class-NSFormatter) å¨æ¥æåå
¶ISO 8601å符串表示形å¼ä¹é´è¿è¡è½¬æ¢çæ ¼å¼åç¨åºã --ISO8601DateFormatter(Class-Formatter) å¨æ¥æåå
¶ISO 8601å符串表示形å¼ä¹é´è¿è¡è½¬æ¢çæ ¼å¼åç¨åºã53 //40.NSIndexPath(Class-NSObject) å
å«è¿æ¥å°IndexPathçç´¢å¼å表ç对象;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSIndexPathã --IndexPath(Structure) ç´¢å¼å表ï¼è¿äºç´¢å¼ä¸èµ·è¡¨ç¤ºå°åµå¥æ°ç»æ ä¸çç¹å®ä½ç½®çè·¯å¾ã54 //41.NSIndexSet(Class-NSObject) 表示è¿æ¥å°IndexSetçæä¸æ´æ°å¼çä¸å¯åéåç对象;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSIndexSetã --IndexSet(Structure) 表示å¦ä¸ä¸ªéåä¸å
ç´ ç´¢å¼çå¯ä¸æ´æ°å¼çéåã55 //42.NSInvocation(Class-NSObject) ä½ä¸ºå¯¹è±¡åç°çObjective-Cæ¶æ¯ã56 //43.NSItemProvider(Class-NSObject) å¨ææ¾æå¤å¶/ç²è´´æ´»å¨æé´è¿ç¨ä¹é´ä¼ è¾æ°æ®ææ件ç项æä¾ç¨åºï¼æä»ä¸»æºåºç¨ç¨åºå°åºç¨ç¨åºæ©å±ç¨åºã57 //44.NSJSONSerialization(Class-NSObject) å¨JSONåçæåºç¡å¯¹è±¡ä¹é´è½¬æ¢ç对象ã --JSONSerialization(Class-NSObject) å¨JSONåçæåºç¡å¯¹è±¡ä¹é´è½¬æ¢ç对象ã58 //45.NSKeyedArchiver(Class-NSCoder) å°å¯¹è±¡çæ°æ®åå¨å°é®æå¼ç¨çå½æ¡£æ件ä¸çç¼ç å¨ã59 //46.NSLengthFormatter(Class-NSFormatter) ä¸ç§æ ¼å¼åç¨åºï¼æä¾çº¿æ§è·ç¦»çæ¬å°åæè¿°ï¼å¦é¿åº¦åé«åº¦æµéã --LengthFormatter(Class-Formatter) ä¸ç§æ ¼å¼åç¨åºï¼æä¾çº¿æ§è·ç¦»çæ¬å°åæè¿°ï¼å¦é¿åº¦åé«åº¦æµéã60 //47.NSLinguisticTagger(Class-NSObject) åæèªç¶è¯è¨ææ¬ï¼æ è®°é¨åè¯é³åè¯æ±ç±»ï¼è¯å«å称ï¼è¿è¡å¼çï¼ç¡®å®è¯è¨åèæ¬ã61 //48.NSLocale(Class-NSObject) 表示è¯è¨ãæååææ¯çº¦å®ä¿¡æ¯ç对象ï¼è¿äºä¿¡æ¯è¿æ¥å°ç°åº;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSLocaleã --Locale(Structure) æå
³ç¨äºæ ¼å¼åæ°æ®ä»¥ä¾è¡¨ç¤ºçè¯è¨ãæååææ¯çº¦å®çä¿¡æ¯ã62 //49.NSLock(Class-NSObject) åè°åä¸åºç¨ç¨åºä¸å¤ä¸ªæ§è¡çº¿ç¨çæä½ç对象ã63 //50.NSMapTable(Generic Class-NSObject) 类似äºåå
¸çéåï¼ä½å
·ææ´å¹¿æ³çå¯ç¨å
åè¯ä¹ã64 //51.NSMassFormatter(Class-NSFormatter) æä¾è´¨éåæéå¼çæ¬å°åæè¿°çæ ¼å¼åç¨åºã --MassFormatter(Class-Formatter) æä¾è´¨éåæéå¼çæ¬å°åæè¿°çæ ¼å¼åç¨åºã65 //52.NSMeasurement(Class-NSObject) ç¨è¿æ¥å°æµéçæµéåä½è¡¨ç¤ºæ°åéç对象;å½æ¨éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSMeasurementã --Measurement(Generic Structure) 带æ度éåä½çæ°åéï¼æ¯æåä½è½¬æ¢ååä½æç¥è®¡ç®ã66 //53.NSMeasurementFormatter(Class-NSFormatter) æä¾åå
å度éçæ¬å°å表示çæ ¼å¼åç¨åºã --MeasurementFormatter(Class-Formatter) æä¾åå
å度éçæ¬å°å表示çæ ¼å¼åç¨åºã67 //54.NSMethodSignature(Class-NSObject) æ¹æ³çè¿åå¼ååæ°çç±»åä¿¡æ¯çè®°å½ã68 //55.NSNotification(Class-NSObject) éè¿éç¥ä¸å¿åææ注åçè§å¯è
广æä¿¡æ¯ç容å¨ã --Notification(Structure) éè¿éç¥ä¸å¿åææ注åçè§å¯è
广æä¿¡æ¯ç容å¨ã69 //56.NSNotificationQueue(Class-NSObject) éç¥ä¸å¿ç¼å²åºã --NotificationQueue(Class-NSObject) éç¥ä¸å¿ç¼å²åºã70 //57.NSNull(Class-NSObject) ä¸ä¸ªåä¾å¯¹è±¡ï¼ç¨äºè¡¨ç¤ºä¸å
许空å¼çéå对象ä¸ç空å¼ã71 //58.NSNumberFormatter(Class-NSFormatter) å¨æ°å¼åå
¶ææ¬è¡¨ç¤ºå½¢å¼ä¹é´è¿è¡è½¬æ¢çæ ¼å¼åç¨åºã --NumberFormatter(Class-Formatter) å¨æ°å¼åå
¶ææ¬è¡¨ç¤ºå½¢å¼ä¹é´è¿è¡è½¬æ¢çæ ¼å¼åç¨åºã72 //59.NSObject(Class) 大å¤æ°Objective-Cç±»å±æ¬¡ç»æçæ ¹ç±»ï¼åç±»ä»æ ¹ç±»ç»§æ¿å°è¿è¡æ¶ç³»ç»çåºæ¬æ¥å£ä»¥åä½ä¸ºObjective-C对象çè½åã --Object(Class)73 //60.NSOperation(Class-NSObject) 表示ä¸å个任å¡å
³èç代ç åæ°æ®çæ½è±¡ç±»ã --Operation(Class-NSObject) 表示ä¸å个任å¡å
³èç代ç åæ°æ®çæ½è±¡ç±»ã74 //61.NSOrderedSet(Class-NSObject) å¯ä¸å¯¹è±¡çéææåºéåã75 //62.NSOrthography(Class-NSObject) 对èªç¶è¯è¨ææ¬çè¯è¨å
容çæè¿°ï¼é常ç¨äºæ¼ååè¯æ³æ£æ¥ã76 //63.NSPersonNameComponents(Class-NSObject) ä¸ä¸ªå¯¹è±¡ï¼å®ç®¡ç人åå§åçå个é¨åï¼ä»¥å
许设置ä¸è¯è¨ç¯å¢ç¸å
³çæ ¼å¼ã --PersonNameComponents(Structure) ä¸ä¸ªäººå§åçåç¬é¨åï¼å
许æ¬å°åæ ¼å¼ã77 //64.NSPersonNameComponentsFormatter(Class-NSFormatter) æä¾äººåçç»ä»¶çæ¬å°å表示çæ ¼å¼åç¨åºã --PersonNameComponentsFormatter(Class-Formatter) æä¾äººåçç»ä»¶çæ¬å°å表示çæ ¼å¼åç¨åºã78 //65.NSPointerArray(Class-NSObject) 类似äºæ°ç»çéåï¼ä½å
·ææ´å¹¿æ³çå¯ç¨å
åè¯ä¹ã79 //66.NSPointerFunctions(Class-NSObject) NSPointerFunctionsçä¸ä¸ªå®ä¾å®ä¹äºéåäºç®¡çå
¶ä»å°æ¹çæéå¼ç¨çcalloutå½æ°ã80 //67.NSPort(Class-NSObject) 表示éä¿¡ééçæ½è±¡ç±»ã --Port(Class-NSObject) 表示éä¿¡ééçæ½è±¡ç±»ã81 //68.NSPredicate(Class-NSObject) ä¸ç§é»è¾æ¡ä»¶çå®ä¹ï¼ç¨äºçº¦ææ£ç´¢æå
åçéã82 //69.NSProcessInfo(Class-NSObject) å
³äºå½åè¿ç¨çä¿¡æ¯çéåã --ProcessInfo(Class-NSObject) å
³äºå½åè¿ç¨çä¿¡æ¯çéåã83 //70.NSProgress(Class-NSObject) åç¨æ·ä¼ éç»å®ä»»å¡æ£å¨è¿è¡çè¿åº¦ç对象ã --Progress(Class-NSObject) åç¨æ·ä¼ éç»å®ä»»å¡æ£å¨è¿è¡çè¿åº¦ç对象ã84 //71.NSProxy(Class) ä¸ä¸ªæ½è±¡è¶
ç±»ï¼ä¸ºå
å½å
¶ä»å¯¹è±¡æå°ä¸åå¨ç对象çæ¿èº«ç对象å®ä¹APIã85 //72.NSRange(Structure) ç¨äºæè¿°ç³»åçä¸é¨åçç»æï¼å¦å符串ä¸çå符ææ°ç»ä¸ç对象ã --Range(Generic Structure) ä»ä¸çå°ä¸ççåå¼åºé´ï¼ä½ä¸å
æ¬ä¸çã86 //73.NSRegularExpression(Class-NSObject) åºç¨äºUnicodeå符串çå·²ç¼è¯æ£å表达å¼çä¸å¯å表示ã87 //74.NSRunLoop(Class-NSObject) 管çè¾å
¥æºç对象çç¼ç¨æ¥å£ã --RunLoop(Class-NSObject) 管çè¾å
¥æºç对象çç¼ç¨æ¥å£ã88 //75.NSScanner(Class-NSObject) ä¸ç§å符串åæå¨ï¼ç¨äºæ«æå符éä¸çåå符串æå符ï¼ä»¥ååè¿å¶ãåå
è¿å¶åæµ®ç¹è¡¨ç¤ºæ³ä¸çæ°å¼ã --Scanner(Class-NSObject) ä¸ç§å符串åæå¨ï¼ç¨äºæ«æå符éä¸çåå符串æå符ï¼ä»¥ååè¿å¶ãåå
è¿å¶åæµ®ç¹è¡¨ç¤ºæ³ä¸çæ°å¼ã89 //76.NSSet(Class-NSObject) 表示éæãæ åºãæä¸éåç对象ï¼ç¨äºå¨éè¦å¼ç¨è¯ä¹çæ
åµä¸ä»£æ¿éå常éã --Set(Generic Structure) å¯ä¸å
ç´ çæ åºéåã90 //77.NSSortDescriptor(Class-NSObject) å¦ä½åºäºææ对象çå
Œ
±å±æ§å¯¹å¯¹è±¡éåæåºçä¸å¯åæè¿°ã91 //78.NSStream(Class-NSObject) 表示æµçæ½è±¡ç±»ã --Stream(Class-NSObject) 表示æµçæ½è±¡ç±»ã92 //79.NSString(Class-NSObject) è¿æ¥å°å符串çéæ纯ææ¬Unicodeå符串对象;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSStringã --String(Structure) ä¸ä¸ªUnicodeå符串å¼ï¼å®æ¯å符çéåã93 //80.NSTextCheckingResult(Class-NSObject) å¨åæææ¬åæ¶åç°çææ¬å
容çä¸ç§ç°è±¡ï¼å¦å¹é
æ£å表达å¼æ¶ã94 //81.NSThread(Class-NSObject) æ§è¡çº¿ç¨ã --Thread(Class-NSObject) æ§è¡çº¿ç¨ã95 //82.NSTimeZone(Class-NSObject) æå
³è¿æ¥å°æ¶åºçæ¬å°æ¶é´çº¦å®çä¿¡æ¯;å½æ¨éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼è¯·ä½¿ç¨NSTimeZoneã --TimeZone(Structure) æå
³ä¸ç¹å®å°ç¼æ¿æ²»åºåç¸å
³çæ åæ¶é´çº¦å®çä¿¡æ¯ã96 //83.NSTimer(Class-NSObject) å¨ç»è¿ä¸å®æ¶é´é´éå触åç计æ¶å¨ï¼åç®æ 对象åéæå®çæ¶æ¯ã --Timer(Class-NSObject) å¨ç»è¿ä¸å®æ¶é´é´éå触åç计æ¶å¨ï¼åç®æ 对象åéæå®çæ¶æ¯ã97 //84.NSURL(Class-NSObject) 表示è¿æ¥å°URLçèµæºçä½ç½®ç对象;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSURLã --URL(Structure) æ è¯èµæºä½ç½®çå¼ï¼å¦è¿ç¨æå¡å¨ä¸ç项æå°æ¬å°æ件çè·¯å¾ã98 //85.NSURLAuthenticationChallenge(Class-NSObject) æ¥èªæå¡å¨çææï¼éè¦æ¥èªå®¢æ·æºç身份éªè¯ã --URLAuthenticationChallenge(Class-NSObject) æ¥èªæå¡å¨çææï¼éè¦æ¥èªå®¢æ·æºç身份éªè¯ã99 //86.NSURLCache(Class-NSObject) å°URL请æ±æ å°å°ç¼åçååºå¯¹è±¡ç对象ã --URLCache(Class-NSObject) å°URL请æ±æ å°å°ç¼åçååºå¯¹è±¡ç对象ã100 //87.NSURLConnection(Class-NSObject) 使æ¨è½å¤å¯å¨ååæ¢URL请æ±ç对象ã101 //88.NSURLCredential(Class-NSObject) ç±ç¹å®äºåæ®ç±»ååè¦ä½¿ç¨çæä¹
æ§åå¨ç±»å(å¦ææçè¯)çä¿¡æ¯ç»æç身份éªè¯åæ®ã --URLCredential(Class-NSObject) ç±ç¹å®äºåæ®ç±»ååè¦ä½¿ç¨çæä¹
æ§åå¨ç±»å(å¦ææçè¯)çä¿¡æ¯ç»æç身份éªè¯åæ®ã102 //89.NSURLCredentialStorage(Class-NSObject) å
±äº«åæ®ç¼åç管çå¨ã --URLCredentialStorage(Class-NSObject) å
±äº«åæ®ç¼åç管çå¨ã103 //90. --URLError(Structure) URLå è½½apiè¿åçé误代ç ã104 //91.NSURLProtectionSpace(Class-NSObject) æå¡å¨ä¸éè¦èº«ä»½éªè¯çæå¡å¨æåºåï¼é常称为é¢åã URLProtectionSpace(Class-NSObject) æå¡å¨ä¸éè¦èº«ä»½éªè¯çæå¡å¨æåºåï¼é常称为é¢åã105 //92.NSURLProtocol(Class-NSObject) å¤çå è½½ç¹å®äºåè®®çURLæ°æ®çæ½è±¡ç±»ã --URLProtocol(Class-NSObject) å¤çå è½½ç¹å®äºåè®®çURLæ°æ®çæ½è±¡ç±»ã106 //93.NSURLRequest(Class-NSObject) å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ä½¿ç¨çURLå 载请æ±ç表示ã --URLRequest(Structure) ç¬ç«äºåè®®æURLæ¹æ¡çURLå 载请æ±ã107 //94.NSURLResponse(Class-NSObject) ä¸ååºURLå 载请æ±ç¸å
³èçå
æ°æ®ï¼ç¬ç«äºåè®®åURLæ¹æ¡ã --URLResponse(Class-NSObject) ä¸ååºURLå 载请æ±ç¸å
³èçå
æ°æ®ï¼ç¬ç«äºåè®®åURLæ¹æ¡ã108 //95.NSURLSession(Class-NSObject) åè°ä¸ç»ç¸å
³ç½ç»æ°æ®ä¼ è¾ä»»å¡ç对象ã --URLSession(Class-NSObject) åè°ä¸ç»ç¸å
³ç½ç»æ°æ®ä¼ è¾ä»»å¡ç对象ã109 //96.NSUUID(Class-NSObject) 表示è¿æ¥å°UUIDçæ®éæä¸å¼ç对象;å½éè¦å¼ç¨è¯ä¹æå
¶ä»ç¹å®äºåºç¡çè¡ä¸ºæ¶ï¼ä½¿ç¨NSUUIDã --UUID(Structure) ä¸ä¸ªéç¨çæä¸å¼ï¼å¯ç¨äºæ è¯ç±»åãæ¥å£åå
¶ä»é¡¹ã110 //97.NSUbiquitousKeyValueStore(Class-NSObject) åºäºicloudçé®å¼å¯¹å®¹å¨ï¼ç¨äºå¨ç¨æ·è¿æ¥ç设å¤ä¸è¿è¡çåºç¨ç¨åºå®ä¾ä¹é´å
±äº«æ°æ®ã111 //98.NSUndoManager(Class-NSObject) ä¸ç§éç¨çæä½è®°å½å¨ï¼æ¯ææ¤æ¶åéåã --UndoManager(Class-NSObject) ä¸ç§éç¨çæä½è®°å½å¨ï¼æ¯ææ¤æ¶åéåã112 //99.NSUnit(Class-NSObject) 表示度éåä½çæ½è±¡ç±»ã --Unit(Class-NSObject) 表示度éåä½çæ½è±¡ç±»ã113 //100.NSUserActivity(Class-NSObject) 表示åºç¨ç¨åºå¨æ个æ¶å»çç¶æã114 //101.NSUserDefaults(Class-NSObject) ä¸ä¸ªå°ç¨æ·é»è®¤æ°æ®åºçæ¥å£ï¼å¨æ¤æ¥å£ä¸ï¼æ¨å¯ä»¥å¨åºç¨ç¨åºå¯å¨æé´æä¹
å°åå¨é®å¼å¯¹ã --UserDefaults(Class-NSObject) ä¸ä¸ªå°ç¨æ·é»è®¤æ°æ®åºçæ¥å£ï¼å¨æ¤æ¥å£ä¸ï¼æ¨å¯ä»¥å¨åºç¨ç¨åºå¯å¨æé´æä¹
å°åå¨é®å¼å¯¹ã115 //102.NSValue(Class-NSObject) ç¨äºå个CæObjective-Cæ°æ®é¡¹çç®å容å¨ã116 //103.NSValueTransformer(Class-NSObject) ç¨äºå°å¼ä»ä¸ç§è¡¨ç¤ºå½¢å¼è½¬æ¢ä¸ºå¦ä¸ç§è¡¨ç¤ºå½¢å¼çæ½è±¡ç±»ã --ValueTransformer(Class-NSObject) ç¨äºå°å¼ä»ä¸ç§è¡¨ç¤ºå½¢å¼è½¬æ¢ä¸ºå¦ä¸ç§è¡¨ç¤ºå½¢å¼çæ½è±¡ç±»ã117 //104.NSXMLParser(Class-NSObject) XMLææ¡£çäºä»¶é©±å¨è§£æå¨(å
æ¬DTD声æ)ã --XMLParser(Class-NSObject) XMLææ¡£çäºä»¶é©±å¨è§£æå¨(å
æ¬DTD声æ)ã118 //105.NSZone(Type Alias,Structure) ç¨äºæ è¯å管çå
ååºåçç±»åã119 //106.NSXPCConnection(Class-NSObject) 两个è¿ç¨ä¹é´çååéä¿¡ä¿¡éã 120 }121}...
RuntimeKitTests.swift
Source:RuntimeKitTests.swift
...19 // MARK: - Runtime tests20 21 // MARK: get class name22 23 func testClassName_NSObject() {24 let NSObjectClassNameFromRuntime = Runtime.className(NSObject.self)25 let NSObjectClassNameFromFoundation = NSStringFromClass(NSObject.self)26 XCTAssertEqual(NSObjectClassNameFromRuntime, "NSObject")27 XCTAssertEqual(NSObjectClassNameFromRuntime, NSObjectClassNameFromFoundation)28 }29 30 func testClass_SwiftPureClass() {31 do {32 // SwiftPureClass.SwiftPureClass33 let SwiftNestedPureClassNameFromRuntime = Runtime.className(SwiftPureClass.SwiftPureClass.self)34 let SwiftNestedPureClassNameFromFoundation = NSStringFromClass(SwiftPureClass.SwiftPureClass.self)35 XCTAssertEqual(SwiftNestedPureClassNameFromRuntime, SwiftNestedPureClassNameFromFoundation)36 }37 do {38 // SwiftPureClass.SwiftPureClass.SwiftPureClass39 let SwiftNestedPureClassNameFromRuntime = Runtime.className(SwiftPureClass.SwiftPureClass.SwiftPureClass.self)40 let SwiftNestedPureClassNameFromFoundation = NSStringFromClass(SwiftPureClass.SwiftPureClass.SwiftPureClass.self)41 XCTAssertEqual(SwiftNestedPureClassNameFromRuntime, SwiftNestedPureClassNameFromFoundation)42 }43 }44 45 func testClass_SwiftPureStruct_SwiftPureClass() {46 do {47 // SwiftPureStruct.SwiftPureClass48 let SwiftNestedPureClassNameFromRuntime = Runtime.className(SwiftPureStruct.SwiftPureClass.self)49 let SwiftNestedPureClassNameFromFoundation = NSStringFromClass(SwiftPureStruct.SwiftPureClass.self)50 XCTAssertEqual(SwiftNestedPureClassNameFromRuntime, SwiftNestedPureClassNameFromFoundation)51 }52 do {53 // SwiftPureStruct.SwiftPureClass.SwiftPureClass54 let SwiftNestedPureClassNameFromRuntime = Runtime.className(SwiftPureStruct.SwiftPureClass.SwiftPureClass.self)55 let SwiftNestedPureClassNameFromFoundation = NSStringFromClass(SwiftPureStruct.SwiftPureClass.SwiftPureClass.self)56 XCTAssertEqual(SwiftNestedPureClassNameFromRuntime, SwiftNestedPureClassNameFromFoundation)57 }58 }59 60 func testClass_NSObjectSubclass() {61 // NSObjectSubclass62 let NSObjectSubclassFromRuntime = Runtime.className(NSObjectSubclass.self)63 let NSObjectSubClassFromFoundation = NSStringFromClass(NSObjectSubclass.self)64 XCTAssertEqual(NSObjectSubclassFromRuntime, NSObjectSubClassFromFoundation)65 }66 67 func testClass_NSObjectSubclass_NSObjectSubclass() {68 // NSObjectSubclass.NSObjectSubclass69 let NSObjectSubclassFromRuntime = Runtime.className(NSObjectSubclass.NSObjectSubclass.self)70 let NSObjectSubClassFromFoundation = NSStringFromClass(NSObjectSubclass.NSObjectSubclass.self)71 XCTAssertEqual(NSObjectSubclassFromRuntime, NSObjectSubClassFromFoundation)72 }73 74 // MARK: get class75 76 func testClass_NSObject() {77 guard let NSObjectClassFromRuntime: AnyClass = Runtime.class("NSObject") else {78 fatalError("failed NSObjectClassFromRuntime")79 }80 let NSObjectClass = NSObject.self81 XCTAssertEqual(NSStringFromClass(NSObjectClassFromRuntime), NSStringFromClass(NSObjectClass))82 }83 84 func testClass_HogeStruct() {85 86 struct Hoge {}87 88 guard let _: AnyClass = Runtime.class("Hoge") else {89 XCTAssertTrue(true, "not found struct definition from objc runtime")90 return91 }92 XCTFail("should not found struct definition from objc runtime")93 }94 95 func testClass_SwiftPureProtocol() {96 let desc = "should not found swift pure protocol definition from objc runtime"97 guard let _: AnyClass = Runtime.class("SwiftPureProtocol") else {98 return precondition(true, desc)99 }100 XCTFail(desc)101 }102 103 // MARK: get all class104 105 func testAllClasses() {106 XCTAssertTrue(Runtime.allClass().count > 0)107 }108 109 func testNSObjectInAllClasses() {110 let desc = "should found NSObject definition from objc runtime"111 guard let NSObjectClassFromRuntime = Runtime.allClass(isIncluded: { anyClazz in112 NSStringFromClass(anyClazz) == NSStringFromClass(NSObject.self)113 }).first else {114 return precondition(true, desc)115 }116 let NSObjectClass = NSObject.self117 XCTAssertEqual(NSStringFromClass(NSObjectClassFromRuntime), NSStringFromClass(NSObjectClass))118 }119 120 // MARK: get meta class121 122 func testMetaClass_NSObject() {123 guard let NSObjectMetaClassFromRuntime: AnyClass = Runtime.metaClass(NSObject.self) else {124 fatalError("failed NSObjectClassFromRuntime")125 }126 let NSObjectClass = NSObject.self127 XCTAssertEqual(NSStringFromClass(NSObjectMetaClassFromRuntime), NSStringFromClass(NSObjectClass))128 }129 130 // MARK: is meta class131 132 func testIsMetaClass_NSObject() {133 guard let NSObjectMetaClassFromRuntime: AnyClass = Runtime.metaClass(NSObject.self) else {134 fatalError("failed NSObjectClassFromRuntime")135 }136 let NSObjectClass = NSObject.self137 XCTAssertTrue(Runtime.isMetaClass(NSObjectMetaClassFromRuntime))138 XCTAssertFalse(Runtime.isMetaClass(NSObjectClass))139 }140 141 // MARK: get super class142 143 func testSuperClass_NSDictionary() {144 guard let NSDictionarySuperClassFromRuntime: AnyClass = Runtime.superClass(NSDictionary.self) else {145 fatalError("failed NSObjectClassFromRuntime")146 }147 let NSObjectClass = NSObject.self148 XCTAssertEqual(NSStringFromClass(NSDictionarySuperClassFromRuntime), NSStringFromClass(NSObjectClass))149 }150 151 // MARK: get & set class version152 153 func testClassVersion_NSObject() {154 var NSObjectClassVersion = Runtime.classVersion(NSObject.self)155 XCTAssertEqual(NSObjectClassVersion, 0)156 Runtime.setClassVersion(NSObject.self, version: 1)157 NSObjectClassVersion = Runtime.classVersion(NSObject.self)158 XCTAssertEqual(NSObjectClassVersion, 1)159 Runtime.setClassVersion(NSObject.self, version: 0)160 NSObjectClassVersion = Runtime.classVersion(NSObject.self)161 XCTAssertEqual(NSObjectClassVersion, 0)162 }163 164 // MARK: get class instance size165 166 func testClassInstanceSize_NSObject() {167 let NSObjectClassInstanceSize = Runtime.classInstanceSize(NSObject.self)168 XCTAssertEqual(NSObjectClassInstanceSize, 8)169 XCTAssertEqual(NSObjectClassInstanceSize, MemoryLayout<NSObject>.size)170 }171 172 // MARK: -173 174 func testPerformanceExample() {175 // This is an example of a performance test case.176 measure {177 178 }179 }180}
TestDefinition.swift
Source:TestDefinition.swift
...9class SwiftPureClass {10 class SwiftPureClass {11 class SwiftPureClass {}12 struct SwiftPureStruct {}13 class NSObjectSubclass: NSObject {}14 }15 16 struct SwiftPureStruct {17 class SwiftPureClass {}18 struct SwiftPureStruct {}19 class NSObjectSubclass: NSObject {}20 }21 22 class NSObjectSubclass: NSObject {23 class SwiftPureClass {}24 struct SwiftPureStruct {}25 class NSObjectSubclass: NSObject {}26 }27}28struct SwiftPureStruct {29 class SwiftPureClass {30 class SwiftPureClass {}31 struct SwiftPureStruct {}32 class NSObjectSubclass: NSObject {}33 }34 35 struct SwiftPureStruct {36 class SwiftPureClass {}37 struct SwiftPureStruct {}38 class NSObjectSubclass: NSObject {}39 }40 41 class NSObjectSubclass: NSObject {42 class SwiftPureClass {}43 struct SwiftPureStruct {}44 class NSObjectSubclass: NSObject {}45 }46}47class NSObjectSubclass: NSObject {48 class SwiftPureClass {49 class SwiftPureClass {}50 struct SwiftPureStruct {}51 class NSObjectSubclass: NSObject {}52 }53 54 struct SwiftPureStruct {55 class SwiftPureClass {}56 struct SwiftPureStruct {}57 class NSObjectSubclass: NSObject {}58 }59 60 class NSObjectSubclass: NSObject {61 class SwiftPureClass {}62 struct SwiftPureStruct {}63 class NSObjectSubclass: NSObject {}64 }65}66protocol SwiftPureProtocol {}...
NSObject
Using AI Code Generation
1import Mockingbird2import XCTest3class Mock1: NSObject, Mockingbird.Mock {4 let handle = Mockingbird.MockHandle()5 struct __StubbingProxy_1: Mockingbird.StubbingProxy {6 func method1() -> Mockingbird.StubFunction<Mockingbird.NoReturn, Mockingbird.NoReturn> {7 return Mockingbird.StubFunction(stub: handle.createStub("method1()", parameterMatchers: []))8 }9 }10 struct __VerificationProxy_1: Mockingbird.VerificationProxy {11 func method1() -> Mockingbird.VerificationFunction<Mockingbird.NoReturn> {12 return Mockingbird.VerificationFunction(verification: handle.createVerification("method1()", parameterMatchers: []))13 }14 }15 var stubbing: __StubbingProxy_1 {16 return __StubbingProxy_1(handle: handle)17 }18 var verification: __VerificationProxy_1 {19 return __VerificationProxy_1(handle: handle)20 }21}22import Mockingbird23import XCTest24class Mock2: NSObject, Mockingbird.Mock {25 let handle = Mockingbird.MockHandle()26 struct __StubbingProxy_2: Mockingbird.StubbingProxy {27 func method2() -> Mockingbird.StubFunction<Mockingbird.NoReturn, Mockingbird.NoReturn> {28 return Mockingbird.StubFunction(stub: handle.createStub("method2()", parameterMatchers: []))29 }30 }31 struct __VerificationProxy_2: Mockingbird.VerificationProxy {32 func method2() -> Mockingbird.VerificationFunction<Mockingbird.NoReturn> {33 return Mockingbird.VerificationFunction(verification: handle.createVerification("method2()", parameterMatchers: []))34 }35 }
NSObject
Using AI Code Generation
1import Mockingbird2import XCTest3class Test2: XCTestCase {4 func test1() {5 let mock = mock(NSObject.self)6 let mock2 = mock(NSObject.self)7 let mock3 = mock(NSObject.self)8 let mock4 = mock(NSObject.self)9 let mock5 = mock(NSObject.self)10 let mock6 = mock(NSObject.self)11 let mock7 = mock(NSObject.self)12 let mock8 = mock(NSObject.self)13 let mock9 = mock(NSObject.self)14 let mock10 = mock(NSObject.self)15 let mock11 = mock(NSObject.self)16 let mock12 = mock(NSObject.self)17 let mock13 = mock(NSObject.self)18 let mock14 = mock(NSObject.self)19 let mock15 = mock(NSObject.self)20 let mock16 = mock(NSObject.self)21 let mock17 = mock(NSObject.self)22 let mock18 = mock(NSObject.self)23 let mock19 = mock(NSObject.self)24 let mock20 = mock(NSObject.self)25 let mock21 = mock(NSObject.self)26 let mock22 = mock(NSObject.self)27 let mock23 = mock(NSObject.self)28 let mock24 = mock(NSObject.self)29 let mock25 = mock(NSObject.self)30 let mock26 = mock(NSObject.self)31 let mock27 = mock(NSObject.self)32 let mock28 = mock(NSObject.self)33 let mock29 = mock(NSObject.self)34 let mock30 = mock(NSObject.self)35 let mock31 = mock(NSObject.self)36 let mock32 = mock(NSObject.self)37 let mock33 = mock(NSObject.self)38 let mock34 = mock(NSObject.self)39 let mock35 = mock(NSObject.self)40 let mock36 = mock(NSObject.self)41 let mock37 = mock(NSObject.self)42 let mock38 = mock(NSObject.self)43 let mock39 = mock(NSObject.self)44 let mock40 = mock(NSObject.self)45 let mock41 = mock(NSObject.self)46 let mock42 = mock(NSObject.self)47 let mock43 = mock(NSObject.self)48 let mock44 = mock(NSObject.self)49 let mock45 = mock(NSObject.self)50 let mock46 = mock(NSObject.self)51 let mock47 = mock(NSObject.self)52 let mock48 = mock(NSObject.self
NSObject
Using AI Code Generation
1import Foundation2import Mockingbird3class MockingbirdClass: NSObject {4 func testMethod() -> String {5 }6}7import Foundation8import Mockingbird9class MockingbirdTestClass: NSObject {10 func test() {11 let mockingbird = MockingbirdClass()12 print(mockingbird.testMethod())13 }14}15import Foundation16import Mockingbird17import XCTest18class MockingbirdTest: XCTestCase {19 func test() {20 let mockingbirdTest = MockingbirdTestClass()21 mockingbirdTest.test()22 }23}
NSObject
Using AI Code Generation
1class Mockingbird: NSObject {2}3class Sparrow: NSObject {4}5class Crow: NSObject {6}7class Penguin: NSObject {8}9class Parrot: NSObject {
NSObject
Using AI Code Generation
1import Mockingbird2import Foundation3class MyClass: NSObject {4 func myMethod() -> String {5 }6}7let mock = mock(MyClass.self)8let myMethod = given(mock.myMethod())9willReturn("Hello World").given(myMethod)10let myObject = MyClass()11print(myObject.myMethod())12import Mockingbird13import XCTest14class MyClass: NSObject {15 func myMethod() -> String {16 }17}18class MyTest: XCTestCase {19 func testMyMethod() {20 let mock = mock(MyClass.self)21 let myMethod = given(mock.myMethod())22 willReturn("Hello World").given(myMethod)23 let myObject = MyClass()24 XCTAssertEqual(myObject.myMethod(), "Hello World")25 }26}
NSObject
Using AI Code Generation
1import Mockingbird2import XCTest3class MockingbirdTest: XCTestCase {4 func testExample() {5 let mock = mock(ExampleClass.self)6 given(mock.testMethod()) ~> "Hello World"7 XCTAssertEqual(mock.testMethod(), "Hello World")8 }9}10class ExampleClass {11 func testMethod() -> String {12 }13}14import Mockingbird15import XCTest16class MockingbirdTest: XCTestCase {17 func testExample() {18 let mock = mock(ExampleClass.self)19 given(mock.testMethod()) ~> "Hello World"20 XCTAssertEqual(mock.testMethod(), "Hello World")21 }22}23class ExampleClass: NSObject {24 func testMethod() -> String {25 }26}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!