I’m trying to get my app a little more dynamic. I’m trying to declare a function in a class that is supposed to get instantiated and used by a few other classes i have.
At the moment i’m doing this.
// FunkBib.h
#import <Foundation/Foundation.h>
@interface FunkBib : NSObject {
}
-(NSString *)formateraTillEEEEdMMMM:(id)suprDatum;
@end
// FunkBib.m
-(NSString *)formateraTillEEEEdMMMM:(id) suprDatum{
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
dateFormatter.dateFormat = @"yyyyMMdd";
NSDate *date = [dateFormatter dateFromString:suprDatum];
NSLocale *swedishLocale=[[[NSLocale alloc] initWithLocaleIdentifier:@"sv_SE"] autorelease];
dateFormatter.locale=swedishLocale;
dateFormatter.dateFormat=@"EEEE d MMMM";
NSString * weekdayString= [dateFormatter stringFromDate:date];
NSString *newWeekDayString = [weekdayString stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:[[weekdayString substringToIndex:1] capitalizedString]];
return newWeekDayString;
}
Meanwhile in my other classes i do this.
//someclass.h
#import <UIKit/UIKit.h>
@class FunkBib;
@interface someclass : UIViewController {
FunkBib *funkBib;
}
@property(nonatomic,retain) FunkBib *funkBib;
@end
// someclass.m
#import "FunkBib.h"
@implementation someclass.m
@synthesize funkBib;
And at a later point in the code i’d like to use this function like this.
somelabel.text = [funkBib formateraTillEEEEdMMMM:[someArray objectAtIndex:somewhere]];
I have no direct idea why this is not working. Anyone have any general pointers about how i might solve this?
BTW: The code is not copy-pasted, so there may be syntax errors.
create instance for FunBib
-(void)viewDidLoad{
[super viewDidLoad];
self.funkBib=[[FunkBib alloc] init];
somelabel.text = [self.funkBib formateraTillEEEEdMMMM:[someArray objectAtIndex:somewhere]];
}