Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

begdev

macrumors newbie
Original poster
Mar 14, 2009
20
0
If you've seen me here before, I've been quite noob.
But like i promised, i read up and am making an RSS organizer application all my, myself. but i ran into some issues... After debugging, I am left with 1 error (twice)

EDIT: After some tinkering i discovered by first problem, but now i have new ones...
"fatal error: method definition not in @implementation context"

heres the code...
my header:
Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface NavController : UINavigationController {
	
    IBOutlet id delegate;
	
	UIView *infoView;
	
	UIView *settingsView;
	
}

@end

- (IBAction)infoClick:(id)sender;
- (IBAction)settingsClick:(id)sender;

my implementation:
Code:
#import "Navcontroller.h"
@class infoView
@implementation Navcontroller
@end

- (IBAction)infoClick:(id)sender {
	
	[self addSubView:infoView];
    
}

- (IBAction)settingsClick:(id)sender {
    
}
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
The @end is at the wrong place. Move it to the bottom of both files. All method declarations and implementations should be between the @interface/@end and @implementation/@end.

The '@class infoView' line should be removed.

'@implementation Navcontroller' should be '@implementation NavController' - Objective-C is case sensitive.
 

begdev

macrumors newbie
Original poster
Mar 14, 2009
20
0
The @end is at the wrong place. Move it to the bottom of both files. All method declarations and implementations should be between the @interface/@end and @implementation/@end.

The '@class infoView' line should be removed.

'@implementation Navcontroller' should be '@implementation NavController' - Objective-C is case sensitive.

Works!

except now we have a few more issues...

Navcontroller.h
Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface NavController : UINavigationController {
	
    IBOutlet id delegate;
	
	UIView *infoView;
	
	UIView *settingsView;
	
}

- (IBAction)infoClick:(id)sender;
- (IBAction)settingsClick:(id)sender;

@end

Navcontroller.m

83193db5ac361eac3da1f50c99d26c57.png


infoView.h

Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface infoView : UIView {

}


- (IBAction)backButton:(id)sender;
	
@end

infoView.m

Code:
#import "infoView.h"

@implementation infoView

- (IBAction)backButton:(id)sender {
    
	[self removeFromSuperview];
}

@end

i took out the @class in all files. and i think this has caused the issue, but i can't get it to compile with them...

basically, on the navigation bar, there is a button, and its linked to when its clicked, add the infoView to it...
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
To compile that'd be [self.view addSubview:infoView] but I have a feeling that's not what you want..

But, infoView is never set. I see that you have some C++ experience. ALL objects in Cocoa are used as pointers, so you cannot just declare it and have it created like you can when you declare an object in C++. You need to assign it to something. Is your infoView in a nib? Maybe you could post a screenshot of your nib.
 

begdev

macrumors newbie
Original poster
Mar 14, 2009
20
0
To compile that'd be [self.view addSubview:infoView] but I have a feeling that's not what you want..

But, infoView is never set. I see that you have some C++ experience. ALL objects in Cocoa are used as pointers, so you cannot just declare it and have it created like you can when you declare an object in C++. You need to assign it to something. Is your infoView in a nib? Maybe you could post a screenshot of your nib.

sure hold on for the screenshot. thx for your help btw.

EDIT: k here it is http://www.grabup.com/uploads/aae857bd8ae20979f40f4e8f861c0ca6.png
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Ok, declare your infoView as an IBOutlet like you did with delegate and then you can connect it from the controller to the view in the nib.
 

begdev

macrumors newbie
Original poster
Mar 14, 2009
20
0
Ok, declare your infoView as an IBOutlet like you did with delegate and then you can connect it from the controller to the view in the nib.

like this?

.h

cd9fb66c6c70393f566387d3400d1eab.png


.m

fea58f1e8bbf24563e986cca4995bf6a.png




c4908e347c913d24089b355bb3d6ac88.png


amazingly enough, i got the other 70% of the app done perfectly (its the tableview part)
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
UINavigationController already has a property for delegate, so remove that entirely.

For the infoView, it's preferred to declare it like IBOutlet UIView *infoView; so that IB knows what it really is and prevents you from connecting it to something else.

I gave you the fix above for the addSubview: method (remember Obj-C is case sensitive) - the other one should be obvious. Just delete or comment out the settingsClick: method definition if you're not going to use/implement it.

Edit: I should just get on iChat, share screens and fix it all for you real quick :p
 

begdev

macrumors newbie
Original poster
Mar 14, 2009
20
0
UINavigationController already has a property for delegate, so remove that entirely.

For the infoView, it's preferred to declare it like IBOutlet UIView *infoView; so that IB knows what it really is and prevents you from connecting it to something else.

I gave you the fix above for the addSubview: method - the other one should be obvious. Just delete or comment out the settingsClick: method definition if you're not going to use/implement it.

Ok well i did all of that, and it makes sense on how this would work. Yet, it does not... When I click the Nav button, it crashes.

Could this be that I'm using the navbar controller and nav button? and then a UIView?

Edit: I should just get on iChat, share screens and fix it all for you real quick :p


Would you???
 

MacMatt1

macrumors newbie
Feb 2, 2010
2
0
I have a similar problem and after exhausting attempts can not rearrange this into a way that will compile. Could somebody offer me some kind help please. Will be much appreciated.

Code:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface FestViewController : UIViewController { 
	IBOutlet UILabel *holidayInfo;
	IBOutlet UILabel *holidayWeb;
	IBOutlet UIImageView *holidayImage;
	IBOutlet UILabel *holidayDays;
	IBOutlet UILabel *holidayLoc;
	IBOutlet UILabel *holidayLong;
	IBOutlet UILabel *holidayLat;
	IBOutlet UILabel *holidayID;
	IBOutlet UILabel *holidayDates;
	IBOutlet UILabel *holidayCount;

}
@end



@interface AddressAnnotation : NSObject<MKAnnotation> {
	CLLocationCoordinate2D coordinate;
	
	NSString *mTitle;
	NSString *mSubTitle;
}

@end

@interface MapViewController : UIViewController<MKMapViewDelegate> {
	
	IBOutlet UIButton *goButton;
	IBOutlet MKMapView *mapView;
	
	AddressAnnotation *addAnnotation;
}

- (IBAction) showAddress;

-(CLLocationCoordinate2D) addressLocation;

@end

@property (nonatomic, retain) IBOutlet UILabel *holidayInfo;
@property (nonatomic, retain) IBOutlet UILabel *holidayWeb;
@property (nonatomic, retain) IBOutlet UIImageView *holidayImage;
@property (nonatomic, retain) IBOutlet UILabel *holidayDays;
@property (nonatomic, retain) IBOutlet UILabel *holidayLoc;
@property (nonatomic, retain) IBOutlet UILabel *holidayLong;
@property (nonatomic, retain) IBOutlet UILabel *holidayLat;
@property (nonatomic, retain) IBOutlet UILabel *holidayID;
@property (nonatomic, retain) IBOutlet UILabel *holidayDates;
@property (nonatomic, retain) IBOutlet UILabel *holidayCount;



- (IBAction)webPush:(id)sender;
 

MacMatt1

macrumors newbie
Feb 2, 2010
2
0
Hi again thanks for that, it now compiles. Next problem is though that it crashes when that view is loaded. There is a warning about the @end. I'll attach a screenshot. Thanks in advance again!
 

Attachments

  • Picture 14.png
    Picture 14.png
    18.7 KB · Views: 92

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Also, to keep things less confusing, it's common to restrict one class definition per file (with paired .h and .m, of course). So, you'd have:
- FestViewController.h and .m
- AddressAnnotation.h and .m
- MapViewController.h and .m
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.