EILPoint Class Reference

Inherits from NSObject
Conforms to NSCoding
NSCopying
Declared in EILPoint.h
EILPoint.m

Overview

Represents a geometrical point. Object is immutable.

Properties

  x

X coordinate of the point.

@property (nonatomic, assign, readonly) double x

Declared In

EILPoint.h

  y

Y coordinate of the point.

@property (nonatomic, assign, readonly) double y

Declared In

EILPoint.h

Creating and Initializing Points

– initWithX:y:

Returns a new point object.

- (instancetype)initWithX:(double)x y:(double)y

Parameters

x

Coordinate on X axis.

y

Coordinate on Y axis.

Return Value

A point initialized with (x, y).

Declared In

EILPoint.h

+ pointWithX:y:

Returns a new point object.

+ (instancetype)pointWithX:(double)x y:(double)y

Parameters

x

Coordinate on X axis.

y

Coordinate on Y axis.

Return Value

A point initialized with (x, y).

Declared In

EILPoint.h

+ pointWithPoint:

Returns a new point object based on the given point.

+ (instancetype)pointWithPoint:(EILPoint *)point

Parameters

point

A point.

Return Value

A point initialized with (point.x, point.y).

Declared In

EILPoint.h

Operations on point

– pointTranslatedBydX:dY:

Translates the point by a given vector (dX, dY) and returns a new point.

- (instancetype)pointTranslatedBydX:(double)dX dY:(double)dY

Parameters

dX

Value of translation on X axis.

dY

Value of translation on Y axis.

Return Value

A new point translated by (dX, dY).

Declared In

EILPoint.h

– distanceToPoint:

Computes distance between given point and this point.

- (double)distanceToPoint:(EILPoint *)point

Parameters

point

Given point to which distance will be computed.

Return Value

Distance between points.

Declared In

EILPoint.h

– length

Computes the length of the vector represented by the point i.e. distance from the point to the (0,0).

- (double)length

Return Value

Length of the vector

Declared In

EILPoint.h

Serialization

+ pointFromDictionary:

Deserializes a point from NSDictionary.

+ (nullable EILPoint *)pointFromDictionary:(NSDictionary *)dict

Parameters

dict

NSDictionary to deserialize from.

Return Value

A point created from NSDictionary.

Declared In

EILPoint.h

– toDictionary

Serializes the point to NSDictionary.

- (NSDictionary *)toDictionary

Return Value

A point representation in NSDictionary.

Declared In

EILPoint.h

Identifying and Comparing Objects

– isEqual:

Returns a boolean value that indicates whether given point is equal to this one.

- (BOOL)isEqual:(nullable id)other

Parameters

other

The object to be compared to this point. May be nil.

Return Value

YES if points are equal, otherwise NO.

Declared In

EILPoint.h

– isEqualToPoint:

- (BOOL)isEqualToPoint:(nullable EILPoint *)point

See Also

Declared In

EILPoint.h

– hash

Returns an integer that can be used as a table address in a hash table structure.

- (NSUInteger)hash

Declared In

EILPoint.h

Describing Objects

– description

Returns a string representation of the receiver.

- (NSString *)description

Return Value

A string representation of the point in form of (x,y)

Declared In

EILPoint.h

Encoding and Decoding

– initWithCoder:

Returns a point initialized from data in a given unarchiver.

- (nullable instancetype)initWithCoder:(NSCoder *)decoder

Parameters

decoder

An unarchiver object.

Return Value

A new point initialized using the data in decoder.

Declared In

EILPoint.h

– encodeWithCoder:

Encodes the point using a given archiver.

- (void)encodeWithCoder:(NSCoder *)coder

Parameters

An

archiver object.

Declared In

EILPoint.h