1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Simple iOS app with a single label
19 app_namespace
"nit.app.hello_ios"
20 app_version
(0, 5, git_revision
)
26 redef fun did_finish_launching_with_options
28 return app_delegate
.hello_world
32 redef class AppDelegate
34 # Print and show "Hello World!"
35 private fun hello_world
: Bool in "ObjC" `{
37 // Print to the console
38 NSLog(@"Hello World!");
40 // Display "Hello world!" on the screen
41 CGRect frame = [[UIScreen mainScreen] bounds];
42 self.window = [[UIWindow alloc] initWithFrame: frame];
43 self.window.backgroundColor = [UIColor whiteColor];
45 UILabel *label = [[UILabel alloc] init];
46 label.text = @"Hello World!";
47 label.center = CGPointMake(100, 100);
50 // As with `self.window
` we must set a `rootViewController
`
51 self.window.rootViewController = [[UIViewController alloc]initWithNibName:nil bundle:nil];
52 self.window.rootViewController.view = label;
54 [self.window addSubview: label];
55 [self.window makeKeyAndVisible];