Xcode, iOS, iPhone, iPad, Mac OS, Objective C, C, C++, Android, Java.
Thursday 16 March 2023
Apple Macbook Delete DNS history, chrome incognito private session.
Open terminal and enter
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Monday 6 January 2020
iPhone not connecting to MacBook. iPhone getting disconnected from iTunes and Xcode
Are you facing the problem that your iPhone connect and disconnect to your system?
Xcode iTunes unable to read the device from the USB.
All you need to just restart your USB port.
- Open Terminal app
- Type the following command.
sudo killall -STOP -c usbd
Thursday 2 January 2020
User Permissions iOS in info.plist
For asking user permission developer must key-string pairs in Info.plist
<key>AppleKey</key>
<string>Developer's description to ask for permission from the user.</string>
Example:
If developer wants to use camera for video call, then user should ask for
1. photo gallery, 2. microphone, 3. camera
1.) <key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library for profile picture.</string>
2.) <key>NSMicrophoneUsageDescription</key>
<string>This app does not require access to the microphone for call.</string>
3.) <key>NSCameraUsageDescription</key>
<string>This app requires access to the camera for video call.</string>
Apple Document for properties list key references.: developer.apple.com
Few More Examples:
Apple Music:
<key>NSAppleMusicUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Bluetooth:
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Calendar:
<key>NSCalendarsUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Camera:
<key>NSCameraUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Contacts:
<key>NSContactsUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
FaceID:
<key>NSFaceIDUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Health Share:
<key>NSHealthShareUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Health Update:
<key>NSHealthUpdateUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Home Kit:
<key>NSHomeKitUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Location:
<key>NSLocationUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Location (Always):
<key>NSLocationAlwaysUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Location (When in use):
<key>NSLocationWhenInUseUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Microphone:
<key>NSMicrophoneUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Motion (Accelerometer):
<key>NSMotionUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
NFC (Near-field communication):
<key>NFCReaderUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Photo Library:
<key>NSPhotoLibraryUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Photo Library (Write-only access):
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Reminders:
<key>NSRemindersUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Siri:
<key>NSSiriUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Speech Recognition:
<key>NSSpeechRecognitionUsageDescription</key>
<string>Developer description to get permission to access this capability</string>
Thursday 5 July 2018
Xcode iPhone/iPad find the top View Controller in the current View Hierarchy
There are three possiblities.
Case 1: If the view controller is embedded in UINavigationController
Case 2: If the view controller is embedded in UITabControllerBar
Case 3: If the view controller is presented via other UIViewController
So we have to traverse through the possible combination until we reach the topmost layer.
#pragma mark- View Hierarchy-
+ (UIViewController*)topViewController {
return [self topViewControllerWithRootViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
+ (UIViewController*)topViewControllerWithRootViewController:(UIViewController*)rootViewController {
//Type 1: Travese in tabbar controller-
if ([rootViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController* tabBarController = (UITabBarController*)rootViewController;
return [self topViewControllerWithRootViewController:tabBarController.selectedViewController];
//Type 2: Travese in navigation controller-
} else if ([rootViewController isKindOfClass:[UINavigationController class]]) {
UINavigationController* navigationController = (UINavigationController*)rootViewController;
return [self topViewControllerWithRootViewController:navigationController.visibleViewController];
//Type 3: Travese in view controller-
} else if (rootViewController.presentedViewController) {
UIViewController* presentedViewController = rootViewController.presentedViewController;
return [self topViewControllerWithRootViewController:presentedViewController];
} else {
return rootViewController;
}
}
Subscribe to:
Posts (Atom)