iOS & macOS Charting Documentation - SciChart iOS & macOS Charts SDK v4.x

SCIObservableCollection

@interface SCIObservableCollection<__covariant T> : NSObject <NSFastEnumeration>

Defines a collection implementation which allows to get notification about adding, removing objects from it.

Note

T is the type of underlying objects.
  • Checks if this colection is empty or no.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isEmpty;

    Return Value

    YES if count is 0, otherwise - NO.

  • Gets the quantity of objects in collection.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSInteger count;
  • Gets the first object from this instance of SCIObservableCollection.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) T _Nonnull firstObject;
  • Creates a new SCIObservableCollection instance.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithCapacity:(NSInteger)capacity;

    Parameters

    capacity

    The initial capacity.

  • Creates a new SCIObservableCollection instance which contains the elements of the specified collection.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithCollection:(nonnull NSArray<T> *)collection;

    Parameters

    collection

    The collection with items to add.

  • Checks is the object is in the collection.

    Declaration

    Objective-C

    - (BOOL)contains:(nonnull T)object;

    Parameters

    object

    The object to check.

    Return Value

    YES if the object is in collection, otherwise - NO;

  • Add an object into this SCIObservableCollection instance.

    Declaration

    Objective-C

    - (void)add:(nonnull T)object;

    Parameters

    object

    The object to add.

  • Add an object into this SCIObservableCollection instance if it wasn’t added before, otherwise nothing happens

    Declaration

    Objective-C

    - (void)safeAdd:(nonnull T)object;

    Parameters

    object

    The object to add.

  • Add objects into SCIObservableCollection.

    Declaration

    Objective-C

    - (void)addAll:(nonnull T)objects, ...;

    Parameters

    objects

    The objects to add.

  • Insert object into SCIObservableCollection at Index.

    Declaration

    Objective-C

    - (void)insert:(nonnull T)object at:(NSInteger)index;

    Parameters

    object

    The object to insert.

    index

    The index to insert object at.

  • Returns the index of the first occurrence of the specified element in this collection.

    Declaration

    Objective-C

    - (NSInteger)indexOf:(nonnull T)object;

    Return Value

    Returns the index of the first occurrence, otherwise - 1.

  • Returns the object located at the specified index.

    Declaration

    Objective-C

    - (nonnull T)itemAt:(NSInteger)index;

    Parameters

    index

    An index within the bounds of the array.

    Return Value

    The object located at index.

  • Replaces the element at the specified position in this collection with the specified element.

    Declaration

    Objective-C

    - (void)setObject:(nonnull T)object at:(NSInteger)index;

    Parameters

    object

    object to be stored at the specified position

    index

    index of the element to replace

  • Removes object instance from this collection.

    Declaration

    Objective-C

    - (BOOL)remove:(nonnull T)object;

    Parameters

    object

    Object instance to be deleted from the collection, if present in it.

    Return Value

    YES If object is removed, otherwise - NO.

  • Removes objects instance from collection.

    Declaration

    Objective-C

    - (void)removeAt:(NSInteger)index;

    Parameters

    index

    Index of object, which will be deleted from collection.

  • Removes all objects from collection.

    Declaration

    Objective-C

    - (void)clear;
  • Add observer for the collection.

    Declaration

    Objective-C

    - (void)addObserver:
        (nonnull void (^)(SCIObservableCollection<T> *_Nonnull,
                          SCICollectionChangedEventArgs<T> *_Nonnull))observer;
  • Remove observer from the collection.

    Declaration

    Objective-C

    - (void)removeObserver:
        (nonnull void (^)(SCIObservableCollection<T> *_Nonnull,
                          SCICollectionChangedEventArgs<T> *_Nonnull))observer;
  • Remove all observers from the collection.

    Declaration

    Objective-C

    - (void)removeAllObservers;
  • Returns the object at the specified index.

    Declaration

    Objective-C

    - (nonnull T)objectAtIndexedSubscript:(NSInteger)idx;

    Parameters

    idx

    An index within the bounds of the array.

    Return Value

    The object located at index.

  • Replaces the object at the index with the new object, possibly adding the object.

    Warning

    Raises an NSInvalidArgumentException if the obj is nil.

    Warning

    Raises an NSRangeException if index is beyond the end of the array.

    Declaration

    Objective-C

    - (void)setObject:(nonnull T)obj atIndexedSubscript:(NSInteger)idx;

    Parameters

    obj

    The object with which to replace the object at index index in the array. This value must not be nil.

    idx

    The index of the object to be replaced. This value must not exceed the bounds of the array.

  • Checks whether the collection is nil or empty.

    Declaration

    Objective-C

    + (BOOL)isNilOrEmpty:(nonnull SCIObservableCollection *)collection;

    Return Value

    YES if the collection is nil or empty.

  • Checks whether the collection contains at least one object which satisfies specified predicate.

    Declaration

    Objective-C

    - (BOOL)any:(nonnull SCIPredicate)predicate;

    Parameters

    predicate

    The predicate to check.

    Return Value

    YES if list contains at least one object which satisfies specified predicate.

  • Checks whether all list objects satisfy specified predicate.

    Declaration

    Objective-C

    - (BOOL)all:(nonnull SCIPredicate)predicate;

    Parameters

    predicate

    The predicate to check.

    Return Value

    YES if all list objects satisfy specified predicate.

  • Selects all items which satisfy specified predicate.

    Declaration

    Objective-C

    - (nonnull instancetype)where:(nonnull SCIPredicate)predicate;

    Parameters

    predicate

    The predicate to check.

    Return Value

    The collection with selected items.

  • Selects all items which satisfy specified predicate.

    Declaration

    Objective-C

    - (void)where:(nonnull SCIPredicate)predicate
        withDestination:(nonnull SCIObservableCollection *)destination;

    Parameters

    predicate

    The predicate to check.

    destination

    The list where selected items should be saved

  • Gets count of items from the list which satisfy specified predicate.

    Declaration

    Objective-C

    - (NSInteger)count:(nonnull SCIPredicate)predicate;

    Parameters

    predicate

    The predicate to check.

    Return Value

    Count of items from the list which satisfy specified predicate.

  • Selects the first item from the list, if list is empty returns nil.

    Declaration

    Objective-C

    - (nullable T)firstOrDefault;

    Return Value

    The first item from the list, or nil if list is empty.

  • Selects the first item from the list which satisfies specified predicate, if list is empty or match not found returns nil.

    Declaration

    Objective-C

    - (nullable T)firstOrDefault:(nonnull SCIPredicate)predicate;

    Parameters

    predicate

    The predicate to check.

    Return Value

    The first item from the list which satisfies specified predicate,, or null if list is empty.

  • Selects the first item from the list, if list is empty throws exception.

    Declaration

    Objective-C

    - (nonnull T)first;

    Return Value

    The first item from the list.

  • Selects the first item from the list which satisfies specified predicate, if list is empty or match not found throws exception.

    Declaration

    Objective-C

    - (nonnull T)first:(nonnull SCIPredicate)predicate;

    Parameters

    predicate

    The predicate to check.

    Return Value

    The first item from the list which satisfies specified predicate.

  • Selects single item which satisfies specified predicate, If list is empty returns null and if there are more than one item which satisfies predicate then throws exception.

    Declaration

    Objective-C

    - (nullable T)singleOrDefault:(nonnull SCIPredicate)predicate;

    Parameters

    predicate

    The predicate to check.

    Return Value

    The single item.

  • Selects single item which satisfies specified predicate, if there are more than one item which satisfies predicate then throws exception.

    Declaration

    Objective-C

    - (nonnull T)single:(nonnull SCIPredicate)predicate;

    Parameters

    predicate

    The predicate to check.

    Return Value

    The single item.

  • Returns an NSArray containing all of the elements in this list in proper sequence (from first to last element).

    Declaration

    Objective-C

    - (nonnull NSArray<T> *)toArray;