English 中文(简体)
贵国申请代表在哪里设置,谁开始将其窗户和视主计长的特性?
原标题:Where is your Application Delegate set and who initializes its window and viewController properties?

我有一个非常新的问题,即我对我的看法。 如果我提出新的观点申请,即“测试”,Xcode就自动为测试格式制定同样的准则。

@class TestForStackOverflowViewController;

@interface TestForStackOverflowAppDelegate : NSObject <UIApplicationDelegate>

@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic, retain) IBOutlet TestForStackOverflowViewController *viewController;

@end

以及以下文件:

#import "TestForStackOverflowAppDelegate.h"

#import "TestForStackOverflowViewController.h"

@implementation TestForStackOverflowAppDelegate

@synthesize window = _window;
@synthesize viewController = _viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

[...]

我在此提出问题:

1) where is the TestForStackOverflowAppDelegate class set as delegate for the current application? Is it done "automagically"? I ve seen that the main.m source file contains only the following code:

int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
}

是否应该将申请代表级别定为UIApplicationMain 第四参数?

2)是测试产品总库的窗户和视窗户 正在确定应用等级?

3) 这可能是微不足道的,但为什么我们综合了窗口 = window,没有一个称为“窗口”的事例变数。 测试交换器 我看到,你可以宣布“繁荣”,而不必在班级接口中拥有相应的单价(可能是由汇编者自动创造的),而是是一种良好做法,还是应该总是在你的班级中创造相应的单价?

我用我这么长的信息说,我只希望我不要提出过一个非常明显的问题,因为意大利的今天晚,我很疲.。

最佳回答

www.un.org/Depts/DGACM/index_spanish.htm 如何装上指定代表的类别?

在你——Info.plist的档案中,有一个名为“Main nib档案基名”的关键人物,并有一个像Main Window.xib这样的观点。 在该轴心档案中,有一只档案所有者代理标,有一只代表组。

在设计商中开放第十一B。 通知文件所有者,点击,看代表的物体。 现在看上下文设计的物体(XCode 4),请看随附代表的物体。

Where is the window and viewController for the appDelegate set?

Look in the designer and context click on the app delegate object below the (XCode 4) line. The window and viewController target is tied there.

_window iVar

这自动提供给了你。 我不清楚它是否继承过来,还是由汇编者产生。

Here s more on _ iVars: Why rename synthesized properties in iOS with leading underscores?

If you chose to do the equivalent in code:

remove plist xib reference main.m: pass name of delegate

int main(int argc, char *argv[])
{
    int retVal = UIApplicationMain(argc, argv, nil, @"HelloViewAppDelegate");

代表:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    CGRect screenBounds = [[UIScreen mainScreen] applicationFrame];
    CGRect windowBounds = screenBounds;
    windowBounds.origin.y = 0.0;

    // init window
    [self setWindow: [[UIWindow alloc] initWithFrame:screenBounds]];

    // init view controller
    _mainViewController = [[MainViewController alloc] init];

    [[self window] addSubview:[_mainViewController view]];

    [self.window makeKeyAndVisible];
    return YES;
}
问题回答

(1) 简单易懂,请上<条码>。

  • you application .plist is found,
  • the key "Main nib file base name" is looked up,
  • this XIB is opened,
  • The object that supports the UIApplicationDelegate protocol is instantiated and used as the application delegate

(2) 这些规定载于第十一B,如果是的话,你可以认为是这样。

  • open the main XIB,
  • select the AppDelegate object,
  • open the Connections inspector for this object,
  • look into the Outlets section

3) 你是正确的,由汇编者自动创建。 这使得该法典更便于阅读,因为其行文不通,而更便于重新确定只把财产放在一处。

希望!





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签