[userDefaults boolForKey:@"theKeyOfMyBOOL"]; returns a BOOL, so either YES or NO (not nil).
Internally, it is stored as an NSNumber. So, if you call
[userDefaults objectForKey:@"theKeyOfMyBOOL"];
you will be given an NSNumber, if you have ever stored anything, or nil, if you have not.
Category: iphone
Application Support You don’t have permission to save the file
Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “data” in the folder “gamedata”." UserInfo={NSFilePath=file:///var/mobile/Containers/Data/Application/651354D9-30FF-4156-9D31-5F90D92D13C7/Library/Application%20Support/gamedata/data, NSUnderlyingError=0x14010cbf0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
do {
try NSFileManager.defaultManager().createDirectoryAtPath(GameData.filePath, withIntermediateDirectories: true, attributes: nil)
} catch {
print(error)
}
NSKeyedArchiver.archiveRootObject(GameData.data!, toFile: GameData.filePath)
print(GameData.filePath)
createDirectoryAtPath will say You don’t have permission
OK, so use URL:
let fileManager = NSFileManager.defaultManager()
let appSupportPath:[NSURL] = fileManager.URLsForDirectory(.ApplicationSupportDirectory, inDomains: .UserDomainMask)
let store:NSURL = appSupportPath.first!
do {
try NSFileManager.defaultManager().createDirectoryAtURL(store, withIntermediateDirectories: true, attributes: nil)
} catch {
print(error)
}
NSKeyedArchiver.archiveRootObject(GameData.data!, toFile: GameData.filePath)
print(GameData.filePath)
SKView please presentScene(nil) or the scene will still here and eat the memory
me design LevelViewController (TableView) -> present -> GameViewController . SKView . Scene
When I dismiss the GameViewController, the scene “update” (onEnterFrame) still running, to prove that the scene has not been killed
And after several time present the GameViewController, the app will lag becoz too many SKScene is running.
So please (self.view as! SKView).presentScene(nil)
when GameViewController self.dismissViewControllerAnimated(true, completion: nil)
scrollview with a uiview in masonry
A tableview which scrollview and the tableview can scroll to right
self.tableView = [[UITableView alloc]init];
self.tableView.translatesAutoresizingMaskIntoConstraints = NO;
[self.tableView setDelegate:self];
[self.tableView setDataSource:self];
self.tableView.backgroundColor = [UIColor whiteColor];
[self.tableView setAllowsSelection:NO];
//build the scrollabe view
self.scrollView = [[UIScrollView alloc] init];
self.scrollView.translatesAutoresizingMaskIntoConstraints = NO;
// add subview tree
[self.scrollView addSubview:self.tableView];
[self.view addSubview:self.scrollView];
//build footer view
self.footerView = [[DetailsTableVTViewFooterView alloc] init];
self.footerView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:self.footerView];
[self.footerView.saveButton addTarget:self action:@selector(saveLocalChanges) forControlEvents:UIControlEventTouchUpInside];
// Using Masonry for autolayout
[self.footerView makeConstraints:^(MASConstraintMaker *make) {
make.height.equalTo(@footerHeight);
make.width.equalTo(frame.size.width);
make.right.equalTo(self.view.right);
}];
self.scrollView.backgroundColor = [UIColor redColor];
[self.scrollView makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view.right);
make.left.equalTo(self.view.left);
make.top.equalTo(self.view.top);
make.bottom.equalTo(self.footerView.top);
}];
[self.tableView makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(tableViewWidth);
make.bottom.equalTo(self.footerView.top);
make.left.equalTo(self.scrollView.left);
make.right.equalTo(self.scrollView.right);
make.top.equalTo(self.scrollView.top);
}];
if you face strange position of keyboard or some uiview component, you may try to debug using this first
[!] The `BP Mobile Inspection [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig’. This can lead to problems with the CocoaPods installation
iphone stuff blog, check it
[iphone, mac] blog of cocoa
[iphone] development platform, cocos2d 既 朋友
香港人之 blog
一個寫 mobile apps 既香港人既 blog
http://leoto.blogspot.com/