VoucherMedia
@interface VoucherMedia : NSObject <NSCoding>
VoucherMedia is the model for all Media items inside of a Voucher.
It represents all of the different Media types:
Image - Any kind of photo (eg. png, jpg).
Animation - Any kind of animated photo (eg. gif).
Sound - Any kind of sound (eg. mp3).
Youtube - A youtube video.
Video - Any kind of video (eg. m4a).
Note - Any kind of text.
-
The type of
VoucherMedia.Declaration
Objective-C
@property (readonly, nonatomic) VoucherMediaType mediaType;Swift
var mediaType: VoucherMediaType { get } -
The id of the
VoucherMedia. This id is unique for allVoucherMedias and will be set by the Vouchr Server.Declaration
Objective-C
@property (assign, readwrite, nonatomic) long mediaId;Swift
var mediaId: Int { get set } -
The title of the
VoucherMedia.Declaration
Objective-C
@property (readonly, strong, nonatomic, nullable) NSString *title;Swift
var title: String? { get } -
The url to get the media item.
Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) NSString *mediaUrlString;Swift
var mediaUrlString: String? { get set } -
The url to show a thumbnail image.
Declaration
Objective-C
@property (readwrite, strong, nonatomic, nullable) NSString *thumbnailUrlString;Swift
var thumbnailUrlString: String? { get set } -
Initializer to create a
VoucherMediafrom an NSDictionary. The Initializer will try to be smart about returning the proper subclass ofVoucherMedia(eg.ImageMediawhen it is a photo).Declaration
Objective-C
- (nonnull instancetype)initWithDictionary:(nonnull NSDictionary *)dictionary;Swift
init(dictionary: [AnyHashable : Any])Parameters
dictionary- the dictionary representation of a
VoucherMedia.Return Value
Instance of
VoucherMedia. -
Initializer to create a
VoucherMediafrom properties. The Initializer will try to be smart about returning the proper subclass ofVoucherMedia(eg.ImageMediawhen it is a photo).Declaration
Objective-C
- (nonnull instancetype)initWithType:(VoucherMediaType)mediaType title:(nullable NSString *)title mediaUrlString:(nullable NSString *)mediaUrlString thumbnailUrlString:(nullable NSString *)thumbnailUrlString;Swift
init(type mediaType: VoucherMediaType, title: String?, mediaUrlString: String?, thumbnailUrlString: String?)Parameters
mediaType- the type of
VoucherMedia.title- the title of the
VoucherMedia.mediaUrlString- the url to the
VoucherMediaitem.thumbnailUrlString- the thumbnail of the
VoucherMediaitem.Return Value
Instance of
VoucherMedia. -
Creates an array of
VoucherMedias from an Array of NSDictionary versions ofVoucherMedias. Internally callsinitWithDictionary:for eachVoucherMedia.Declaration
Objective-C
+ (nonnull NSArray<VoucherMedia *> *)voucherMediasFromArray: (nonnull NSArray *)mediasJson;Swift
class func voucherMedias(from mediasJson: [Any]) -> [VoucherMedia]Parameters
mediasJson- Array of NSDictionary
VoucherMedias.Return Value
Array of
VoucherMediaobjects. -
Static Initializer to create a
VoucherMediafrom an NSDictionary. The Initializer will try to be smart about returning the proper subclass ofVoucherMedia(eg.ImageMediawhen it is a photo).Declaration
Objective-C
+ (nonnull instancetype)voucherMediaWithDictionary: (nonnull NSDictionary *)dictionary;Parameters
dictionary- the dictionary representation of a
VoucherMedia.Return Value
Instance of
VoucherMedia. -
Static Initializer to create a
VoucherMediafrom properties. The Initializer will try to be smart about returning the proper subclass ofVoucherMedia(eg.ImageMediawhen it is a photo).Declaration
Objective-C
+ (nonnull instancetype)voucherMediaWithType:(VoucherMediaType)mediaType title:(nullable NSString *)title mediaUrlString:(nullable NSString *)mediaUrlString thumbnailUrlString: (nullable NSString *)thumbnailUrlString;Parameters
mediaType- the type of
VoucherMedia.title- the title of the
VoucherMedia.mediaUrlString- the url to the
VoucherMediaitem.thumbnailUrlString- the thumbnail of the
VoucherMediaitem.Return Value
Instance of
VoucherMedia. -
Converts a
VoucherMediato an NSDictionary that can be used for sending to the server.Declaration
Objective-C
- (nonnull NSDictionary *)dictionaryRepresentationWithoutMediaData;Swift
func dictionaryRepresentationWithoutMediaData() -> [AnyHashable : Any]Return Value
dictionary - Dictionary form of a
VoucherMediawithout the media data. -
Converts a
VoucherMediato an NSDictionary that can be used for caching.Declaration
Objective-C
- (nonnull NSDictionary *)dictionaryRepresentation;Swift
func dictionaryRepresentation() -> [AnyHashable : Any]Return Value
dictionary - Dictionary form of a
VoucherMedia. -
Helper to convert a
VoucherMediaTypeto a string valueDeclaration
Objective-C
+ (nonnull NSString *)mediaStringFromMediaType:(VoucherMediaType)mediaType;Swift
class func mediaString(from mediaType: VoucherMediaType) -> StringParameters
mediaType- the mediaType that is being converted
Return Value
string form of a mediaType.
-
Updates all properties of this instance of
VoucherMediawith the properties of media.Declaration
Objective-C
- (void)updateWithMedia:(nonnull VoucherMedia *)media;Swift
func update(with media: VoucherMedia)Parameters
media- the properties that should be set on this
VoucherMedia. -
Updates the type of this instance of
VoucherMediawith specifiedVoucherMediaType.Declaration
Objective-C
- (void)updateMediaType:(VoucherMediaType)type;Swift
func updateMediaType(_ type: VoucherMediaType)Parameters
type- the type that should be set on this
VoucherMedia. -
Indicates whether the
VoucherMediahas been uploaded to theVoucherserver.Declaration
Objective-C
- (BOOL)hasBeenUploadedToServer;Swift
func hasBeenUploadedToServer() -> Bool
View on GitHub
VoucherMedia Class Reference