-
-
-

UsergridEntity

-
-
-
public class UsergridEntity: NSObject, NSCoding
- -
-
-

UsergridEntity is the base class that contains a single Usergrid entity.

- -

UsergridEntity maintains a set of accessor properties for standard Usergrid schema properties (e.g. name, uuid), and supports helper methods for accessing any custom properties that might exist.

- -
-
-
-
    -
  • -
    - - - - subscript(_:) - -
    -
    -
    -
    -
    -
    -

    Subscript for the UsergridEntity class.

    - -
      -
    • Example usage: - -let propertyValue = usergridEntity["propertyName"] -usergridEntity["propertyName"] = propertyValue -
    • -
    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public subscript(propertyName: String) -> AnyObject?
    - -
    -
    -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - asset - -
    -
    -
    -
    -
    -
    -

    The UsergridAsset that contains the asset data.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    internal(set) public var asset: UsergridAsset?
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - fileMetaData - -
    -
    -
    -
    -
    - -
    -

    Declaration

    -
    -

    Swift

    -
    internal(set) public var fileMetaData : UsergridFileMetaData?
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - type - -
    -
    -
    -
    -
    -
    -

    Property helper method for the UsergridEntity objects UsergridEntityProperties.EntityType.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var type: String { return self.getEntitySpecificProperty(.EntityType) as! String }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - uuid - -
    -
    -
    -
    -
    -
    -

    Property helper method for the UsergridEntity objects UsergridEntityProperties.UUID.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var uuid: String? { return self.getEntitySpecificProperty(.UUID) as? String }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - name - -
    -
    -
    -
    -
    -
    -

    Property helper method for the UsergridEntity objects UsergridEntityProperties.Name.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var name: String? { return self.getEntitySpecificProperty(.Name) as? String }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - created - -
    -
    -
    -
    -
    -
    -

    Property helper method for the UsergridEntity objects UsergridEntityProperties.Created.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var created: NSDate? { return self.getEntitySpecificProperty(.Created) as? NSDate }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - modified - -
    -
    -
    -
    -
    -
    -

    Property helper method for the UsergridEntity objects UsergridEntityProperties.Modified.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var modified: NSDate? { return self.getEntitySpecificProperty(.Modified) as? NSDate }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - location - -
    -
    -
    -
    -
    -
    -

    Property helper method for the UsergridEntity objects UsergridEntityProperties.Location.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var location: CLLocation?
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - uuidOrName - -
    -
    -
    -
    -
    -
    -

    Property helper method to get the UUID or name of the UsergridEntity.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var uuidOrName: String? { return self.uuid ?? self.name }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - isUser - -
    -
    -
    -
    -
    -
    -

    Tells you if this UsergridEntity has a type of user.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var isUser: Bool { return self is UsergridUser || self.type == UsergridUser.USER_ENTITY_TYPE }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - hasAsset - -
    -
    -
    -
    -
    -
    -

    Tells you if there is an asset associated with this entity.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var hasAsset: Bool { return self.asset != nil || self.fileMetaData?.contentLength > 0 }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - jsonObjectValue - -
    -
    -
    -
    -
    -
    -

    The JSON object value.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var jsonObjectValue : [String:AnyObject] { return self.properties }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - stringValue - -
    -
    -
    -
    -
    -
    -

    The string value.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public var stringValue : String { return NSString(data: try! NSJSONSerialization.dataWithJSONObject(self.jsonObjectValue, options: .PrettyPrinted), encoding: NSUTF8StringEncoding) as! String }
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - description - -
    -
    -
    -
    -
    -
    -

    The description.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public override var description : String
    - -
    -
    -
    -
    -
  • -
  • -
    - - - - debugDescription - -
    -
    -
    -
    -
    -
    -

    The debug description.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public override var debugDescription : String
    - -
    -
    -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Designated initializer for UsergridEntity objects

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    required public init(type:String, name:String? = nil, propertyDict:[String:AnyObject]? = nil)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - type - - -
    -

    The type associated with the UsergridEntity object.

    - -
    -
    - - name - - -
    -

    The optional name associated with the UsergridEntity object.

    - -
    -
    - - propertyDict - - -
    -

    The optional property dictionary that the UsergridEntity object will start out with.

    - -
    -
    -
    -
    -

    Return Value

    -

    A new UsergridEntity object.

    - -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Used for custom mapping subclasses to a given Usergrid type.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public static func mapCustomType(type:String,toSubclass:UsergridEntity.Type)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - type - - -
    -

    The type of the Usergrid object.

    - -
    -
    - - toSubclass - - -
    -

    The subclass UsergridEntity.Type to map it to.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - entity(jsonDict:) - -
    -
    -
    -
    -
    -
    -

    Class convenience constructor for creating UsergridEntity objects dynamically.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public class func entity(jsonDict jsonDict: [String:AnyObject]) -> UsergridEntity?
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - jsonDict - - -
    -

    A valid JSON dictionary which must contain at the very least a value for the type key.

    - -
    -
    -
    -
    -

    Return Value

    -

    A UsergridEntity object provided that the type key within the dictionay exists. Otherwise nil.

    - -
    -
    -
    -
  • -
  • -
    - - - - entities(jsonArray:) - -
    -
    -
    -
    -
    -
    -

    Class convenience constructor for creating multiple UsergridEntity objects dynamically.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public class func entities(jsonArray entitiesJSONArray: [[String:AnyObject]]) -> [UsergridEntity]
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - entitiesJSONArray - - -
    -

    An array which contains dictionaries that are used to create the UsergridEntity objects.

    - -
    -
    -
    -
    -

    Return Value

    -

    An array of UsergridEntity.

    - -
    -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - init(coder:) - -
    -
    -
    -
    -
    -
    -

    NSCoding protocol initializer.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    required public init?(coder aDecoder: NSCoder)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - aDecoder - - -
    -

    The decoder.

    - -
    -
    -
    -
    -

    Return Value

    -

    A decoded UsergridUser object.

    - -
    -
    -
    -
  • -
  • -
    - - - - encodeWithCoder(_:) - -
    -
    -
    -
    -
    -
    -

    NSCoding protocol encoder.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func encodeWithCoder(aCoder: NSCoder)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - aCoder - - -
    -

    The encoder.

    - -
    -
    -
    -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - putProperty(_:value:) - -
    -
    -
    -
    -
    -
    -

    Updates a properties value for the given property name.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func putProperty(name:String,value:AnyObject?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - name - - -
    -

    The name of the property.

    - -
    -
    - - value - - -
    -

    The value to update to.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - putProperties(_:) - -
    -
    -
    -
    -
    -
    -

    Updates a set of properties that are within the given properties dictionary.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func putProperties(properties:[String:AnyObject])
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - properties - - -
    -

    The property dictionary containing the properties names and values.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - removeProperty(_:) - -
    -
    -
    -
    -
    -
    -

    Removes the property for the given property name.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func removeProperty(name:String)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - name - - -
    -

    The name of the property.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - removeProperties(_:) - -
    -
    -
    -
    -
    -
    -

    Removes the properties with the names within the propertyNames array

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func removeProperties(propertyNames:[String])
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - propertyNames - - -
    -

    An array of property names.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - append(_:value:) - -
    -
    -
    -
    -
    -
    -

    Appends the given value to the end of the properties current value.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func append(name:String, value:AnyObject)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - name - - -
    -

    The name of the property.

    - -
    -
    - - value - - -
    -

    The value or an array of values to append.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Inserts the given value at the given index within the properties current value.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func insert(name:String, value:AnyObject, index:Int = 0)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - name - - -
    -

    The name of the property.

    - -
    -
    - - index - - -
    -

    The index to insert at.

    - -
    -
    - - value - - -
    -

    The value or an array of values to insert.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - pop(_:) - -
    -
    -
    -
    -
    -
    -

    Removes the last value of the properties current value.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func pop(name:String)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - name - - -
    -

    The name of the property.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - shift(_:) - -
    -
    -
    -
    -
    -
    -

    Removes the first value of the properties current value.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func shift(name:String)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - name - - -
    -

    The name of the property.

    - -
    -
    -
    -
    -
    -
  • -
-
-
- -
    -
  • -
    - - - - reload(_:) - -
    -
    -
    -
    -
    -
    -

    Performs a GET on the UsergridEntity using the shared instance of UsergridClient.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func reload(completion: UsergridResponseCompletion? = nil)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - completion - - -
    -

    An optional completion block that, if successful, will contain the reloaded UsergridEntity object.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - reload(_:completion:) - -
    -
    -
    -
    -
    -
    -

    Performs a GET on the UsergridEntity.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func reload(client:UsergridClient, completion: UsergridResponseCompletion? = nil)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - client - - -
    -

    The client to use when reloading.

    - -
    -
    - - completion - - -
    -

    An optional completion block that, if successful, will contain the reloaded UsergridEntity object.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - save(_:) - -
    -
    -
    -
    -
    -
    -

    Performs a PUT (or POST if no UUID is found) on the UsergridEntity using the shared instance of UsergridClient.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func save(completion: UsergridResponseCompletion? = nil)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - completion - - -
    -

    An optional completion block that, if successful, will contain the updated/saved UsergridEntity object.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - save(_:completion:) - -
    -
    -
    -
    -
    -
    -

    Performs a PUT (or POST if no UUID is found) on the UsergridEntity.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func save(client:UsergridClient, completion: UsergridResponseCompletion? = nil)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - client - - -
    -

    The client to use when saving.

    - -
    -
    - - completion - - -
    -

    An optional completion block that, if successful, will contain the updated/saved UsergridEntity object.

    - -
    -