ABPersonViewController does not support subclassing in iOS 7.0 and later - iphone

is there any best way to listout Property of Contact in detail?
like it is working in IOS 6.1 and earlier Version.
//
// ABPersonViewController.h
// AddressBookUI
//
// Copyright (c) 2010 Apple Inc. All rights reserved.
//
#import <UIKit/UIViewController.h>
#import <AddressBook/AddressBook.h>
#interface ABPersonViewController : UIViewController <UIViewControllerRestoration>
// ABPersonViewController does not support subclassing in iOS 7.0 and later. A nil instance will be returned.

i found a solution :please see source
there is some deprecated functions but we can resolve it,
by replace Below function in "ABContactsHelper" Class
+ (ABAddressBookRef) addressBook
{
#ifdef __IPHONE_6_0
return ABAddressBookCreateWithOptions(NULL, NULL);
#else
return ABAddressBookCreate();
#endif
}
Use it where "ABAddressBookCreate()" is Called.
Like
ABAddressBookRef addressBook = [ABContactsHelper addressBook];

Related

How to get available SSID list for iOS6

in iOS 4.x, there were APIs about my requirement, But it seems changed into private in 5.x, And It seems to removed in 6.x. (Actually it seems can't be called in sandbox)
Getting SSID list for 802.11 is very essential idea for our new project.
This code work well in order to get SSID.
#import <SystemConfiguration/CaptiveNetwork.h>
#implementation IODAppDelegate
#synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CFArrayRef myArray = CNCopySupportedInterfaces();
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
NSLog(#"Connected at:%#",myDict);
NSDictionary *myDictionary = (__bridge_transfer NSDictionary*)myDict;
NSString * BSSID = [myDictionary objectForKey:#"BSSID"];
NSLog(#"bssid is %#",BSSID);
// Override point for customization after application launch.
return YES;
}
And this is the results :
Connected at:{
BSSID = 0;
SSID = "Eqra'aOrange";
SSIDDATA = <45717261 27614f72 616e6765>;
}
I believe that there is no solution for this. the reason is:
Even user disabled location service, an App which accesses SSID list(actually BSSID) can infer location of user by using skyhook or something similar solution.
This information is not confirmed by Apple, But I'm pretty sure about it.

Phonegap plugin for version 2.0

Well, I am pretty new to phone gap. A day back, I got it installed on MAC OSX 10.7.1 with Xcode version 4.2.
First thing, I couldn’t see an option in my Xcode to create phone gap application. However I can make it happen using terminal. (Later came to know, that is how it works on this version, probably).
Second, I followed this tutorial and tried to add plugins. When I compile, it gives me fatal error. 'CDVPlugin.h' file not found. But i could see it in the Cordovalib.xcodeproj
In NativeControls.h
#import <Cordova/CDVPlugin.h>
#else
#import "CDVPlugin.h"
#endif
So can anyone please point out what I am doing wrong? Should I need to add CDVPlugin.h and related files again?
The compilation worked after modifying both the files NativeControls.h and NativeControls.m:
Modified NativeControls.h:
//
// NativeControls.h
//
//
// Created by Jesse MacFadyen on 10-02-03.
// MIT Licensed
// Originally this code was developed my Michael Nachbaur
// Formerly -> PhoneGap :: UIControls.h
// Created by Michael Nachbaur on 13/04/09.
// Copyright 2009 Decaf Ninja Software. All rights reserved.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UIKit/UITabBar.h>
#import <UIKit/UIToolbar.h>
//#ifdef PHONEGAP_FRAMEWORK
#import <Cordova/CDVPlugin.h>
//#else
//#import "CDVPlugin.h"
//#endif
#interface NativeControls : CDVPlugin <UITabBarDelegate, UIActionSheetDelegate> {
UITabBar* tabBar;
NSMutableDictionary* tabBarItems;
UIToolbar* toolBar;
UIBarButtonItem* toolBarTitle;
NSMutableArray* toolBarItems;
CGRect originalWebViewBounds;
}
/* Tab Bar methods
*/
- (void)createTabBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)showTabBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)hideTabBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)showTabBarItems:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)createTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)updateTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)selectTabBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
/* Tool Bar methods
*/
- (void)createToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)resetToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)setToolBarTitle:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)createToolBarItem:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)showToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
- (void)hideToolBar:(NSArray*)arguments withDict:(NSDictionary*)options;
/* ActionSheet
*/
- (void)createActionSheet:(NSArray*)arguments withDict:(NSDictionary*)options;
#end
Modifications in the file NativeControls.m: in line 22, change PGPlugin to CDVPlugin
Hope this will help.
In Cordova 2.1 (only)
I got around this error by simply commenting out if/else for a given PushNotification plugin
#import <Foundation/Foundation.h>
//#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
//#else
//#import "CDVPlugin.h"
//#endif
#import <EventKitUI/EventKitUI.h>
#import <EventKit/EventKit.h>

I'm using CAEmitterLayer, but app should also support iOS4.0, how to do?

I am new in iOS. I want to use CAEmitterLayer, which is only support by iOS 5, but my app should support iOS 4 and above. I am using [UIDevice currentDevice].systemVersion
to check the version, but it crashes.
Here is the code:
#class CAEmitterLayer;
#interface FireView : UIView
#property (strong) CAEmitterLayer *fireEmitter;
#property (strong) CAEmitterLayer *smokeEmitter;
- (void) setFireAmount:(float)zeroToOne;
#end
// create the FireView if iOS>=5.0
if ([[UIDevice currentDevice].systemVersion doubleValue] >=5.0) {
FireView *fireView = [[[FireView alloc] initWithFrame:CGRectMake(0, 95, 100, 280)] autorelease];
[self.view addSubview:fireView];
}
The problem is it crash before I create the FireView.
error:dyld: Symbol not found: _OBJC_CLASS_$_CAEmitterCell
even I don't include the FireView.h file, still crashes.
Should I create both iOS4 and iOS5 version?
Can you give me some advice?
Please help. Thank you very much.
You can check to see if CAEmitterLayer class is available on current device's iOS version by:
if (NSClassFromString(#"CAEmitterLayer"))
{
// available
}

#ifdef conditionals not working

I am using conditional code as below,
I want to run certain code only in ios5.0 and > ios5.0( i mean i want to support ios5.0 and 5.1 version too)
But the below condition dos not seem to work. ( Currently my development version is 5.1 but the below snippet is not getting identified.the control is not going into it.)
Please let me know your thoughts
#ifdef __IPHONE_5_0_OR_LATER
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0
// iPhone 5.0 code here
#endif
#define __IPHONE_2_0 20000
#define __IPHONE_2_1 20100
#define __IPHONE_2_2 20200
#define __IPHONE_3_0 30000
#define __IPHONE_3_1 30100
#define __IPHONE_3_2 30200
#define __IPHONE_4_0 40000
#define __IPHONE_4_1 40100
#define __IPHONE_4_2 40200
#define __IPHONE_4_3 40300
#define __IPHONE_5_0 50000
#define __IPHONE_5_1 50100
#define __IPHONE_NA 99999 /* not available */
How to target a specific iPhone version?
#ifdef is a compile directive, thus it will be evaluated at compile time not run time.
Thus if you add this to you code, the methods call in the if will all ways be called if your target SDK matches your #ifdef. So if you compile an app for both iOS 4 and 5 and place all the 5 only methods in #ifdef io5 the app will crash on iOS 4 since the methods will be called.
If you want to check if some method is available then you should do like :
Here is an example for dismissing an modal view controller from it's parent. Since parentViewController is changed to presentingViewController in iOS 5, we check if presentingViewController is available and use it.
if ([self respondsToSelector:#selector(presentingViewController)]) {
[self.presentingViewController dismissModalViewControllerAnimated:YES];
} else {
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
The same with goes for checking if a class is available :
if ([MPNowPlayingInfoCenter class]) {
MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
NSDictionary *songInfo = /* ... snip ... */;
center.nowPlayingInfo = songInfo;
}
NSArray *versionCompatibility = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:#"."];
if ( 5 == [[versionCompatibility objectAtIndex:0] intValue] ) { /// iOS5 is installed
// Put iOS-5 code here
} else { /// iOS4 is installed
// Put iOS-4 code here
}

Register to Addressbook changes, using ABAddressBookRegisterExternalChangeCallback

I really need some help here.
I do exactly the same as in all the examples, but don't get any notification.
Here's my code:
#import <AddressBook/ABAddressBook.h>
#import <AddressBook/AddressBook.h>
Registering for notification:
ABAddressBookRef book = ABAddressBookCreate();
ABAddressBookRegisterExternalChangeCallback(book, addressBookChanged, self);
Definition of the callback:
void addressBookChanged(ABAddressBookRef reference,
CFDictionaryRef dictionary,
void *context)
{
ViewController *viewController = (ViewController*)context;
[viewController addressBookChanged];
}
And another method:
-(void) addressBookChanged
{
NSLog(#"%#", #"addressBookChanged");
}
I'm running the app
Switching to the contacts app
Adding a new contact
nothing happens... no log, nothing...
What am I doing wrong here?
Any ' #import ' missing?
Should it work on device/simulator?
Any specific way of declaring the callback? Static maybe?
Any help will be appreciated.
Thanks.
Ok, I know the answer now...
The callback is being invoked, but only when I resume back my application.