I have created a singleton for my MusicBackground. And I receive a line code of imcomplete implementation of this line #implementation MyBgMusic. Can anyone tell me why ? Below is the code:
#import "MyBgMusic.h"
static MyBgMusic *sharedMyManager = nil;
#implementation MyBgMusic
#synthesize player,playBgMusic;
#pragma mark -
#pragma mark Singleton Methods
+ (MyBgMusic*)sharedInstance {
static MyBgMusic *_sharedInstance;
if(!_sharedInstance) {
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedInstance = [[super allocWithZone:nil] init];
});
}
return _sharedInstance;
}
+ (id)allocWithZone:(NSZone *)zone {
return [self sharedInstance];
}
- (id)copyWithZone:(NSZone *)zone {
return self;
}
#if (!__has_feature(objc_arc))
- (id)retain {
return self;
}
- (unsigned)retainCount {
return UINT_MAX; //denotes an object that cannot be released
}
- (id)autorelease {
return self;
}
- (void)dealloc
{
[MyBgMusic release];
[playBgMusic release];
[player release];
[super dealloc];
}
#endif
#pragma mark -
#pragma mark Custom Methods
- (void)viewDidLoad
{
NSString *path = [[NSBundle mainBundle] pathForResource:#"music" ofType:#"mp3"];
self.player=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
player.delegate = self;
[player play];
player.numberOfLoops = -1;
[super viewDidLoad];
}
#end
For the M file, below is the code:
#import <Foundation/Foundation.h>
#import <AVFoundation/AVAudioPlayer.h>
#interface MyBgMusic : UIViewController <AVAudioPlayerDelegate> {
AVAudioPlayer *player;
UIButton *playBgMusic;
}
#property (nonatomic, retain) IBOutlet AVAudioPlayer *player;
#property (nonatomic, retain) IBOutlet UIButton *playBgMusic;
+ (id)sharedManager;
-(IBAction) toggleMusic;
#end
And how do I reference to my toggle button: Below is the code :
- (IBAction)toggleMusic {
if ([self.player isPlaying] == YES) {
[self.player stop];
} else {
[self.player play];
}
self.playBgMusic.enabled = YES;
}
It means that your MyBgMusic class isn't doing everything it promised to do in its header file, which includes being a UIViewController and implementing the AVAudioPlayerDelegate protocol. I'm not familiar with exactly what the AVAudioPlayerDelegate is, but it's quite possible that your class doesn't implement all of the required methods.
Also, you're declaring methods +(id)sharedManager and -(IBAction)toggleMusic, but I don't see them anywhere in the implementation file. That would be a case of promising something in the header and not implementing it in the class.
It would help if you posted the actual error message.
That error means your #implementation section does not contain everything described in the #interface section.
I can see two problems.
First you need to place this code:
- (IBAction)toggleMusic {
...
}
Somewhere in between #implementation and #end.
And you also need to rename the line + (MyBgMusic*)sharedInstance to + (id)sharedManager.
EDIT:
To access the toggle music method elsewhere in your code, you would do:
[[MyBgMusic sharedManager] toggleMusic];
Your +(id)sharedManagerimplementation is called +(id)sharedInstance. Just guessing, but it seems they are supposed to do the same.
Related
I have created singleton class for AVAudioPlayer. I am able to call the methods in the class and everything works fine. When the song finishes,the method (void)audioPlayerDidFinishPlaying is called which in turn suppose to call the method ' processSuccessful' in my downloadPlay.m class. But, it is not calling the method 'processSuccessful'
My codes as follows
PlayerManager.h
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
#protocol ProcessDataDelegate <NSObject>
#required
- (void) processSuccessful;
#end
#interface PlayerManager : NSObject<AVAudioPlayerDelegate,AVAudioSessionDelegate>
{
id <ProcessDataDelegate> delegate;
}
+ (PlayerManager *)sharedAudioPlayer;
#property (nonatomic,assign) id <ProcessDataDelegate>delegate;
#property (nonatomic, strong) AVAudioPlayer* player;
-(void)preparesong:(NSURL *)url;
-(void)stopsong;
-(void)pause;
-(void)playsong;
-(void)prepareToPlay;
-(BOOL)isPlaying;
-(BOOL)isPlayerExist;
#end
PlayerManager.m
#import "PlayerManager.h"
#interface PlayerManager()
#end
#implementation PlayerManager
#synthesize player;
#synthesize delegate;
static PlayerManager *sharedAudioPlayer = nil;
+ (PlayerManager *)sharedAudioPlayer {
static PlayerManager *sharedAudioPlayer = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedAudioPlayer = [[self alloc] init];
});
return sharedAudioPlayer ;
}
- (void)audioPlayerEndInterruption:(AVAudioPlayer *)player withOptions:(NSUInteger)flags
{
if (flags & AVAudioSessionInterruptionOptionShouldResume)
{
[self.player play];
}
}
- (void)audioPlayerBeginInterruption:(AVAudioPlayer *)player
{
}
#pragma mark - AVAudioPlayerDelegate
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
[[self delegate] processSuccessful];
}
- (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error
{
}
-(void)preparesong:(NSURL *)url
{
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
NSError *error;
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if(!self.player)
{
NSLog(#"Error creating player: %#", error);
}
self.player.delegate = self;
[self.player prepareToPlay];
}
-(BOOL)isPlayerExist
{
if (player)
return YES;
return NO;
}
-(BOOL)isPlaying
{
if (player && player.playing)
return YES;
return NO;
}
-(void)prepareToPlay
{
if (player)
[self.player prepareToPlay];
}
-(void)playsong
{
if (player)
[self.player play];
}
-(void)pause
{
if (player.playing)
[self.player pause];
}
-(void)stopsong
{
if (player)
[self.player stop];
}
#end
downloadPlay.h
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
#import "PlayerManager.h"
#interface downloadPlay: UIViewController <UITableViewDelegate,AVAudioPlayerDelegate,ProcessDataDelegate>
{
PlayerManager *protocolPlay;
}
#property (retain, nonatomic) IBOutlet UITableView *tblFiles;
......
- (void)startPlay:(id)sender;
........
#end
downloadPlay.m
import "downloadPlay.h"
#import "PlayerManager.h"
#interface downloadPlay ()
#end
#implementation downloadPlay
.....
- (void)processSuccessful
{
NSLog(#"This method suppose to be called from the method audioPlayerDidFinishPlaying - from PlayerManager");
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
protocolPlay = [[PlayerManager alloc]init];
[protocolPlay setDelegate:self];
}
- (void)startPlay
{
............
.........
NSURL *destinationURL = [self.docDirectoryURL URLByAppendingPathComponent:filename];
NSError* error = nil;
[[PlayerManager sharedAudioPlayer]stopsong];
[[PlayerManager sharedAudioPlayer ] preparesong:destinationURL ];
[[PlayerManager sharedAudioPlayer]playsong];
}
#end
In viewDidLoad method you are creating a different object by using
protocolPlay = [[PlayerManager alloc]init];
line and set the delegate of this object while you have to set the delegate of shared object.
Solution is:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[[PlayerManager sharedAudioPlayer] setDelegate:self];
}
I'm using the AFNetworking library to parse json using the AFHTTPClient. I can verify that the json is being parsed within the client block and send that data to my json model. However, when I try to access the json model from outside the block I get no data. How can I pass the parsed json data to the json model then access that model data elsewhere in the app?
the AFHTTPClient subclass / singleton:
#import <Foundation/Foundation.h>
#import "AFHTTPClient.h"
#interface JsonClient : AFHTTPClient
+ (JsonClient *)sharedClient;
#end
#import "JsonClient.h"
#import "AFJSONRequestOperation.h"
static NSString *const kJsonBaseURLString = #"https://alpha-api.app.net/";
#implementation JsonClient
+ (JsonClient *)sharedClient {
static JsonClient *_sharedClient = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [[JsonClient alloc] initWithBaseURL:[NSURL URLWithString:kJsonBaseURLString]];
});
return _sharedClient;
}
- (id)initWithBaseURL:(NSURL *)url {
self = [super initWithBaseURL:url];
if (!self) {
return nil;
}
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
[self setDefaultHeader:#"Accept" value:#"application/json"];
return self;
}
#end
the JSON model data:
#import <Foundation/Foundation.h>
#interface TheJson : NSObject
#property (nonatomic, copy) NSString *createdAt;
#property (nonatomic, copy) NSString *userText;
- (id)initWithDictionary:(NSDictionary *)dict;
#end
#import "TheJson.h"
#implementation TheJson
- (id)initWithDictionary:(NSDictionary *)dict {
self = [super init];
if (self) {
self.createdAt = [dict objectForKey:#"created_at"];
self.userText = [dict objectForKey:#"text"];
}
return self;
}
#end
the ViewController to update the user interface:
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
#end
#import "ViewController.h"
#import "JsonClient.h"
#import "TheJson.h"
#interface ViewController ()
#property (weak) IBOutlet UILabel *createdLabel;
#property (weak) IBOutlet UILabel *textLabel;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (IBAction)fetchJsonData:(id)sender {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
[[JsonClient sharedClient] getPath:#"stream/0/posts/stream/global" parameters:nil
success:^(AFHTTPRequestOperation *operation, id JSON) {
NSArray *postsFromResponse = [JSON valueForKeyPath:#"data"];
NSDictionary *dictFromArray = postsFromResponse[0];
TheJson *jsonObject = [[TheJson alloc] initWithDictionary:dictFromArray];
NSLog(#"createdAt is %#", jsonObject.createdAt);
NSLog(#"text from user is %#", jsonObject.userText);
[self updateInterface];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Error is %#", [error description]);
}
];
}
- (void)updateInterface {
TheJson *thejson;
[_createdLabel setText:thejson.createdAt];
[_textLabel setText:thejson.userText];
}
#end
You haven't passed the new jsonObject out of the block nor stored it anywhere. A short term answer is to declare updateInterface to take the jsonObject as a parameter.
So your updateInterface becomes updateInterface: something like this:
- (void)updateInterface:(TheJson*)thejson {
[_createdLabel setText:thejson.createdAt];
[_textLabel setText:thejson.userText];
}
...and then within your block, you call this method like this:
[self updateInterface:jsonObject];
Longer term, if your app has many of these objects and/or needs to hold onto them for any amount of time, you probably want to think about how you will store and organize these as you download them.
Is it possible to create an instance of an object in class A and access that same instance of the object from class B? I am trying to develop an app that creates a TCP Socket using NSInputStream and NSOutputStream and need more than one class to be able to access it.
Thank you,
Travis Elliott
edit
Here is the code I am working with. Its a program that deals with socket connections. I basically need to be able to communicate to the same socket from my appDelegate and View controller. Here is the code I have based on your help. I am using the appDelegate as the control(D in your example), perhaps I cannot do this. CommunicationHub is the class I need to control the same instance of from both AppDelegate and ViewController.
AppDelegate.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
#import "CommunicationHub.h"
#interface AppDelegate : UIResponder <UIApplicationDelegate>{
ViewController *viewController;
CommunicationHub *cHub;
}
#property (strong, nonatomic) UIWindow *window;
#property (strong, retain) ViewController *viewController;
#property (strong, retain) CommunicationHub *cHub;
-(void)CreateInstances;
#end
AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
#implementation AppDelegate
#synthesize viewController;
#synthesize cHub;
#synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self CreateInstances];
// Override point for customization after application launch.
return YES;
}
-(void)CreateInstances{
NSLog(#"Inside CreateInstances");
CommunicationHub *cHub = [[CommunicationHub alloc] init];
viewController = [[ViewController alloc] init];
[viewController initWithcHub:cHub];
NSLog(#"ID of cHub in AppDelegate is %i", cHub);
}
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(#"Application Will Resign Active");
[cHub disconnect];
}
#end
ViewController.h
#import <UIKit/UIKit.h>
#import "CommunicationHub.h"
#interface ViewController : UIViewController
{
CommunicationHub *cHub;
}
#property (strong, nonatomic) IBOutlet UITextField *IPAddress;
#property (strong, nonatomic) IBOutlet UITextField *PortNumber;
- (IBAction)goAwayKeyBoard:(id)sender;
- (IBAction)touchBackground:(id)sender;
-(void) initWithcHub:(CommunicationHub *)ptr;
- (IBAction)connectSocket:(id)sender;
- (IBAction)disconnectSocket:(id)sender;
#end
ViewController.m
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize IPAddress;
#synthesize PortNumber;
-(void) initWithcHub:(CommunicationHub *)ptr
{
cHub = [[ptr retain]init];
NSLog(#"id of cHub in ViewController is %i", cHub);
}
- (IBAction)connectSocket:(id)sender
{
//Called by button on UI.
int portNumber = [PortNumber.text intValue];
[cHub Connect:(int *)portNumber ipAddress:(IPAddress.text)];
}
- (IBAction)disconnectSocket:(id)sender
{
//Called by button on UI.
[cHub disconnect];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setIPAddress:nil];
[self setPortNumber:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
-(IBAction)goAwayKeyBoard:(id)sender{
[self resignFirstResponder];
}
- (IBAction)touchBackground:(id)sender {
[IPAddress resignFirstResponder];
[PortNumber resignFirstResponder];
}
#end
CommunicationHub.h
#import <UIKit/UIKit.h>
NSInputStream *inputStream;
NSOutputStream *outputStream;
#interface CommunicationHub : NSObject <NSStreamDelegate>
- (void)Connect:(int *)port ipAddress:(NSString *)ipAddress;
- (void) disconnect;
#end
CommunicationHub.m
#import "CommunicationHub.h"
#implementation CommunicationHub
- (void)Connect:(int *)port ipAddress:(NSString *)ipAddress
{
NSLog(#"inside connect method");
if ([inputStream streamStatus] == 0 ||[inputStream streamStatus] == 5 ||[inputStream streamStatus] == 6 ||[inputStream streamStatus] == 7)
{
NSString *myString = ipAddress;
CFStringRef *myCFString = (__bridge CFStringRef)myString;
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL, myCFString, port, &readStream, &writeStream);
inputStream = (__bridge NSInputStream *)readStream;
outputStream = (__bridge NSOutputStream *)writeStream;
[inputStream setDelegate:self];
[outputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[inputStream open];
[outputStream open];
}
}
- (void) disconnect
{
NSLog(#"inside disconnect method");
if (inputStream != nil) {
if ([inputStream streamStatus] == 2) {
NSLog(#"Disconnecting Streams");
[inputStream close];
[outputStream close];
}else {
NSLog(#"Stream is not Open");
int status = [inputStream streamStatus];
NSLog(#"Stream Status is %i", status);
}
}else {
NSLog(#"Input Stream equals Nil");
}
}
#end
To make it long:
Assuming you have class A, B and C.
C needs to be accessible, from both A and B.
Now, let's assume we have controller D, which instantiates both A and B.
Have D instantiate C first, and store it in a variable.
C *C_Class = [[[C alloc] init] autorelease];
Next, instantiate A and B with C (I'm assuming 'retain properties' here)
self.A_Class = [[[A alloc] initWithC:C_Class] autorelease];
self.B_Class = [[[B alloc] initWithC:C_Class] autorelease];
In both classes, you need the instance method:
- (id)initWithC:(C *)C_Class;
and in the .m file:
- (id)initWithC:(C *)C_Class {
C_C = [C_Class retain]; //Assuming a regular instance variable
}
- (void) dealloc {
[C_C release]; //All that is retained, must be released.
}
From this moment on, you have access to that one instance of Class C in classes A and B, via the name 'C_C'.
Now, please mind that this is just written from the back of my head and prone to have errors, but it SHOULD be alright.
I hope it helps :)
Edit: Since the OP seems to have trouble with these code fragments, I'll add a more complete code.
Let's start with the control class 'D'.
D.h:
#import "A.h"
#import "B.h"
#interface D : NSObject
-(void)CreateInstances;
#property (strong, retain) A *A_Class;
#property (strong, retain) B *B_Class;
#end
D.m:
#import "D.h"
#import "C.h"
#implementation D
-(void)CreateInstances {
C *C_Class = [[C alloc] init] autorelease];
self.A_Class = [[[A alloc] initWithC:C_Class] autorelease];
self.B_Class = [[[B alloc] initWithC:C_Class] autorelease];
}
#end
A.h (B.h mirrors this behavior, maybe consider using a superclass for both)
#import "C.h"
#interface A : NSObject {
C *C_Class; //Class Reference to the C-Object
}
-(id) initWithC:(C *)ptr; //Initialization method, which takes a 'C'-Object.
#end;
A.m
#import "A.h"
#implementation A
- (id) initWithC:(C *)ptr {
C_Class = [ptr retain]; //So the object doesn't get released prematurely.
}
- (void) dealloc {
[C_Class release]; //To avoid memory leaks.
}
#end
Now, please remember, that I wrote this off the top of my head and didn't run it through a compiler, but it SHOULD work, save typos and the likes.
Another edit:
After the OP added his own code, I will post relevant bits of 'corrected' code here.
AppDelegate.m
-(void)CreateInstances{
NSLog(#"Inside CreateInstances");
cHub = [[CommunicationHub alloc] init]; //We're using the instance variable. Not the local one.
viewController = [[ViewController alloc] initWithcHub:cHub];
//[viewController initWithcHub:cHub]; //You may want to rethink your function names.
NSLog(#"ID of cHub in AppDelegate is %i", cHub);
}
ViewController.m
//If a method names STARTS with 'init', it SHOULD initialize the object.
-(id) initWithcHub:(CommunicationHub *)ptr
{
self = [super init]; //Calls the 'init' from the parent class.
if(self) {
cHub = [ptr retain]; //Just retain. After all, the object IS initialized already.
NSLog(#"id of cHub in ViewController is %i", cHub);
}
return self;
}
- (void) dealloc {
[cHub release]; //Basic rule of memory management: ALL that is retained, must be released. In dealloc, at latest.
}
- (IBAction)connectSocket:(id)sender
{
//Called by button on UI.
//Do not pass a pointer to anything, unless you mean to use a pointer.
[cHub Connect:[PortNumber.text intValue] ipAddress:(IPAddress.text)];
}
The rest should be somewhat correct, or at least not subject of this question.
I'm trying to save the name of a button using a singleton so that the name can be accessed in another view to play a video with the same name. However, I'm getting the error: SIGABRT. I don't really see what's wrong with my code. Any ideas?
#import "List.h"
#import "MyManager.h"
#import "Video.h"
#implementation ExerciseList
-(IBAction) goToVideo:(UIButton *) sender{
MyManager *sharedManager = [MyManager sharedManager];
sharedManager.vidName = [[sender titleLabel] text];
Video *videoGo = [[Video alloc] initWithNibName: #"Video" bundle: nil];
[self.navigationController pushViewController: videoGo animated: YES];
[videoGo release];
}
Here is my .h and .m for MyManager:
#import <foundation/Foundation.h>
#interface MyManager : NSObject {
NSMutableArray *workouts;
NSString *vidName;
}
#property (nonatomic, retain) NSMutableArray *workouts;
#property (nonatomic, retain) NSString *vidName;
+ (id)sharedManager;
#end
#import "MyManager.h"
static MyManager *sharedMyManager = nil;
#implementation MyManager
#synthesize workouts;
#synthesize vidName;
#pragma mark Singleton Methods
+ (id)sharedManager {
#synchronized(self) {
if (sharedMyManager == nil)
sharedMyManager = [[self alloc] init];
}
return sharedMyManager;
}
- (id)init {
if ((self = [super init])) {
workouts = [[NSMutableArray alloc] init];
vidName = [[NSString alloc] init];
}
return self;
}
-(void) dealloc{
self.workouts = nil;
self.vidName = nil;
[super dealloc];
}
#end
You should access the title of the button
sharedManger.vidName = [sender currentTitle];
However you are not using ARC so also check where your vidName property is retain or copy.
if it is not retain or copy then you can use this code also
if(sharedManger.vidname != nil){
[sharedManger.vidName release];
sharedManger.vidName = nil;
}
sharedManger.vidName = [[sender currentTitle] retain];
I am very new to obj-c (about 1 day) and i have read the documentation on how to call methods and how to modify strings and i have used similar code in another program and it worked fine. I'm programming a simple web browser for the iphone to teach myself about WebViewController library. When i compile this it gives me the warning "'WebViewController' may not respond to '-parseURl:" at line 17 in the .m file and when i run it i throws the error "NSInvalidArgumentException" in the console.
Code for this in WebViewController.h:
#import <UIKit/UIKit.h>
#interface WebViewController : UIViewController {
IBOutlet UIWebView *webView;
IBOutlet UITextField *textField;
}
NSString *urlAddress;
NSURL *url;
NSURLRequest *requestObj;
- (IBAction)gotoAddress:(id)sender;
- (NSString*) parseURL:(NSString*)str;
#property (nonatomic, retain) UIWebView *webView;
#end
Code for this in WebViewController.m:
#import "WebViewController.h"
#implementation WebViewController
#synthesize webView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Initialization code
}
return self;
}
- (IBAction)gotoAddress:(id)sender {
urlAddress = textField.text;
urlAddress = [self parseURl:urlAddress];
url = [NSURL URLWithString:urlAddress];
requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
NSLog(#"urlAddress= %s", [urlAddress cStringUsingEncoding:1]);
}
- (NSString*) parseURL:(NSString*)str {
NSLog(#"made it");
NSString *httpPart = #"http://";
if ([str rangeOfString:httpPart].location == NSNotFound) {
NSString *correctURL = [NSString stringWithFormat:#"%#%#", httpPart, str];
return correctURL;
}
else {
return str;
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[webView release];
[super dealloc];
}
#end
Thanks for the help
Objective-C (and most other languages) is case-sensitive. "URL" and "URl" are different.
urlAddress = [self parseURl:urlAddress];
should be
urlAddress = [self parseURL:urlAddress];