-(void)prepareForSegue:(UIStoryboardSegue*)seguesender:(id)sender{if([[segueidentifier]isEqualToString:@"gotoViewB"]){idvc=segue.destinationViewController;[vcsetValue:@"hello world 大家好"forKey:@"dataString"];}}
ViewB
在 viewDidLoad 即可取到值。
ViewBController.h
@property(strong)NSString*dataString;
ViewBController.m
-(void)viewDidLoad{[superviewDidLoad];NSLog(@"output:%@",self.dataString);//output:hello world 大家好
}
[1]*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureMetadataOutput setMetadataObjectTypes:] - unsupported type found. Use -availableMetadataObjectTypes.'
File -> New -> Project -> Single View Application
Open storyboard -> Drag "Table View" to View Controller
Press crtl and drag line from "Table View" to ViewController.h
We just declared the arrDataSource by using "@property" in ViewController.h and no longer need to "@synthesize" in ViewController.m file. @synthesize arrDataSource = _arrDataSource;
The compiler will auto generate getter/setter, now we can use _arrDataSource.
// Code generated in background, doesn't actually appear in your application
-(NSMutableArray*)arrDataSource{return_arrDataSource;}-(void)setArrDataSource:(NSMutableArray*)arrDataSource{_arrDataSource=arrDataSource;}
comment: cmd + /
code indent: ctrl + i
shift right: cmd + ]
shift left: cmd + [
move word left(right): alt + left or alt + right
move to begin(end) of line: alt + up or alt + down
edit all in the scope: cmd + ctrl + e
go to declaration: cmd + double click
switch .h and .m: cmd + ctrl + up
open quickly: cmd + shift + o
show detail: option + click
goto line number: cmd + l
open preferences: cmd + ,
Show: Line numbers
show/hide debug area: cmd + shift + y
show/hide left utilities: cmd + option + 0
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
// This function called when receive notification and app is in the foreground.
for (id key in userInfo) {
trace(@"Key=[%@], Value=[%@]", key, [userInfo objectForKey:key]);
}
NSString *openType = [userInfo objectForKey:@"open"];
NSString *link = [userInfo objectForKey:@"link"];
[[HVPApiManager sharedManager] saveNotificationWithOpenType:openType withLink:link];
/* Output Badge number */
trace(@"Badge: %@", [[userInfo objectForKey:@"aps"] objectForKey:@"badge"]);
}