1, 網路履歷有分為自動媒合跟主動應徵
2, 通常主動應徵的很少,自動媒合的打過去就先跟他說明緣由
3, 告知面試當時是否有額外技能測試
4, 常會約好了不來,所以在面試前再印履歷即可
5, 人來了請他填寫基本資料,即使這次沒有成,也可為公司留下資料庫
2013年11月7日 星期四
2013年11月6日 星期三
背景執行APP不死
在plist中加入Required Background Modes,然後在下面加入參數
1).App registers for location updates
2).App provides Voice over IP services
3).App plays audio
4).App processes Newsstand Kit downloads
5).App communicates using CoreBluetooth
6).App shares data using CoreBluetooth
在AppDelegate加入這段Code
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication *app = [UIApplication sharedApplication];
__block UIBackgroundTaskIdentifier bgTask;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
bgTask = UIBackgroundTaskInvalid;
}
});
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
bgTask = UIBackgroundTaskInvalid;
}
});
});
}
//官方版
//iOS7特有種 - (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication *app = [UIApplication sharedApplication];
__block UIBackgroundTaskIdentifier bgTask;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}
});
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}
});
});
}
1).App registers for location updates
2).App provides Voice over IP services
3).App plays audio
4).App processes Newsstand Kit downloads
5).App communicates using CoreBluetooth
6).App shares data using CoreBluetooth
在AppDelegate加入這段Code
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication *app = [UIApplication sharedApplication];
__block UIBackgroundTaskIdentifier bgTask;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
bgTask = UIBackgroundTaskInvalid;
}
});
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
bgTask = UIBackgroundTaskInvalid;
}
});
});
}
//官方版
- (void)applicationDidEnterBackground:(UIApplication *)application |
{
|
bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
|
// Clean up any unfinished task business by marking where you |
// stopped or ending the task outright. |
[application endBackgroundTask:bgTask]; |
bgTask = UIBackgroundTaskInvalid; |
}]; |
// Start the long-running task and return immediately. |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
// Do the work associated with the task, preferably in chunks. |
[application endBackgroundTask:bgTask]; |
bgTask = UIBackgroundTaskInvalid; |
}); |
} |
//也可在App中加入檢查有無支援多工的程式碼
UIDevice* device = [UIDevice currentDevice];
BOOL backgroundSupported = NO;
if ([device respondsToSelector:@selector(isMultitaskingSupported)])
backgroundSupported = device.multitaskingSupported;
//背景執行的原則
- 不要在背景執行OpenGL ES
- 在進入背景前取消所有跟Bonjour有關的服務
Being a Responsible Background App
The foreground app always has precedence over background apps when it comes to the use of system resources and hardware. Apps running in the background need to be prepared for this discrepancy and adjust their behavior when running in the background. Specifically, apps moving to the background should follow these guidelines:
- Do not make any OpenGL ES calls from your code. You must not create an
EAGLContextobject or issue any OpenGL ES drawing commands of any kind while running in the background. Using these calls causes your app to be killed immediately. Apps must also ensure that any previously submitted commands have completed before moving to the background. For information about how to handle OpenGL ES when moving to and from the background, see “Implementing a Multitasking-aware OpenGL ES Application” in OpenGL ES Programming Guide for iOS. - Cancel any Bonjour-related services before being suspended. When your app moves to the background, and before it is suspended, it should unregister from Bonjour and close listening sockets associated with any network services. A suspended app cannot respond to incoming service requests anyway. Closing out those services prevents them from appearing to be available when they actually are not. If you do not close out Bonjour services yourself, the system closes out those services automatically when your app is suspended.
- Be prepared to handle connection failures in your network-based sockets. The system may tear down socket connections while your app is suspended for any number of reasons. As long as your socket-based code is prepared for other types of network failures, such as a lost signal or network transition, this should not lead to any unusual problems. When your app resumes, if it encounters a failure upon using a socket, simply reestablish the connection.
- Save your app state before moving to the background. During low-memory conditions, background apps may be purged from memory to free up space. Suspended apps are purged first, and no notice is given to the app before it is purged. As a result, apps should take advantage of the state preservation mechanism in iOS 6 and later to save their interface state to disk. For information about how to support this feature, see“State Preservation and Restoration.”
- Remove strong references to unneeded objects when moving to the background. If your app maintains a large in-memory cache of objects (especially images), remove all strong references to those caches when moving to the background. For more information, see “Memory Usage for Background Apps.”
- Stop using shared system resources before being suspended. Apps that interact with shared system resources such as the Address Book or calendar databases should stop using those resources before being suspended. Priority for such resources always goes to the foreground app. When your app is suspended, if it is found to be using a shared resource, the app is killed.
- Avoid updating your windows and views. While in the background, your app’s windows and views are not visible, so you should not try to update them. Although creating and manipulating window and view objects in the background does not cause your app to be killed, consider postponing this work until you return to the foreground.
- Respond to connect and disconnect notifications for external accessories. For apps that communicate with external accessories, the system automatically sends a disconnection notification when the app moves to the background. The app must register for this notification and use it to close out the current accessory session. When the app moves back to the foreground, a matching connection notification is sent, giving the app a chance to reconnect. For more information on handling accessory connection and disconnection notifications, see External Accessory Programming Topics.
- Clean up resources for active alerts when moving to the background. In order to preserve context when switching between apps, the system does not automatically dismiss action sheets (
UIActionSheet) or alert views (UIAlertView) when your app moves to the background. It is up to you to provide the appropriate cleanup behavior prior to moving to the background. For example, you might want to cancel the action sheet or alert view programmatically or save enough contextual information to restore the view later (in cases where your app is terminated).For apps linked against a version of iOS earlier than 4.0, action sheets and alerts are still dismissed at quit time so that your app’s cancellation handler has a chance to run. - Remove sensitive information from views before moving to the background. When an app transitions to the background, the system takes a snapshot of the app’s main window, which it then presents briefly when transitioning your app back to the foreground. Before returning from your
applicationDidEnterBackground:method, you should hide or obscure passwords and other sensitive personal information that might be captured as part of the snapshot. - Do minimal work while running in the background. The execution time given to background apps is more constrained than the amount of time given to the foreground app. Apps that spend too much time executing in the background can be throttled back by the system or terminated.
If you are implementing a background audio app, or any other type of app that is allowed to run in the background, your app responds to incoming messages in the usual way. In other words, the system may notify your app of low-memory warnings when they occur. And in situations where the system needs to terminate apps to free even more memory, the app calls its delegate’s
applicationWillTerminate: method to perform any final tasks before exiting.2013年11月5日 星期二
NSString 字串補零
http://kalvar-kaki.blogspot.tw/2013/06/ios-nsstring.html
NSString *cString = [NSString stringWithFormat:@"%04d", 99];
%04 會補成 4 位數,上述 Code 會輸出 0099
補充swift的寫法:
String(format: "%04d", 99)
2013年11月4日 星期一
ASCII 編碼 與 UTF8 編碼
[節錄自http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html]
ASCII码一共规定了128个字符的编码,比如空格"SPACE"是32(二进制00100000),大写的字母A是65(二进制01000001)。这128个符号(包括32个不能打印出来的控制符号),只占用了一个字节的后面7位,最前面的1位统一规定为0。
英语用128个符号编码就够了,但是用来表示其他语言,128个符号是不够的。
可以想象,如果有一种编码,将世界上所有的符号都纳入其中。每一个符号都给予一个独一无二的编码,那么乱码问题就会消失。这就是Unicode,就像它的名字都表示的,这是一种所有符号的编码。
ASCII码一共规定了128个字符的编码,比如空格"SPACE"是32(二进制00100000),大写的字母A是65(二进制01000001)。这128个符号(包括32个不能打印出来的控制符号),只占用了一个字节的后面7位,最前面的1位统一规定为0。
英语用128个符号编码就够了,但是用来表示其他语言,128个符号是不够的。
可以想象,如果有一种编码,将世界上所有的符号都纳入其中。每一个符号都给予一个独一无二的编码,那么乱码问题就会消失。这就是Unicode,就像它的名字都表示的,这是一种所有符号的编码。
UTF-8
互联网的普及,强烈要求出现一种统一的编码方式。UTF-8就是在互联网上使用最广的一种Unicode的实现方式。其他实现方式还包括UTF-16(字符用两个字节或四个字节表示)和UTF-32(字符用四个字节表示),不过在互联网上基本不用。重复一遍,这里的关系是,UTF-8是Unicode的实现方式之一。
UTF-8最大的一个特点,就是它是一种变长的编码方式。它可以使用1~4个字节表示一个符号,根据不同的符号而变化字节长度。
UTF-8的编码规则很简单,只有二条:
1)对于单字节的符号,字节的第一位设为0,后面7位为这个符号的unicode码。因此对于英语字母,UTF-8编码和ASCII码是相同的。
2)对于n字节的符号(n>1),第一个字节的前n位都设为1,第n+1位设为0,后面字节的前两位一律设为10。剩下的没有提及的二进制位,全部为这个符号的unicode码。
下表总结了编码规则,字母x表示可用编码的位。
Unicode符号范围 | UTF-8编码方式
(十六进制) | (二进制)
--------------------+---------------------------------------------
0000 0000-0000 007F | 0xxxxxxx
0000 0080-0000 07FF | 110xxxxx 10xxxxxx
0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
跟据上表,解读UTF-8编码非常简单。如果一个字节的第一位是0,则这个字节单独就是一个字符;如果第一位是1,则连续有多少个1,就表示当前字符占用多少个字节。
下面,还是以汉字"严"为例,演示如何实现UTF-8编码。
已知"严"的unicode是4E25(100111000100101),根据上表,可以发现4E25处在第三行的范围内(0000 0800-0000 FFFF),因此"严"的UTF-8编码需要三个字节,即格式是"1110xxxx 10xxxxxx 10xxxxxx"。然后,从"严"的最后一个二进制位开始,依次从后向前填入格式中的x,多出的位补0。这样就得到了,"严"的UTF-8编码是"11100100 10111000 10100101",转换成十六进制就是E4B8A5。
2013年11月3日 星期日
Base64編碼
[整理自wiki]
Base64是一種基於64個可列印字元來表示二進制數據的表示方法。由於2的6次方等於64,所以每6個位元為一個單元,對應某個可列印字元。三個位元組有24個位元,對應於4個Base64單元,即3個位元組需要用4個可列印字元來表示。它可用來作為電子郵件的傳輸編碼。
在此例中,Base64演算法將三個字元編碼為4個字元
Base64索引表:
如果要編碼的位元組數不能被3整除,最後會多出1個或2個位元組,那麼可以使用下面的方法進行處理:先使用0位元組值在末尾補足,使其能夠被3整 除,然後再進行base64的編碼。在編碼後的base64文本後加上一個或兩個'='號,代表補足的位元組數。也就是說,當最後剩餘一個八位位元組(一 個byte)時,最後一個6位的base64位元組塊有四位是0值,最後附加上兩個等號;如果最後剩餘兩個八位位元組(2個byte)時,最後一個6位的 base位元組塊有兩位是0值,最後附加一個等號。 參考下表:
下表中,A只有一個Byte還缺二個Byte,所以最後要加二個=
下表中,BC只有二個Byte還缺一個Byte,所以最後要加一個=
Base64是一種基於64個可列印字元來表示二進制數據的表示方法。由於2的6次方等於64,所以每6個位元為一個單元,對應某個可列印字元。三個位元組有24個位元,對應於4個Base64單元,即3個位元組需要用4個可列印字元來表示。它可用來作為電子郵件的傳輸編碼。
- 編碼「Man」
| 文本 | M | a | n | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ASCII編碼 | 77 | 97 | 110 | |||||||||||||||||||||
| 二進制位 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 0 |
| 索引 | 19 | 22 | 5 | 46 | ||||||||||||||||||||
| Base64編碼 | T | W | F | u | ||||||||||||||||||||
Base64索引表:
| Value | Char | Value | Char | Value | Char | Value | Char | |||
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | A | 16 | Q | 32 | g | 48 | w | |||
| 1 | B | 17 | R | 33 | h | 49 | x | |||
| 2 | C | 18 | S | 34 | i | 50 | y | |||
| 3 | D | 19 | T | 35 | j | 51 | z | |||
| 4 | E | 20 | U | 36 | k | 52 | 0 | |||
| 5 | F | 21 | V | 37 | l | 53 | 1 | |||
| 6 | G | 22 | W | 38 | m | 54 | 2 | |||
| 7 | H | 23 | X | 39 | n | 55 | 3 | |||
| 8 | I | 24 | Y | 40 | o | 56 | 4 | |||
| 9 | J | 25 | Z | 41 | p | 57 | 5 | |||
| 10 | K | 26 | a | 42 | q | 58 | 6 | |||
| 11 | L | 27 | b | 43 | r | 59 | 7 | |||
| 12 | M | 28 | c | 44 | s | 60 | 8 | |||
| 13 | N | 29 | d | 45 | t | 61 | 9 | |||
| 14 | O | 30 | e | 46 | u | 62 | + | |||
| 15 | P | 31 | f | 47 | v | 63 | / |
如果要編碼的位元組數不能被3整除,最後會多出1個或2個位元組,那麼可以使用下面的方法進行處理:先使用0位元組值在末尾補足,使其能夠被3整 除,然後再進行base64的編碼。在編碼後的base64文本後加上一個或兩個'='號,代表補足的位元組數。也就是說,當最後剩餘一個八位位元組(一 個byte)時,最後一個6位的base64位元組塊有四位是0值,最後附加上兩個等號;如果最後剩餘兩個八位位元組(2個byte)時,最後一個6位的 base位元組塊有兩位是0值,最後附加一個等號。 參考下表:
下表中,A只有一個Byte還缺二個Byte,所以最後要加二個=
下表中,BC只有二個Byte還缺一個Byte,所以最後要加一個=
| 文本(1 Byte) | A | |||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 二進制位 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | ||||||||||||||||
| 二進制位(補0) | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | ||||||||||||
| Base64編碼 | Q | Q | ||||||||||||||||||||||
| 文本(2 Byte) | B | C | ||||||||||||||||||||||
| 二進制位 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | x | x | x | x | x | x | ||
| 二進制位(補0) | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | x | x | x | x | x | x |
| Base64編碼 | Q | k | M | |||||||||||||||||||||
判斷第一次使用App (NSUserDefaults)
專案 appdelegate.m 中“application:didFinishLaunchingWithOptions:” 方法 if (![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"]) { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"]; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];}else{ [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"firstLaunch"];}
在程式需要判斷的部分加入以下代碼:
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]) { // 這裡判斷是否第一次 UIAlertView * alert =[[UIAlertView alloc] initWithTitle:@"第一次" message:@"進入App" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil]; [alert show]; [alert release]; }
訂閱:
文章 (Atom)