Faultless to avoid any warnings

Discussion in 'iOS Programming' started by mikezang, Jan 8, 2012.

  1. mikezang, Jan 8, 2012
    Last edited by a moderator: Jan 9, 2012

    mikezang macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #1
    I want to avoid any warnings when compiling my App, now I got some warnings from Open Source as below, there is a warning in initWithRootViewController, because it needs a class UIViewController as parameter, what can I do?

    Code:
    @interface InAppSettingsModalViewController : UIViewController {
    }
    @end
    
    @implementation InAppSettingsModalViewController
    
    - (id)init{
        InAppSettingsViewController *settings = [[InAppSettingsViewController alloc] init];
        self = [[UINavigationController alloc] initWithRootViewController:settings];
        [settings addDoneButton];
        [settings release];
        return self;
    }
    
    @end
     
  2. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
  3. mikezang, Jan 8, 2012
    Last edited by a moderator: Jan 9, 2012

    mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #3
    Code:
    #import "InAppSettings.h"
    #import "InAppSettingsSpecifier.h"
    #import "InAppSettingsConstants.h"
    #import "InAppSettingsPSMultiValueSpecifierTable.h"
     
  4. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
    Are you sure you want to init the InAppSettingsViewController in your InAppSettingsModalViewController.
    rather then reusing the parentViewController?
    also, why would you assign a navigationController to your self, what kind of context is this in?
    Are you talking bout your app delegate when it concerns the warning or what?
     
  5. mikezang, Jan 9, 2012
    Last edited by a moderator: Jan 9, 2012

    mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #5
    some other warnings are here:

    warning1:
    'NSObject' may not respond to 'connection:didReceiveResponse:'

    Code:
    #pragma mark NSURLConnection Delegate methods
    
    - (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)response{
    	assert(aConnection = connection);
    	NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
    	if ([response respondsToSelector: @selector(allHeaderFields)]){
    		self.contentType = [[(NSHTTPURLResponse*)response allHeaderFields] valueForKey: @"Content-Type"];
    		encoding = [NSString encodingForContentType: contentType];
    		if ([contentType rangeOfString: @"html" options: NSCaseInsensitiveSearch].location != NSNotFound)
    			parser.mode = ElementParserModeHTML;
    		else
    			parser.mode = ElementParserModeXML;
    	}
    	if ([connectionDelegate respondsToSelector:@selector(connection:didReceiveResponse:)])
    		[COLOR="Red"][connectionDelegate connection:connection didReceiveResponse: response];[/COLOR]
    	[pool release];
    }

    warning2:
    Declaration of 'struct sockaddr_in' will not be visible outside of this function

    Code:
    // Use to check the reachability of a particular IP address. 
    + (Reachability *) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
    This code is from a Open Source InAppSettings at https://bitbucket.org/keegan3d/inappsettings/src/0d2d8574de9f/InAppSettings/InAppSettings.m

    By the way, the code can be used and Modal View Controller can be shown.
     

Share This Page