Why is Core Plot delegate protocol not found? - objective-c

I try to use Rays tutorial of Core plot for my iPad App
I use a SplitViewController
And I want to have a scatter plot in my DetailViewController
I change my Code to:
#interface GWDetailViewController : UIViewController <UISplitViewControllerDelegate,CPTPlotDataSource>
and now I get this error:
Cannot find protocol declaration for 'CPTPlotDataSource'
to add frameworks and librarys was no problem
What is wrong?

Make sure that the .h file for your view controller contains the following import statement:
#import "CorePlot-CocoaTouch.h"

If you dont want to import header file every time, you can Import it in .pch file for once.
In your scenario ,Open .pch file(usually placed in supporting file folder ) and add following code.
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "CorePlot-CocoaTouch.h"
#import "CPDConstants.h"
#import "CPDStockPriceStore.h"

Related

Use classes without import header

I have some weird codes.
ClassA.h
// there is no import code
#protocol Album <Meta>
#end
#interface MyAlbum: VariantMeta <Album>
#end
What I know is this.
If I want to use any classes which are declared from outside of current file (in this case Meta and VariantMeta) I have to import those classes header files.
But Class.h can use Meta without imports any headers.
There should be #import 'Meta.h'; in my understanding.
But there is not!
Can I get any hints for understanding this situation?
help me
thanks
Update
Class.m file looks like this.
// Class.m
#import <Framework/SomeHeaderWhichImportMetaHeaderFile>
#import "ClassA.h"
#implementation MyAlbum
#end
I guess this Class.m file's import, somehow, affects header file. but I don't know how it can be...

YTPlayerView not found issue

Currently i have kinda strange issue with YTPLayerView. I already have a project that contains both Objective-C and Swift codes. So, I need to use Youtube Player in Objective-c. The problem is that when i declare my Objective-c View Controller in Bridging-Header my Objective-C header file fives an error "'YTPlayerView.h' file not found", but this error do not occurs when my Bridging header is empty. Maybe i forgot something to include idk. Can someone help me?
This is my Bridging Header code:
#import "CameraViewController.h";
This is my CameraViewController.h file:
#import UIKit;
#import "YTPlayerView.h"
#interface CameraViewController : UIViewController<YTPlayerViewDelegate>
#property(nonatomic, strong) IBOutlet YTPlayerView *playerView;
#end
I have already installed the podfile for youtube player:
use_frameworks!
target 'MyApp' do
pod 'youtube-ios-player-helper', '~> 0.1.4'
end
Thank you in advance!
Try to do:
#import <youtube_ios_player_helper/YTPlayerView.h>

Circular Importing of ViewController

In Appdelegate I am Importing Some Class for showing the view and in that view I have required to import the Same AppDelegate for accessing some method and variable but when I am doing this. Its shows circular import error.
I have tried by importing by #class in .h file and import in .m file.
In both classes you should only use #class in the .h file and then add the #import in the .m file. This is the correct solution for the problem you describe.
Note that the circularity could be bigger because a 3rd class could be #imported and it in turn #imports another class to make the circular link. Generally you should use #class in your .h files unless you have to #import (for the superclass and #protocols you implement).

Strange Delegate Protocol Declaration error?

So in a header file I have the following code:
#import <AudioToolbox/AudioToolbox.h>
#interface alertController:UIViewController <AVAudioPlayerDelegate>
{
AVAudioPlayer *player;
}
I have both the framework linked and It works just fine in another file within the same project, but I am getting the error that it cannot find the protocol declaration for "AVAudioPlayerDelegate", nor does it recognize the line AVAudioPlayer * audioPlayer because it is an unknown type name. Any ideas why this isn't working despite my import statement, including the framework, and the fact that it's working fine in another file?
AVAudioPlayer (and its delegate) come from AVFoundation, not AudioToolbox. Your other project probably imports <AVFoundation/AVFoundation.h> either through a separate included header file or through your PCH. You should replace that #import with
#import <AVFoundation/AVFoundation.h>

How can i use MBProgressHUD in multiple ViewControllers?

I have a problem using the MBProgressHUD library. I can use it normally in my main ViewController, but, then, when i try to import the .h file in other view controller, i have the following error:
Redefinition of enumerator 'MBProgressHUDModeIndeterminate'
Redefinition of enumerator 'MBProgressHUDModeDeterminate'
...
Does anyone knows how can i manage it?
Thanks
EDIT: I have the following imports in my main view controller
#import "ViewController.h"
#import "FMDatabase.h"
#import "AppDelegate.h"
#import "MBProgressHUD.h"
#implementation ViewController
When i try to put this imports in other view controller, i get the errors:
#import "FinalViewController.h"
#import "Parse/Parse.h"
#import "MBProgressHUD.h"
#implementation FinalViewController
I have used the MBProgressHUD library from this link https://github.com/matej/MBProgressHUD
You're probably #include-ing MBProgressHUD.h rather that #import-ing it. #import ensures that it's only imported once.
I've used MBProgressHUD exclusively in my apps, and across multiple view controllers and never seen that issue before.
You could try and add your import statement to your .pch file rather than import for each view controller. It will add the header even if you don't use it, but might be worth a go.
Also, make sure you only have one copy of the header file in your project. The error you are showing almost looks like it is being defined twice which would indicate too many headers.