I’m trying to have 2 views in my app, using 2 buttons on my home screen. For each of these buttons I’ve created a new class and added the following code to my view controller:
ViewController.h :
#import <UIKit/UIKit.h>
@interface Gallerie2ViewController : UIViewController {
}
- (IBAction)switch2class1:(id)sender; // 1st button
- (IBAction)switch2class2:(id)sender; // 2nd one
@end
ViewController.m :
#import "ViewController.h"
#import "class1.h"
#import "class2.h"
@implementation ViewController
- (IBAction)switch2class1:(id)sender
{
Class1 *Class1view = [[Class1 alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:Class1view animated:YES];
}
- (IBAction)switch2class2:(id)sender
{
Class2 *Class2View = [[Class2 alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:Class2View animated:YES];
}
Class1.h/.m has the same content than Class2.h/.m , but when running my app, the 1st button works fine (opens the Class1 view) but the 2nd button crashes the app!
What am I doing wrong?
Allright, I’ve checked with the console (thanks Sam Jarman) and found the cause of this issue : one of my classes (Class2) was named List. So it compiled with List.h and List.m but List.h is already defined (probably part of the SDK). It didn’t make any error/warning of the conflict at compiling, but well.. i’ve renamed list.h to cat.h and it works fine now !
Thanks !