Skip to content

Commit

Permalink
fix: property memory annotations (#146)
Browse files Browse the repository at this point in the history
This commit does 2 things.

First, it fixes a reported crash due to the MPAliasResponse NSString *errorResponse being marked as assign intead of copy (or strong), as well as fixing another potential instance of this that I found in MParticleOptions NSString *defaultAgent being marked as unsafe_unretained instead of copy (or strong). I changed both instances of this to copy.

Second, it removes all uses of the assign and unsafe_unretained memory annotations on value types, as that is the only valid option (strong and weak cannot be used for value types) and is the default anyway. Looking at Apple’s UIView.h for example, they omit them as well.
  • Loading branch information
einsteinx2 committed May 16, 2022
1 parent fc3dce4 commit bb8c7fe
Show file tree
Hide file tree
Showing 44 changed files with 155 additions and 155 deletions.
6 changes: 3 additions & 3 deletions mParticle-Apple-SDK/Consent/MPConsentKitFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ NS_ASSUME_NONNULL_BEGIN

@interface MPConsentKitFilterItem : NSObject

@property (nonatomic, assign) BOOL consented;
@property (nonatomic, assign) int javascriptHash;
@property (nonatomic) BOOL consented;
@property (nonatomic) int javascriptHash;

@end

@interface MPConsentKitFilter : NSObject

@property (nonatomic, assign) BOOL shouldIncludeOnMatch;
@property (nonatomic) BOOL shouldIncludeOnMatch;
@property (nonatomic, strong) NSArray<MPConsentKitFilterItem *> *filterItems;

@end
Expand Down
4 changes: 2 additions & 2 deletions mParticle-Apple-SDK/Data Model/MPBreadcrumb.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

@property (nonatomic, strong, nonnull) NSString *sessionUUID;
@property (nonatomic, strong, nonnull) NSData *breadcrumbData;
@property (nonatomic, unsafe_unretained) NSTimeInterval timestamp;
@property (nonatomic, unsafe_unretained) int64_t breadcrumbId;
@property (nonatomic) NSTimeInterval timestamp;
@property (nonatomic) int64_t breadcrumbId;

- (nonnull instancetype)initWithSessionUUID:(nonnull NSString *)sessionUUID
breadcrumbId:(int64_t)breadcrumbId
Expand Down
6 changes: 3 additions & 3 deletions mParticle-Apple-SDK/Data Model/MPConsumerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ extern NSString * _Nonnull const kMPCKExpiration;

@interface MPCookie : NSObject <NSSecureCoding>

@property (nonatomic, unsafe_unretained) int64_t cookieId;
@property (nonatomic) int64_t cookieId;
@property (nonatomic, strong, nullable) NSString *content;
@property (nonatomic, strong, nullable) NSString *domain;
@property (nonatomic, strong, nullable) NSString *expiration;
@property (nonatomic, strong, nonnull) NSString *name;
@property (nonatomic, unsafe_unretained, readonly) BOOL expired;
@property (nonatomic, readonly) BOOL expired;

- (nonnull instancetype)initWithName:(nonnull NSString *)name configuration:(nonnull NSDictionary *)configuration;
- (nullable NSDictionary *)dictionaryRepresentation;
Expand All @@ -24,7 +24,7 @@ extern NSString * _Nonnull const kMPCKExpiration;
#pragma mark - MPConsumerInfo
@interface MPConsumerInfo : NSObject <NSSecureCoding>

@property (nonatomic, unsafe_unretained) int64_t consumerInfoId;
@property (nonatomic) int64_t consumerInfoId;
@property (nonatomic, strong, nullable) NSArray<MPCookie *> *cookies;
@property (nonatomic, strong, nullable) NSString *uniqueIdentifier;
@property (nonatomic, strong, nullable, readonly) NSString *deviceApplicationStamp;
Expand Down
6 changes: 3 additions & 3 deletions mParticle-Apple-SDK/Data Model/MPMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

@property (nonatomic, strong, readonly, nonnull) NSString *messageType;
@property (nonatomic, strong, readonly, nonnull) NSData *messageData;
@property (nonatomic, unsafe_unretained) NSTimeInterval timestamp;
@property (nonatomic, unsafe_unretained) int64_t messageId;
@property (nonatomic) NSTimeInterval timestamp;
@property (nonatomic) int64_t messageId;
@property (nonatomic, strong, nullable) NSNumber *sessionId;
@property (nonatomic, strong, nonnull) NSNumber *userId;
@property (nonatomic, strong, nullable) NSString *dataPlanId;
@property (nonatomic, strong, nullable) NSNumber *dataPlanVersion;
@property (nonatomic, unsafe_unretained) MPUploadStatus uploadStatus;
@property (nonatomic) MPUploadStatus uploadStatus;
@property (nonatomic) BOOL shouldUploadEvent;

- (nonnull instancetype)initWithSessionId:(nullable NSNumber *)sessionId
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Data Model/MPSegment.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern NSString *const kMPSegmentListKey;
@property (nonatomic, strong, readonly) NSDate *expiration;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSArray<MPSegmentMembership *> *memberships;
@property (nonatomic, unsafe_unretained, readonly) BOOL expired;
@property (nonatomic, readonly) BOOL expired;

- (instancetype)initWithSegmentId:(NSNumber *)segmentId UUID:(NSString *)uuid name:(NSString *)name memberships:(NSArray<MPSegmentMembership *> *)memberships endpointIds:(NSArray *)endpointIds;
- (instancetype)initWithDictionary:(NSDictionary *)segmentDictionary;
Expand Down
8 changes: 4 additions & 4 deletions mParticle-Apple-SDK/Data Model/MPSegmentMembership.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ typedef NS_ENUM(NSUInteger, MPSegmentMembershipAction) {

@interface MPSegmentMembership : NSObject <NSCopying>

@property (nonatomic, unsafe_unretained) int64_t segmentId;
@property (nonatomic, unsafe_unretained) int64_t segmentMembershipId;
@property (nonatomic, unsafe_unretained) NSTimeInterval timestamp;
@property (nonatomic, unsafe_unretained) MPSegmentMembershipAction action;
@property (nonatomic) int64_t segmentId;
@property (nonatomic) int64_t segmentMembershipId;
@property (nonatomic) NSTimeInterval timestamp;
@property (nonatomic) MPSegmentMembershipAction action;

- (instancetype)initWithSegmentId:(int64_t)segmentId membershipDictionary:(NSDictionary *)membershipDictionary;
- (instancetype)initWithSegmentId:(int64_t)segmentId segmentMembershipId:(int64_t)segmentMembershipId timestamp:(NSTimeInterval)timestamp membershipAction:(MPSegmentMembershipAction)action __attribute__((objc_designated_initializer));
Expand Down
20 changes: 10 additions & 10 deletions mParticle-Apple-SDK/Data Model/MPSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
@interface MPSession : MPDataModelAbstract <NSCopying>

@property (nonatomic, strong, nonnull) NSMutableDictionary *attributesDictionary;
@property (nonatomic, unsafe_unretained) NSTimeInterval backgroundTime;
@property (nonatomic, unsafe_unretained, readonly) NSTimeInterval foregroundTime;
@property (nonatomic, unsafe_unretained) NSTimeInterval startTime;
@property (nonatomic, unsafe_unretained) NSTimeInterval endTime;
@property (nonatomic, unsafe_unretained) NSTimeInterval length;
@property (nonatomic, unsafe_unretained, readonly) NSTimeInterval suspendTime;
@property (nonatomic, unsafe_unretained, readonly) uint eventCounter;
@property (nonatomic, unsafe_unretained, readonly) uint numberOfInterruptions;
@property (nonatomic, unsafe_unretained) int64_t sessionId;
@property (nonatomic, unsafe_unretained, readonly) BOOL persisted;
@property (nonatomic) NSTimeInterval backgroundTime;
@property (nonatomic, readonly) NSTimeInterval foregroundTime;
@property (nonatomic) NSTimeInterval startTime;
@property (nonatomic) NSTimeInterval endTime;
@property (nonatomic) NSTimeInterval length;
@property (nonatomic, readonly) NSTimeInterval suspendTime;
@property (nonatomic, readonly) uint eventCounter;
@property (nonatomic, readonly) uint numberOfInterruptions;
@property (nonatomic) int64_t sessionId;
@property (nonatomic, readonly) BOOL persisted;
@property (nonatomic, strong, readwrite, nonnull) NSNumber *userId;
@property (nonatomic, strong, readwrite, nonnull) NSString *sessionUserIds;
@property (nonatomic, strong, readwrite, nullable) NSDictionary<NSString *, id> *appInfo;
Expand Down
6 changes: 3 additions & 3 deletions mParticle-Apple-SDK/Data Model/MPUpload.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
@interface MPUpload : MPDataModelAbstract <NSCopying, MPDataModelProtocol>

@property (nonatomic, strong, nonnull) NSData *uploadData;
@property (nonatomic, unsafe_unretained) NSTimeInterval timestamp;
@property (nonatomic) NSTimeInterval timestamp;
@property (nonatomic, strong, nullable) NSNumber *sessionId;
@property (nonatomic, unsafe_unretained) int64_t uploadId;
@property (nonatomic, assign) MPUploadType uploadType;
@property (nonatomic) int64_t uploadId;
@property (nonatomic) MPUploadType uploadType;
@property (nonatomic, strong, nullable) NSString *dataPlanId;
@property (nonatomic, strong, nullable) NSNumber *dataPlanVersion;
@property BOOL containsOptOutMessage;
Expand Down
8 changes: 4 additions & 4 deletions mParticle-Apple-SDK/Data Model/MParticleUserNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ extern NSString * _Nonnull const kMPUserNotificationCategoryKey;
@property (nonatomic, strong, readonly, nullable) NSString *redactedUserNotificationString;
@property (nonatomic, strong, readonly, nonnull) NSDate *receiptTime;
@property (nonatomic, strong, readonly, nonnull) NSString *state;
@property (nonatomic, unsafe_unretained, readwrite) int64_t userNotificationId;
@property (nonatomic, unsafe_unretained, readwrite) MPUserNotificationBehavior behavior;
@property (nonatomic, unsafe_unretained, readonly) MPUserNotificationMode mode;
@property (nonatomic, unsafe_unretained, readwrite) BOOL shouldPersist;
@property (nonatomic, readwrite) int64_t userNotificationId;
@property (nonatomic, readwrite) MPUserNotificationBehavior behavior;
@property (nonatomic, readonly) MPUserNotificationMode mode;
@property (nonatomic, readwrite) BOOL shouldPersist;

- (nonnull instancetype)initWithDictionary:(nonnull NSDictionary *)notificationDictionary state:(nonnull NSString *)state behavior:(MPUserNotificationBehavior)behavior mode:(MPUserNotificationMode)mode;

Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Identity/MPAliasRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ @interface MPAliasRequest ()
@property (nonatomic, strong, readwrite) NSNumber *destinationMPID;
@property (nonatomic, strong, readwrite) NSDate *startTime;
@property (nonatomic, strong, readwrite) NSDate *endTime;
@property (nonatomic, assign, readwrite) BOOL usedFirstLastSeen;
@property (nonatomic, readwrite) BOOL usedFirstLastSeen;

@end

Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Include/MPAliasRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
Whether the start/end times were automatically inferred from the source user's firstSeen and lastSeen properties
*/
@property (nonatomic, assign, readonly) BOOL usedFirstLastSeen;
@property (nonatomic, readonly) BOOL usedFirstLastSeen;

@end

Expand Down
8 changes: 4 additions & 4 deletions mParticle-Apple-SDK/Include/MPAliasResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ NS_ASSUME_NONNULL_BEGIN
/**
The HTTP response code returned by the server.
*/
@property (nonatomic, assign) NSInteger responseCode;
@property (nonatomic) NSInteger responseCode;

/**
A human-readable error message returned by the server.
*/
@property (nonatomic, assign) NSString *errorResponse;
@property (nonatomic, copy) NSString *errorResponse;

/**
The corresponding alias request for this response.
Expand All @@ -35,12 +35,12 @@ NS_ASSUME_NONNULL_BEGIN
/**
Whether the SDK will automatically try to re-send the alias request.
*/
@property (nonatomic, assign) BOOL willRetry;
@property (nonatomic) BOOL willRetry;

/**
Whether the alias request was successfully accepted by the server.
*/
@property (nonatomic, assign) BOOL isSuccessful;
@property (nonatomic) BOOL isSuccessful;

@end

Expand Down
4 changes: 2 additions & 2 deletions mParticle-Apple-SDK/Include/MPBaseEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ NS_ASSUME_NONNULL_BEGIN
assigned to this property.
@see MPEventType
*/
@property (nonatomic, unsafe_unretained) MPEventType type;
@property (nonatomic) MPEventType type;

/**
An enum value that indicates the type of message to be sent
assigned to this property.
@see MPMessageType
*/
@property (nonatomic, unsafe_unretained) MPMessageType messageType;
@property (nonatomic) MPMessageType messageType;

/**
A dictionary containing further information about the event. The number of entries is
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Include/MPCCPAConsent.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
* Whether the user consented to data collection
This should be set to false if the user has opted out of data sharing under the CCPA.
*/
@property (nonatomic, assign) BOOL consented;
@property (nonatomic) BOOL consented;
/**
* The data collection document to which the user consented or did not consent
*/
Expand Down
6 changes: 3 additions & 3 deletions mParticle-Apple-SDK/Include/MPCommerceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ typedef NS_ENUM(NSUInteger, MPCommerceEventAction) {
/**
A value from the <b>MPCommerceEventAction</b> enum describing the commerce event action.
*/
@property (nonatomic, unsafe_unretained) MPCommerceEventAction action;
@property (nonatomic) MPCommerceEventAction action;

/**
The step number, within the chain of commerce event transactions, corresponding to the checkout.
*/
@property (nonatomic, unsafe_unretained) NSInteger checkoutStep;
@property (nonatomic) NSInteger checkoutStep;

/**
Flag indicating whether a refund is non-interactive. The default value is false/NO.
*/
@property (nonatomic, unsafe_unretained) BOOL nonInteractive;
@property (nonatomic) BOOL nonInteractive;

/**
Initializes an instance of MPCommerceEvent with an action and a product.
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Include/MPCommerceEventInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typedef NS_ENUM(NSUInteger, MPCommerceInstruction) {

@property (nonatomic, strong, readonly) MPEvent *event;
@property (nonatomic, strong, readonly) MPProduct *product;
@property (nonatomic, unsafe_unretained, readonly) MPCommerceInstruction instruction;
@property (nonatomic, readonly) MPCommerceInstruction instruction;

- (instancetype)initWithInstruction:(MPCommerceInstruction)instruction event:(MPEvent *)event;
- (instancetype)initWithInstruction:(MPCommerceInstruction)instruction event:(MPEvent *)event product:(MPProduct *)product __attribute__((objc_designated_initializer));
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Include/MPForwardRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@interface MPForwardRecord : NSObject

@property (nonatomic, unsafe_unretained) uint64_t forwardRecordId;
@property (nonatomic) uint64_t forwardRecordId;
@property (nonatomic, strong, nonnull) NSMutableDictionary *dataDictionary;
@property (nonatomic, strong, nonnull) NSNumber *mpid;
@property (nonatomic, strong, nonnull) NSNumber *timestamp;
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Include/MPGDPRConsent.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Whether the user consented to data collection
*/
@property (nonatomic, assign) BOOL consented;
@property (nonatomic) BOOL consented;
/**
* The data collection document to which the user consented or did not consent
*/
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Include/MPIdentityApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ typedef void (^MPModifyApiResultCallback)(MPModifyApiResult *_Nullable apiResult
/**
A custom error code enumeration providing a detailed reason why the request failed.
*/
@property (nonatomic, assign) MPIdentityErrorResponseCode code;
@property (nonatomic) MPIdentityErrorResponseCode code;

/**
A human readable description of the error.
Expand Down
6 changes: 3 additions & 3 deletions mParticle-Apple-SDK/Include/MPKitExecStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ typedef NS_ENUM(NSUInteger, MPKitReturnCode) {
@interface MPKitExecStatus : NSObject

@property (nonatomic, strong, readonly, nonnull) NSNumber *integrationId;
@property (nonatomic, unsafe_unretained) MPKitReturnCode returnCode;
@property (nonatomic, unsafe_unretained, readonly) NSUInteger forwardCount;
@property (nonatomic, unsafe_unretained, readonly) BOOL success;
@property (nonatomic) MPKitReturnCode returnCode;
@property (nonatomic, readonly) NSUInteger forwardCount;
@property (nonatomic, readonly) BOOL success;

- (nonnull instancetype)initWithSDKCode:(nonnull NSNumber *)integrationId returnCode:(MPKitReturnCode)returnCode;
- (nonnull instancetype)initWithSDKCode:(nonnull NSNumber *)integrationId returnCode:(MPKitReturnCode)returnCode forwardCount:(NSUInteger)forwardCount;
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Include/MPKitProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@protocol MPKitProtocol <NSObject>
#pragma mark - Required methods
@property (nonatomic, unsafe_unretained, readonly) BOOL started;
@property (nonatomic, readonly) BOOL started;

- (nonnull MPKitExecStatus *)didFinishLaunchingWithConfiguration:(nonnull NSDictionary *)configuration;

Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Include/MPProduct.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
/**
The prosition of the product on the screen or impression list
*/
@property (nonatomic, unsafe_unretained) NSUInteger position;
@property (nonatomic) NSUInteger position;

/**
The quantity of the product. Default value is 1
Expand Down
2 changes: 1 addition & 1 deletion mParticle-Apple-SDK/Include/MPPromotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ typedef NS_ENUM(NSUInteger, MPPromotionAction) {
/**
A value from the <b>MPPromotionAction</b> enum describing the promotion action.
*/
@property (nonatomic, unsafe_unretained, readonly) MPPromotionAction action;
@property (nonatomic, readonly) MPPromotionAction action;

/**
Initializes an instance of MPPromotionContainer with an action and a promotion.
Expand Down
Loading

0 comments on commit bb8c7fe

Please sign in to comment.