iOS

iOSアプリでの着信イベントの取得

iOSにおいて着信イベントを取得するためには、Core Telephony Framework の CTCallCenter を使用する。 CoreTelephony.framework を追加した上で、コードは以下の通り。 #import #import - (void)viewDidLoad { (略) CTCallCenter* callCenter = [[CTCallCen…

iOSプロジェクト向け.gitignore

# Vim swap files *.swp # Xcode *.xcodeproj/* !*.xcodeproj/project.pbxproj # Mac .DS_Store

NSNotificationを使って通知をメインスレッドから投げる

NSNotificationの通知は、NSNotificationCenter の postNotification メソッドを呼んだスレッドで実行される。 一方、iOSアプリではUI操作はメインスレッドからでないと実行できない。 よって、通知を受け取ってUI操作をしたいという場合は以下のようにして…

iPhone のIPアドレスを取得する

iOS

iPhoneのIPアドレスを取得するCのコード。 ifa_name は 3G が "pdp_ip0"、Wi-Fi が "en0" のようである。 #include #include #include #include #include int get_ip_addr(char* buf) { struct ifaddrs* ifa_list = NULL; struct ifaddrs* tmp; int ret; ret…