Skip to content

Commit

Permalink
Document how to implement error based delegate methods in Swift (#2033)
Browse files Browse the repository at this point in the history
  • Loading branch information
zorgiepoo authored Dec 6, 2021
1 parent 3a64116 commit 0a19f6f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Sparkle/SPUUpdaterDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ SU_EXPORT extern NSString *const SUSystemProfilerPreferredLanguageKey;
Returns whether to allow Sparkle to check for updates.
For example, this may be used to prevent Sparkle from interrupting a setup assistant.
Alternatively, you may want to consider starting the updater after eg: the setup assistant finishes
Alternatively, you may want to consider starting the updater after eg: the setup assistant finishes.
Note in Swift, this method returns Void and is marked with the throws keyword. If this method
doesn't throw an error, the updater may perform an update check. Otherwise if an error is thrown (we recommend using an NSError),
then the updater may not perform an update check.
@param updater The updater instance.
@param updateCheck The type of update check that will be performed if the updater is allowed to check for updates.
@param error The (optionally) populated error object if the updater may not perform a new update check.
@param error The populated error object if the updater may not perform a new update check. The @c NSLocalizedDescriptionKey user info key should be populated indicating a description of the error.
@return @c YES if the updater is allowed to check for updates, otherwise @c NO
*/
- (BOOL)updater:(SPUUpdater *)updater mayPerformUpdateCheck:(SPUUpdateCheck)updateCheck error:(NSError * __autoreleasing *)error;
Expand Down Expand Up @@ -227,10 +231,13 @@ SU_EXPORT extern NSString *const SUSystemProfilerPreferredLanguageKey;
If you return @c NO and populate the @c error, the user is not shown this @c updateItem nor is the update downloaded or installed.
Note in Swift, this method returns Void and is marked with the throws keyword. If this method doesn't throw an error, the updater will proceed with the update.
Otherwise if an error is thrown (we recommend using an NSError), then the will not proceed with the update.
@param updater The updater instance.
@param updateItem The selected update item to proceed with.
@param updateCheck The type of update check that would be performed if proceeded.
@param error An error object that must be populated by the delegate if the updater should not proceed with the update.
@param error An error object that must be populated by the delegate if the updater should not proceed with the update. The @c NSLocalizedDescriptionKey user info key should be populated indicating a description of the error.
@return @c YES if the updater should proceed with @c updateItem, otherwise @c NO if the updater should not proceed with the update with an @c error populated.
*/
- (BOOL)updater:(SPUUpdater *)updater shouldProceedWithUpdate:(SUAppcastItem *)updateItem updateCheck:(SPUUpdateCheck)updateCheck error:(NSError * __autoreleasing *)error;
Expand Down

0 comments on commit 0a19f6f

Please sign in to comment.