?
Solved

Using XCode and Cocoa Touch - How do find info on debugging and implementing classes properly for iPhone?

Posted on 2010-08-23
8
Medium Priority
?
911 Views
Last Modified: 2013-12-12
I'm relatively new to development in XCode and Interface Builder for iPhone.  I've developed a little with C# in .NET for work.
I'm wanting to know a systematic approach to debugging and using classes properly in development.

For example, I'm writing an app, and I'm wanting to use a class I haven't implemented before, UIWebView.  I used the apple developer documentation in XCode to learn how to use it, but I've not been able to get a page running in the UIWebView yet.  The simulation runs without warnings or errors, but nothing loads in the UIWebView.

How I should go about solving this sort of problem?  What should I read, or what debugging steps should I take to get the UIWebView, or any class implemented properly?

I could post my code, but I more concerned about the proper steps to solving this type of issue rather than just to solve this example.
0
Comment
Question by:mattasks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33498779
You need to show the code. I attached an example that you may understand already.
Any question you have, you can simply ask here.

Here is a tutorial about UIWebView:
UIWebView Tutorial
http://www.iphonesdkarticles.com/2008/08/uiwebview-tutorial.html

It's simple and works fine. It will take you few minutes to read and implement this program.

There is a debugger in Xcode. It's not the same as in Visual Studio and it will take a while to understand it and start to use it. Command + backslash set a breakpoint. You can use NSLog and it will help you to develop. The log messages you will see in the console. Actually you need to arrange the IDE per your needs. For now, simply use the Xcode menu and Google search for everything.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
  
	CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0);
	UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];
	[webView setBackgroundColor:[UIColor whiteColor]];
	NSString *urlAddress = @"http://www.google.com";
	NSURL *url = [NSURL URLWithString:urlAddress];
	NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
	[webView loadRequest:requestObj];
	[window addSubview:webView]; 
	[webView release];	
    [window makeKeyAndVisible];
	
	return YES;
}

Open in new window

0
 

Author Comment

by:mattasks
ID: 33498850
I'm asking about the steps to solve this type of problem.  For example, if your code above compiled fine, returned no errors or warnings, but the UIWebView wouldn't load a page (just stayed as the plain whiteColor background), what steps would you take to debug it?  Where would you put brakepoints and what would you be looking for in an inspector?
Thanks
0
 

Author Comment

by:mattasks
ID: 33498863
I've done a few applications, and have mostly used tutorials and examples to help debug.  But I'm looking for a better practice to use when I can't find examples.  What are some systematic checks that I should do when this sort of problem occurs?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 33

Accepted Solution

by:
pgnatyuk earned 2000 total points
ID: 33498877
1. Use NSLog for each step.
2. Set a breakpoint new NSString *urlAddress = @"http://www.google.com"; and check the variables and function returns. In may cases you can check everything in Mac OS X application. The change is simple AppKit instead of UIKit.
0
 
LVL 33

Assisted Solution

by:pgnatyuk
pgnatyuk earned 2000 total points
ID: 33498885
For such mistakes you use NSLog and debugger.
Xcode contains instruments for more complicated cases: memory leak detection, profiling, etc.
0
 

Author Comment

by:mattasks
ID: 33499356
Ok, thanks for those suggestions.  I'm becoming more familiar with the debugger now.
I'm trying to use breakpoints and NSLog within viewDidLoad in the view controller, but I can't get the debugger to stop at the breakpoints.  NSLog doesn't seem to write to the console either.  (I've got NSLog working successfully in another method)

- (void)viewDidLoad:(id)sender {
      NSLog(@"inside viewDidLoad override");
      [super viewDidLoad];
}

Any ideas?
0
 

Author Closing Comment

by:mattasks
ID: 33499456
Thanks for the help.  This has helped me start using the debugger and Console.  I have more questions, but I'll start them in new questions so that I can award the points for this solution first.

Thanks,
Matt
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33500061
You are welcome
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let’s list some of the technologies that enable smooth teleworking. 
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question