Skip to content

Commit

Permalink
fix minor crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Sep 29, 2017
1 parent 93f4ca0 commit a0178ca
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion HabitRPG/Habitica-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>246</string>
<string>248</string>
<key>CustomDomain</key>
<string>${CUSTOM_DOMAIN}</string>
<key>DisableSSL</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,13 @@ - (void)configureEmpty {

[bgView addSubview:closedShopInfoView];
[bgView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[closedView]-0-|" options:0 metrics:nil views:@{@"closedView": closedShopInfoView}]];
[bgView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:visualFormat
options:0
metrics:nil
views:views]];
if (visualFormat != nil) {
[bgView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:visualFormat
options:0
metrics:nil
views:views]];
}

closedShopInfoView.image = [UIImage imageNamed:imageName];
closedShopInfoView.shopItemTitleLabel.text = title;
closedShopInfoView.shopItemDescriptionLabel.text = notes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ class HRPGBuyItemModalViewController: UIViewController {
self.dismiss(animated: true, completion: nil)

let topViewController = self.presentingViewController
let storyboard = UIStoryboard(name: "BuyModal", bundle: nil)
if !canAfford() {
var viewControllerName: String? = nil
if currency == .hourglass {
Expand All @@ -330,10 +329,7 @@ class HRPGBuyItemModalViewController: UIViewController {
}

if let name = viewControllerName {
let viewController = storyboard.instantiateViewController(withIdentifier: name)
viewController.modalTransitionStyle = .crossDissolve
viewController.modalPresentationStyle = .currentContext
topViewController?.present(viewController, animated: true, completion: nil)
HRPGBuyItemModalViewController.displayViewController(name: name, parent: topViewController)
}

return
Expand All @@ -342,32 +338,40 @@ class HRPGBuyItemModalViewController: UIViewController {
if currency == .hourglass {
if purchaseType == "gear" || purchaseType == "mystery_set" {
HRPGManager.shared().purchaseMysterySet(setIdentifier, onSuccess: successBlock, onError: {
topViewController?.performSegue(withIdentifier: "insufficientHourglasses", sender: self)
HRPGBuyItemModalViewController.displayViewController(name: "InsufficientHourglassesViewController", parent: topViewController)
})
} else {
HRPGManager.shared().purchaseHourglassItem(key, withPurchaseType: purchaseType, withText: text, withImageName: imageName, onSuccess: successBlock, onError: {
topViewController?.performSegue(withIdentifier: "insufficientHourglasses", sender: self)
HRPGBuyItemModalViewController.displayViewController(name: "InsufficientHourglassesViewController", parent: topViewController)
})
}

} else if currency == .gem || purchaseType == "gems" {
HRPGManager.shared().purchaseItem(key, withPurchaseType: purchaseType, withText: text, withImageName: imageName, onSuccess: successBlock, onError: {
topViewController?.performSegue(withIdentifier: "insufficientGems", sender: self)
HRPGBuyItemModalViewController.displayViewController(name: "InsufficientGemsViewController", parent: topViewController)
})
} else {
if currency == .gold && purchaseType == "quests" {
HRPGManager.shared().purchaseQuest(key, withText: text, withImageName: imageName, onSuccess: successBlock, onError: {
topViewController?.performSegue(withIdentifier: "insufficientGold", sender: self)
HRPGBuyItemModalViewController.displayViewController(name: "InsufficientGoldViewController", parent: topViewController)
})
} else {
HRPGManager.shared().buyObject(key, withValue: value, withText: text, onSuccess: successBlock, onError: {
topViewController?.performSegue(withIdentifier: "insufficientGold", sender: self)
HRPGBuyItemModalViewController.displayViewController(name: "InsufficientGoldViewController", parent: topViewController)
})
}
}
}
}

private static func displayViewController(name: String, parent: UIViewController?) {
let storyboard = UIStoryboard(name: "BuyModal", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: name)
viewController.modalTransitionStyle = .crossDissolve
viewController.modalPresentationStyle = .currentContext
parent?.present(viewController, animated: true, completion: nil)
}

func closePressed() {
dismiss(animated: true, completion: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,11 @@ - (void)controller:(NSFetchedResultsController *)controller
break;

case NSFetchedResultsChangeDelete:
[self.areTagsSelected removeObjectAtIndex:indexPath.item];
[tableView deleteRowsAtIndexPaths:@[ indexPath ]
withRowAnimation:UITableViewRowAnimationFade];
if (self.areTagsSelected.count > indexPath.item) {
[self.areTagsSelected removeObjectAtIndex:indexPath.item];
[tableView deleteRowsAtIndexPaths:@[ indexPath ]
withRowAnimation:UITableViewRowAnimationFade];
}
break;

case NSFetchedResultsChangeUpdate:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger

- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
HRPGChatTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ChatMessageCell" forIndexPath:indexPath];
HRPGChatTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ChatMessageCell"];
cell.transform = self.tableView.transform;
[self configureCell:cell atIndexPath:indexPath withAnimation:NO];
return cell;
Expand Down
3 changes: 1 addition & 2 deletions HabitRPG/TableViewDataSources/HRPGCoreDataDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id<NSFetchedResultsSectionInfo> sectionInfo =
[self.fetchedResultsController sections][(NSUInteger)section];
id<NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsController sections][(NSUInteger)section];
return [sectionInfo numberOfObjects];
}

Expand Down
2 changes: 1 addition & 1 deletion Habitica Snapshots/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>246</string>
<string>248</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions Habitica.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3623,7 +3623,7 @@
CODE_SIGN_ENTITLEMENTS = Habitica.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 246;
CURRENT_PROJECT_VERSION = 248;
DEVELOPMENT_TEAM = 9Q9SMRMCNN;
ENABLE_BITCODE = NO;
EXCLUDED_SOURCE_FILE_NAMES = "";
Expand Down Expand Up @@ -3715,7 +3715,7 @@
CODE_SIGN_ENTITLEMENTS = Habitica.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 246;
CURRENT_PROJECT_VERSION = 248;
DEVELOPMENT_TEAM = 9Q9SMRMCNN;
ENABLE_BITCODE = NO;
EXCLUDED_SOURCE_FILE_NAMES = "FLEX*";
Expand Down
2 changes: 1 addition & 1 deletion HabiticaTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>246</string>
<string>248</string>
</dict>
</plist>

0 comments on commit a0178ca

Please sign in to comment.