Post

Replies

Boosts

Views

Activity

Reply to WARNING: Application performed a reentrant operation in its NSTableView delegate. This warning will become an assert in the future.
I don't get any errors. I'm using Xcode version 14.1 (14B47b) and I'm deploying to a physical iPhone 14 Pro Max and the same as a Simulator. What are your exact steps to reproduce it? Are you typing something in then seeing the error, or typing something in and backspacing to delete the text you entered and then you see an error?
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22
Reply to Crash Writing NSUserDefaults in CompletionBlock of dismissViewController
Isn't it likely that you're trying to access (set) a value in userSettings after it has been dealloc'd by the closure of the view? What you've done is said, "Please dismiss this view, and when you've finished dismissing it, set something in a variable you've just got rid of." I don't know what this code does: [IphemerisUtil requestAppRating] but if it's going to pop up a rating request view, where are you going to display it? You've just dismissed this view so there's nowhere to put an alert box. I'd suggest you try one of two routes: Option 1. Check whether you should ask for a rating before the view is dismissed, and do the dismissal from the [IphemerisUtil requestAppRating] method, i.e.: // In viewDidLoad(): [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closeView) name:@"CloseViewAfterRating" object:nil]; - (void)dismissChart {     if([IphemerisUtil okToRequestRatingUsingCount:OK_TO_REQUEST_REVIEW_COUNT]) {        [IphemerisUtil requestAppRating]; } else { [self closeView]; } } - (void)closeView { [self.navigationController dismissViewControllerAnimated:YES completion:nil]; } // In IphemerisUtil: - (void)requestAppRating { // Get rating // ... // When complete, post a notification to the previous view to close [[NSNotificationCenter defaultCenter] postNotificationName:@"CloseViewAfterRating" object:nil]; } Or, if the ratings method blocks the code until it's complete: - (void)dismissChart {     if([IphemerisUtil okToRequestRatingUsingCount:OK_TO_REQUEST_REVIEW_COUNT]) {        [IphemerisUtil requestAppRating]; } [self.navigationController dismissViewControllerAnimated:YES completion:nil]; } Option 2. Alternatively, if you are always going to check for a rating after various views are closed, you could do it in the viewDidAppear method of your main view.
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’22
Reply to Cannot find 'SWIFTFILE' in scope
You want to access code within PizzaDeliveryAttributes, but the dynamiIislandExtension target doesn't know about that code because you haven't told it about it. Swift is saying it can't find PizzaDeliveryAttributes, so select your PizzaDeliveryAttributes file in the project view on the left, and then look in the "Target Membership" section on the right. You want there to be a tick in the dynamicIslandExtension box.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22
Reply to Cannot Parse JSON data
In your Quote class you have var readDate: Date?, but you can't store a Date object in JSON, you have to use a String. Your quotes.json file does correctly store it as a String, so you need to rewrite your Quote class to handle a String rather than a Date.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to Crash Writing NSUserDefaults in CompletionBlock of dismissViewController
I did look at the code posted, and I pointed out that you're trying to access a variable that is in the process of being dealloc'd. All the other code in that method is creating variables, not trying to access existing variables. Your userSettings variable was created in that view, and you've told the navigation controller to remove the view. It will remove it and that variable will be unavailable. You need to handle it a better way. Perhaps a better way is to write directly to the user defaults, rather than via your userSettings variable?
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’22
Reply to Crash Writing NSUserDefaults in CompletionBlock of dismissViewController
You could see what the problem is by simply doing NSLog(@"userSettings = %@", userSettings); at the top of this method. Did you try that? +(BOOL)okToRequestRatingUsingCount:(int)count { NSLog(@"userSettings = %@", userSettings);    int curVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] intValue]; // Will work without error        NSNumber *lastVerRated = [userSettings objectForKey:RateLastVersionRated]; // Will work, but might return nil if userSettings has been dealloc'd, but no crash    int lastVersionRated = (lastVerRated != nil) ? [lastVerRated intValue] : 0; // If userSettings == nil you'll get 0 but no crash        NSNumber *ratePromptCnt = [userSettings objectForKey:RatePromptCounter]; // Will work, but might return nil if userSettings has been dealloc'd, but no crash    int rateCounter = (ratePromptCnt != nil) ? [ratePromptCnt intValue] : 1; // If userSettings == nil you'll get 1 but no crash        NSDate *dateLastCounterIncrement = [userSettings objectForKey:RatePromptCounterLastDateIncrement]; // Will work, but might return nil if userSettings has been dealloc'd, but no crash    if(!dateLastCounterIncrement) { // If userSettings has been dealloc'd, this will execute      dateLastCounterIncrement = [NSDate date];      [userSettings setObject:dateLastCounterIncrement forKey:RatePromptCounterLastDateIncrement]; // If userSettings is nil, this will crash    }        if(curVersion > lastVersionRated) {      if(rateCounter > count)        return YES;      else {        // Increment the counter only once a day        if([[NSDate date] timeIntervalSinceDate:dateLastCounterIncrement] > (3600 * 24)) {          rateCounter++;          [userSettings setObject:[NSNumber numberWithInt:rateCounter] forKey:RatePromptCounter]; // If userSettings is nil, this will crash        }      }   }   return NO; }
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’22
Reply to WARNING: Application performed a reentrant operation in its NSTableView delegate. This warning will become an assert in the future.
So you're running it as a Mac app? And your EXACT steps are then: Run the app. Press the "TABLE" link. Press the "Generate new data" button. This is when you see the error? Now that there are 1,000s of items you type what exactly? "User #1234" or "#1234" or "1234"? Clear the search criteria, how? Do you press the little X button in the text field, or do you select the text and press the delete key, or do you tap at the end of the text and press backspace until the text is gone? These are three completely different ways of clearing the text, and they call three different methods on the text field. It's extremely important to give the exact steps to reproduce an issue, or we can't really help because we can't reproduce it because we aren't doing the same thing as you. No matter what I do I do not get the error.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22
Reply to Crash Writing NSUserDefaults from applicationDidEnterBackground
You haven't mentioned where in the method it's crashing, but you should do some debugging with breakpoints and inspecting the variables, or some simple stuff with NSLog. Maybe the view controllers have already disappeared so you can't access them. Maybe _tabBarController has gone? Maybe userSettings has gone and you're trying to save into it? Maybe the savedOrder mutable array has the wrong size and you're trying to add an extra item? (I'd just init it and add objects to it rather than create it with a given size, and expect there to be a set number of items.) Also, this: NSArray *tabOrderToSave = _tabBarController.viewControllers; for(UIViewController *aViewController in tabOrderToSave) { could be: for(UIViewController *aViewController in _tabBarController.viewControllers) {
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’22
Reply to WARNING: Application performed a reentrant operation in its NSTableView delegate. This warning will become an assert in the future.
Okay, well I've tried with 100,000 rows and I still don't get the error (Mac Studio M1 Max, 10c/24c, 64GB RAM), but it takes ages to generate the new data. I cannot see any situation where you would want to have 100,000 (or even just 1,000) rows in a table view, so I think you should probably re-architect what you're trying to do here. Maybe use pagination so you only show 100 rows at a time, but let your search function on the full dataset?
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22
Reply to Tracking gestures
No. You aren't able to do that, and for a good reason - privacy. If I installed your app and found it was tracking everything I did I'd be exceptionally annoyed, and your reputation would be in the gutter.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22