Xcode 8.0 ios10 Build Warning for Core-Plot Bar Chart - core-plot

I have an existing project, written in objective-C, from ios8 with the Core-Plot 1.5.1 Static Library. I am compiling for ios8.2->ios10 using Xcode 8.0 beta 6 (8S201h).
When I compile the project I receive the following warning.
(The app creates my bar chart just fine when it runs.)
WARNING: Assigning to _Nullable from incompatible
type 'myViewController * const_strong'
In my bar chart view controller, I have the following:
in the .h:
#interface myViewController : UIViewController <CPTBarPlotDataSource, CPTBarPlotDelegate, UIActionSheetDelegate>
in the .m:
CPTBarPlot *barPlot = [[CPTBarPlot alloc] init];
barPlot.dataSource = self;
barPlot.delegate = self; // [Warning: occurs on this line]
Any advice you might have on this would be greatly appreciated.

Branch release-2.2 contains fixes which solves this kind of issues. It's not officially released but you can try to checkout to see what changes have been made. Link

Related

CorePlot errors after upgrading to xcode 7.3

I updated xcode today to version 7.3 and suddenly the module using CorePlot is throwing errors. "graph in unavailable" and "dataSource is unavailable". I have not made changes to this section of code since inception. I noticed that there is a new version of CorePlot - will that help or hurt?
Code snippet:
//1a - set up the 2 scatter plots - avg expected return for each portfolio
CPTScatterPlot *modelAvgRtnPlot = [[CPTScatterPlot alloc] init];
modelAvgRtnPlot.dataSource = self;
modelAvgRtnPlot.identifier = #"Portfolio A Expected Avg Return";
modelAvgRtnPlot.title = #"Model (A) Average Rtn";
The modelAvgRtnPlot.dataSource = self; line gives the compile error 'dataSource in unavailable'
second issue with 'graph' - snippet:
-(void)barPlot:(CPTBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index {
// 1 - Is the plot hidden?
if (plot.isHidden == YES) {
return;
}
// 2 - Create style, if necessary
static CPTMutableTextStyle *style = nil;
if (!style) {
style = [CPTMutableTextStyle textStyle];
style.color= [CPTColor darkGrayColor];
style.fontSize = 16.0f;
style.fontName = #"Raleway-Bold";
}
// 3 - Create annotation, if necessary
NSNumber *price = [self numberForPlot:plot field:CPTBarPlotFieldBarTip recordIndex:index];
if (self.priceDeviationAnnotation) {
[plot.graph.plotAreaFrame.plotArea removeAnnotation:self.priceDeviationAnnotation];
self.priceDeviationAnnotation = nil;
}
in the above, [plot.graph.plotAreaFrame.plotArea...] is giving the error "'graph' is unavailable"
Here is a another solution:
i have fixed this issue, Xcode - BuildSetting - Weak Reference in Manual Retain Release to Yes and solved.
Are you compiling your project without ARC enabled? There was some recent discussion in this github issue about projects compiled without ARC failing with Xcode 7.3. It has been fixed in the master branch with this commit.
If you're unable to upgrade to master at this time, removing cpt_weak from the property definitions that are giving you problems should fix your compilation error.

is Google maps SDK version 1.7.2 not compatible with iOS 6.1?

I inherited an xcode project whose author compiled with iOS 6.1. I understand apple has stopped accepting projects built using iOS6 SDK, but for whatever reason I need to still be able to compile this for now using iOS 6.1
Anyways, everything worked fine until I needed to use the didTapMyLocationButtonForMapView: method (which notifies me when the use clicks on the my location button) that seems to be only available in the latest google maps SDK which is version 1.7.2 (I couldn't find the method in the gmaps sdk shipped with the project so i simply replaced the old library with the latest one).
However, after doing that I started getting this compilation error:
Undefined symbols for architecture i386: "_glMapBufferRange",
referenced from:
gmscore::renderer::BufferObject::MapBuffer() in GoogleMaps(BufferObject.o) ld: symbol(s) not found for architecture
i386 clang: error: linker command failed with exit code 1 (use -v to
see invocation)
Some claim on the web that this is because 1.7.2 is not compatible with iOS6. However, looking into the release notes of gmaps SDK.. I don't see any indication that 1.7.2 is not compatible with iOS 6 - notice how in the release note of version 1.5 they explicitly state
This release officially supports iOS 7, and requires iOS 6.0 or later
(iOS 5.1 is no longer supported).
but no such disclaimer is found for iOS 6.
any idea what's going on here?
i did wind up making google maps 1.7.2 working with iOS 7 (i don't remember exactly how, but that's the easy part.. usually when get these undefined architecture problems.. i solve them by taking out support for the arm 64 and setting valid architectures only to no) but then that didn't address my problem b/c the didTapMyLocationButtonForMapView: method was a dud: it didn't work in google maps 1.7.2 (ie when the user did tap the my location button.. nothing happened).
note: so if the only reason why you are here is to verify if google maps 1.7.2 works with iOS7 i can tell you that it indeed does work. The rest of the this answer is about how to fire a callback when the mylocationButton is clicked without using the google maps 1.7.2 didTapMyLocationButtonForMapView: method, regardless if you are using 1.7.2 or prior versions.
so i reverted back to the older version of google sdk (i had no other reason to upgrade).. and created my own code that fires when the user taps the my location button. this is how it works (in a nutshell.. i override the UIApplication sendEvent method that gets fired whenever a user touches the screen, and capture the events that happen at the same dimension as the myLocation button.. and then go from there)
first I created a custom UIApplication class:
in main.m:
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, NSStringFromClass([TPMUApplication class]), NSStringFromClass([TPMUAppDelegate class]));
}
}
TPMUApplication.h
#interface TPMUApplication : UIApplication
// the view controller that has the google maps in it
#property (nonatomic, strong) TPMUVC *VC;
#end
TPMUApplication.m
#import "TPMUApplication.h"
#import "TPMUVC.h"
#implementation TPMUApplication
- (void)sendEvent:(UIEvent *)event
{
[super sendEvent:event];
UIView *touchReceipientView =((UITouch *)[event.allTouches anyObject]).view;
CGRect myLocationButtonFourchIncFrame = CGRectMake(256, 354, 64, 54);
CGRect myLocationButtonThreeHalfIncFrame = CGRectMake(256, 266, 64, 54);
if (CGRectEqualToRect(touchReceipientView.frame, myLocationButtonFourchIncFrame) ||
CGRectEqualToRect(touchReceipientView.frame, myLocationButtonThreeHalfIncFrame)) {
if (self.tVC.mapState != TPMUMapStateInMotionAsResultOfMyLocationButtonTap) {
self.VC.mapState = TPMUMapStateInMotionAsResultOfMyLocationButtonTap;
[self.VC didTapMyLocationButtonForMapView:self.VC.mapView];
}
}
}
#end
TPMUVC.h
#import <CoreLocation/CoreLocation.h>
#import <GoogleMaps/GoogleMaps.h>
typedef enum
{
TPMUMapStateIdle = 0,
TPMUMapStateInMotionAsResultOfUserGesture,
TPMUMapStateInMotionAsResultOfMyLocationButtonTap
} TPMUMapState;
#interface TPMUVC : TPMUBaseViewController<GMSMapViewDelegate>
#property (nonatomic, strong) GMSMapView *mapView;
#property (nonatomic, assign) TPMUMapState mapState;
- (BOOL)didTapMyLocationButtonForMapView:(GMSMapView *)mapView;
TPMUVC.m
#import "TPMUApplication.h"
#implementation TPMUVC
#synthesize mapView = mapView_;
#synthesize mapState = mapState_;
- (void)viewDidLoad
{
TPMUApplication *tpmuApp = (TPMUApplication *)[UIApplication sharedApplication];
tpmuApp.taxiRequestVC = self;
}
#pragma mark - GMSMapView delegate
- (void)mapView:(GMSMapView *)mapView willMove:(BOOL)gesture
{
if (gesture) {
mapState_ = TPMUMapStateInMotionAsResultOfUserGesture;
}
}
- (void)mapView:(GMSMapView *)mapView idleAtCameraPosition:(GMSCameraPosition *)position
{
if (mapState_ == TPMUMapStateInMotionAsResultOfUserGesture) {
mapState_ = TPMUMapStateIdle;
}
mapState_ = TPMUMapStateIdle;
mapCameraPosition_ = position;
DLog(#"map is now idle at position [lat: %f,long: %f] zoom: %f", position.target.latitude, position.target.longitude, position.zoom);
}
- (BOOL)didTapMyLocationButtonForMapView:(GMSMapView *)mapView {
return YES;
}

ARC semantic issue "multiple methods named 'setRotation' " while archiving only

My project in cocos2dv3 is throwing ARC Sematic Issue
Multiple methods named 'setRotation:' found with mismatched result, parameter type or attributes
while archiving(release mode). It runs fine while deploying to simulator/device (debug mode).
In release mode compiler gets confused between the implementation of rotation in UIRotationGestureRecognizer and CCNode.
When I got the error in CCBAnimationManager.m , I typecasted the object calling the selector setRotation to (CCNode*) but then the error crept up in CCActionInterval. I'm hoping there is a better solution than typecasting everywhere in cocos2d library.
What am i doing wrong?
Thankyou for your time.
EDIT
#interface CCAction : NSObject <NSCopying> {
id __unsafe_unretained _originalTarget;
id __unsafe_unretained _target;
NSInteger _tag;
}
#property (nonatomic,readonly,unsafe_unretained) id target;
#property (nonatomic,readonly,unsafe_unretained) id originalTarget;
#property (nonatomic,readwrite,assign) NSInteger tag;
in
CCAction.m
#synthesize tag = _tag, target = _target, originalTarget = _originalTarget;
-(void) startWithTarget:(id)aTarget
{
_originalTarget = _target = aTarget;
}
-(void) startWithTarget:(id)aTarget
{
_originalTarget = _target = aTarget;
}
Class Hierarchy
#interface CCActionFiniteTime : CCAction <NSCopying>
#interface CCActionInterval: CCActionFiniteTime <NSCopying>
#interface CCBRotateTo : CCActionInterval <NSCopying>
CCBRotateTo.m {
-(void) startWithTarget:(CCNode *)aTarget
{
[super startWithTarget:aTarget];
startAngle_ = [self.target rotation];
diffAngle_ = dstAngle_ - startAngle_;
}
-(void) update: (CCTime) t
{
[self.target setRotation: startAngle_ + diffAngle_ * t];
}
}
This problem gave me a big headache. Though I've upgraded cocos2d to v2.2 version for my old project (too complex to update to v3), I still got this warning. And any animation I created use rotation in the SpriteBuilder does act oddly, as I described here:
Rotation animation issue on iPhone5S with cocos2d 2.0
Finally I used type casting to solve it as following in CCBAnimationManager.m
#implementation CCBRotateTo
-(void)startWithTarget:(CCNode *)aTarget
{
[super startWithTarget:aTarget];
starAngle_ = [(CCNode *)self.target rotation];
diffAngle_ = dstAngle_ - startAngle_;
}
-(void)update:(ccTime)t
{
[(CCNode *)self.target setRotation: startAngle_ + diffAngle_ * t];
}
With this change, now I can support arm64 too.
update your cocos2dv3 to latest (RC4 for now).
I was using Xcode 5.0 and cocos2dv3 RC1 with no problem.
But updating Xcode to 5.1 I had this problem.
So I updated the cocos2dv3 to RC4 and now it's working fine.
You can find cocos 2d latest versions from here.

JMImageCache in a simple test app crashes with EXC_BAD_ACCESS

In Xcode 5.0.2
I create a blank single view app for iPhone,
then add a "male.png" image to the project,
drag a UIImageView to the storyboard
and finally add the following code to the viewDidLoad:
_imageView.image = [UIImage imageNamed:#"male.png"];
This works well:
Then I add the 4 files from JMImageCache project and change the ViewController.m to:
#import "ViewController.h"
#import "JMImageCache.h"
static NSString* const kAvatar = #"http://gravatar.com/avatar/55b3816622d935e50098bb44c17663bc.png";
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[_imageView setImageWithURL:[NSURL URLWithString:kAvatar]
placeholder:[UIImage imageNamed:#"male.png"]];
}
#end
Unfortunately, this results in app crash with the error message Thread 1: EXC_BAD_ACCESS:
At his webpage Jake Marsh (the author of JMImageCache) notes:
JMImageCache purposefully uses NSString objects instead of NSURL's to make things easier and cut down on [NSURL URLWithString:#"..."] bits everywhere. Just something to notice in case you see any strange EXC_BAD_ACCESS exceptions, make sure you're passing in NSString's and not NSURL's.
But (as an iOS programming newbie) I don't understand, what exactly does Mr. Marsh mean - since his file UIImageView+JMImageCache.m declares the 1st argument for the public method as NSURL:
- (void) setImageWithURL:(NSURL *)url placeholder:(UIImage *)placeholderImage {
[self setImageWithURL:url key:nil placeholder:placeholderImage];
}
Is the note maybe outdated and how could I fix my app?
That's a bug in JMImageCache. setImageWithURL:key:placeholder:completionBlock: calls itself, exhausting the stack.
To work around the bug, call the longer form of the method:
[_imageView setImageWithURL:[NSURL URLWithString:kAvatar]
key:nil
placeholder:[UIImage imageNamed:#"male.png"]
completionBlock:nil
failureBlock:nil];
Or, use an older version of the library (e.g. 0.4.0). Looks like the bug was introduced in 1af09be78a.

MobileCOuntryCode iOS not working

From the below post i am trying to detect the SIM in iPhone
Detect if Sim Card is available in iPhone programmatically
I tried the same code provided by you but it always return me (null). I have added core telephony framework and imported CTCarrier.h file. Is there anything more i need to do?
Thanks
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier* _carrier = info.subscriberCellularProvider;
NSLog(#"carrierName %#",_carrier.carrierName);
NSLog(#"isoCountryCode %#",_carrier.isoCountryCode);
NSLog(#"mobileCountryCode %#",_carrier.mobileCountryCode);
NSLog(#"mobileNetworkCode %#",_carrier.mobileNetworkCode);
Try this method its work.

Resources