RootViewController cannot use 'super' because it is a root class - ios

While going through a tutorial which uses a navigation based- application, I decided to create a Navigation-Based Application with my 3.2.6-Xcode and open it with Xcode 4.2 for following the tutorial with that version.
But when I open the same project in Xcode 4.2 (without changing or adding any code), the 4.2 Xcode gives me 2 errors saying:
RootViewController cannot use 'super' because it is a root class
Right now, my Xcode has 4 class-files: RootViewController.h, RootViewController.m, SaveUpAppDelegate.h and SaveUpAppDelegate.m. The error is in RootViewController.m:
- (void)dealloc {
[super dealloc];
}
and
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Relinquish ownership any cached data, images, etc that aren't in use.
}
I already searched through the internet and found this discussion (http://stackoverflow.com/questions/10113669/xcode-4-3-2-gives-error-cannot-use-super-because-it-is-a-root-class) and they say that the reason might be that the controller is that the developer forgot the superclass in the #interface line. That doesn't fit to my case, because I (or better: Xcode 3.2.6) didn't forget the superclass in RootViewController.h...
#import <UIKit/UIKit.h>
#interface RootViewController : UITableViewController {
}
#end
right now, I commented those critical lines out and it works fine, but I'm sure, I'll need those lines since most of the automatic created lines in the m-file are done with [super ....].
How to solve the problem?

My resolution was more simple. There was a misspelling in the #import "ClassHere.h" in the .m file. This resolved the issue I had.

Clean. It's an option under "Run". It removes all the build files that are automatically generated.

Related

TodayViewController class in iOS Today widget not being read?

My TodayViewController class is implemented as follows:
#import "TodayViewController.h"
#import <NotificationCenter/NotificationCenter.h>
#interface TodayViewController () <NCWidgetProviding>
#end
#implementation TodayViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSLog(#"yeehaw");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
// Perform any setup necessary in order to update the view.
// If an error is encountered, use NCUpdateResultFailed
// If there's no update required, use NCUpdateResultNoData
// If there's an update, use NCUpdateResultNewData
NSLog(#"gitalong");
completionHandler(NCUpdateResultNewData);
}
- (UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMarginInsets{
NSLog(#"yowza!");
return UIEdgeInsetsZero;
}
#end
Basically this is the boilerplate implementation that XCode provides when you create a Today target in your app. The only changes I've made are to add some NSLog() calls in each of the functions, and to remove the default left margin in the widgetMarginInsetsForProposedMarginInsets() function (as per the method in this SO thread).
However, when I look at the system log output, none of my NSLog statements are being output, and the default left margin has not gone away, so I'm thinking that for some reason, my app is not reading/processing the TodayViewController class at all, even though it is otherwise displaying my MainInterface storyboard correctly.
Does anyone know why this might be happening?
UPDATE
A detail I forgot to mention is that the MainInterface.storyboard file I was using to implement the interface was copied into this project from another version of the same project. I was able to fix this problem by recreating the entire project from scratch and recreating the interface from scratch as well, so the MainInterface.storyboard file I used in the "working" project was the original one generated by XCode. While this strategy fixed my immediate problem, I still don't understand why the storyboard file that I imported from another project didn't work. This poses a problem for interface reuse. I'd still like to know how to link an imported storyboard file to a custom ViewController.

Multiple Class in one file

Recently I was studying the possibility of creating multiple classes in only one file, for this I created a class of UIViewController with a .xib file, the structure of the file is as follows:
MyFristViewController.h
#import <UIKit/UIKit.h>
#interface MyFristViewController : UIViewController
#end
#interface MySecondViewController : UIViewController
#end
MyFristViewController.m
#implementation MyFristViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(#"Frist View Loaded");
}
#end
#implementation MySecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(#"Second View Loaded");
}
#end
My doubt is: How does the system know that is to perform the methods contained in the class called 'MyFristViewController'?
I already tried to modify the custom class in interface builder, tried to change the position of the classes in the file and the system continues running only the existing methods inside the 'MyFristViewController' class why?
How does the system know that is to perform the methods contained in the class called 'MyFristViewController'?
The filenames are irrelevant. When looking at a class, for the most part, the code between #implementation <#ClassName#> and #end is used.
Additional customization of classes can be added through categories and class extensions. These can also be specified in the same file, or different files, because (again) the filenames are irrelevant.
Generally, you should have one class per file to make it easy to read and find your code. See How many classes should a programmer put in one file? for additional discussion.
My doubt is: How does the system know that is to perform the methods contained in the class called 'MyFristViewController'?
Because the methods are in the #implementation block of MyFristViewController.
I already tried to modify the custom class in interface builder, tried to change the position of the classes in the file and the system continues running only the existing methods inside the 'MyFristViewController' class why?
Probably because you've linked them to the methods in first #interface section in your header file. Control-drag to the actual method you want to bind to. It's not clear what problem you're actually seeing.
That said, this is a terrible idea. Put each view controller in its own file. It'll work in one file, but it will create lots of confusion, as you're seeing.
I have worked on projects that define multiple classes in a single file. I loathe this practice. I find it very disorienting and I waste a lot of time searching for where the classes are defined/implemented.
I would advise you not to do this. It ends up being very confusing.

Setting Up Google Analytics on Cocos2d

Im trying to set up google analytics but I'm using cocos 2d.
The steps on google says:
You would update this header to:
#import "GAITrackedViewController.h"
#interface HomeViewController : GAITrackedViewController
But how can I do this seeing as my header is:
#interface GameMain : CCLayer <GKAchievementViewControllerDelegate, GKLeaderboardViewControllerDelegate, SKProductsRequestDelegate,SKPaymentTransactionObserver, MBProgressHUDDelegate >
Then also it says:
You must also provide the view name to be used in your Google Analytics reports. A good place to put this is the view controller's initializer method, if you have one, or the viewDidAppear: method:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.screenName = #"About Screen";
}
If anyone knows the solution please tell me.
Thanks

Error when using MKMapView

I created a single view application with story boards. All I had in my view was MKMapView, thats it. It compiles without errors or warning but when I run it, I get this error in my console window:
<Error>: ImageIO: CGImageReadSessionGetCachedImageBlockData *** CGImageReadSessionGetCachedImageBlockData: readSession [0x8ab5750] has bad readRef [0x14b79c70]
I'm using Xcode 4.3 and iPhone Simulator 5.1. Any thoughts?
.h File
#import UIKit/UIKit.h
#import CoreLocation/CoreLocation.h
#import MapKit/MapKit.h
#interface WhereamiViewController : UIViewController <CLLocationManagerDelegate, MKMapViewDelegate>
{
IBOutlet MKMapView *worldView;
IBOutlet UIActivityIndicatorView *activityIndicator;
IBOutlet UITextField *locationTitleField;
}
#end
.m file
#import "WhereamiViewController.h"
#interface WhereamiViewController ()
#end
#implementation WhereamiViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
Just ran into this:
Simple Fix: Make sure to check the box for "shows user location" for the MapView in interface builder.
Probably i should not answer a question of almost a year, but i was having the same issue and the cause was that i was calling CLLocationManager *startUpdateLocation* on viewDidLoad method, when i change it to viewWillAppear the issue dissapeared.
That looks to me like a bug in the framework. Report it using the Apple Bug Reporter and see if it's a known issue.
My PNG's contained some transparent parts and I think this caused the problem, because after removing these parts the error disappeared. Maybe I had some error in my PNG files, because transparency should be supported.
I also ran into the same problem. I solved it by commenting out all the code and compile the program. Then I uncommented each method one by one compiling after each time. For some reason that seemed to get rid of the error for me.
Correct ur codes as below, and create the outlet of map view.
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
Well I'm doing a much simpler project so I'm not sure if it will help you. But I'll show you my code anyway. You may want to just start with this and then see if you can build from there.
So for the ViewController.h it should read......
#import <UIKit/UIKit.h>
#import <MapKit

how to add a ready-to-use project ( created and started with application delegate but without xib,nib) to another project

I have a ready-to-use project ( created and started with application delegate but without xib,nib). Now I want to invoke and start it from another project.
But I can't use initwithnib, how can I include and start this ready-to-use project from another project?
More specifically, how to add and integrate Apple's Sample code " TableViewUpdates ( TVAnimationsGestures.xcodeproject ) " which only has its own appDelegate and Mainwindow.xib file to my own application? thanks!
Or can you add a xib file to the Apple's Sample code " TableViewUpdates ( TVAnimationsGestures.xcodeproject ) " so that I may use initWithNib in my another project to invoke and run the sample code. thanks !
I work on Xcode 4.3.2.
Create sigle view sigle view app.
Expand all folders in MoviePlayer example. Select all files, except info.plist, main, Frameworks, Products folders, readme.txt, MoviePlayer.project. Copy them to new empty project. Don't forget to check "add to target".
In target's build phase tab added MediaPlayer.framework (in link Binary with libs)
Copy all object from MainWindow.xib to your own xib for your viewController.
Than in ViewController.h :
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
#property (strong, nonatomic) IBOutlet UITabBarController *tabBarConroller;
#end
Connect your tabBarController from ViewController.xib to the property.
Than in ViewController.m :
#implementation ViewController
#synthesize tabBarConroller;
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubview:tabBarConroller.view];
}
- (void)viewDidUnload
{
[self setTabBarConroller:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
...other appdelegateMethods ...
#end
7. Check that all objects in viewController.xib has necessary outlets.
6. Edit > Refactor > Convert to ARC. (next, ok...)
It's done.

Resources