---
# System prepended metadata

title: ios 第二週 0612
tags: [ios]

---

---
title: ios 第二週 0612
tags: ios
---
> [回首頁](https://hackmd.io/@janice-code/after_school_ios)

<style>
.a {
    color: orange;
    font-weight:bold
}
.b {
    color: blue;
    font-weight:bold;
}
</style>

[TOC]

### 物件名稱
- NSString 👉 字串
```cpp
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
    NSString * appDelegateClassName;
    @autoreleasepool {
    
        NSString* str1 = @"test APP";
        NSLog(@"AFTER school : %@", str1);
        
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
```
```
2021-06-12 11:30:13.680385+0800 testAPP[4358:2485376] AFTER school : test APP
```
- NSArray 👉 陣列
```cpp
int main(int argc, char * argv[]) {
    @autoreleasepool {
    
        NSArray *arr1 = [[NSArray alloc]initWithObjects:@"111", @"222", @"333", nil];
        NSLog(@"NSArr : %@", arr1);
        
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
```
```
2021-06-12 11:36:26.266018+0800 testAPP[4555:2492856] NSArr : (
    111,
    222,
    333
)
```

- NSDictionary 👉 字典
```cpp
int main(int argc, char * argv[]) {
    @autoreleasepool {
        
        NSDictionary *dic = [[NSDictionary alloc]initWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2",nil];
        NSLog(@"NSDic : %@", dic);
          
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
```
```
2021-06-12 11:39:50.273875+0800 testAPP[4665:2497238] NSDic : {
    key1 = value1;
    key2 = value2;
}
```

- NSInteger 👉

- NSLog 👉 可以輸入任何型別的資料

- NSURL 👉 可輸入網址，需先建入 WebView

### UI 組件
- UIViewController

- <span class="a">UITableViewController</span>

- <span class="a">UITableView</span> 👉 like 手機 setting 的那種介面

- <span class="b">UIAlertController</span> 👉 警告控制器
```cpp
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
    @autoreleasepool {
        
        UIAlertController *ale = [UIAlertController alertControllerWithTitle:@"主標題" message:@"副標題" preferredStyle:UIAlertControllerStyleAlert];
        NSLog(@"NSale : %@", ale);
                
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
```
```
2021-06-12 11:47:03.984608+0800 testAPP[4889:2506220] NSale : <UIAlertController: 0x7fdf6f00ca00>
```

- <span class="b">UIAlertAction</span>

- UIWebView

- UITextField

- UIScrollView

- UIToolBar

- UILabel

### 實作
- 程式進入點
![](https://i.imgur.com/6WIzMJS.png)


