iOS Note-nsset

Source: Internet
Author: User

  main.m//  nsset////  Created by passer-by on 15-3-23.//  Copyright (c) 2015 MAC. All rights reserved.//#import <foundation/foundation.h>int Main (int argc, const char * argv[]) {    @autor eleasepool    {       /*         Nsset vs. Nsarray    &NB Sp     1> Common          * are collections that can hold multiple OC objects          * can only hold OC objects, cannot save Put non-OC object type (basic data type: int, char, float, etc., struct, enum)          * itself immutable, there is a variable subclass                   2> different points          * Nsarray in order, Nsset no order    &NB Sp     */                Nsset *set1 = [Nsset setwithobjects:@ "a", @ "b  "@" C ", @" D ", nil];        Nsset *set2 = [[Nsset alloc] initwithobjects:@" 1 "@" 2 "@" 3 ", nil];        Nsarray *array = [Nsarray arraywithobjects:@ "a", @ "B", @ "C", nil];        Nsset *set3 = [Nsset setwitharray:array];& nbsp;               NSLog (@ "Set1:%@", Set1);        NSLog (@ "s  Et2:%@ ", Set2);        NSLog (@" Set3:%@ ", Set3);               //Get Set number         NSLog (@ "Set1 count:%d", Set1.count);          & nbsp    //Get all objects in the collection as an array         Nsarray *allobj = [Set2 allobjects];      &NBSP ; NSLog (@ "AllObj:%@", AllObj);               //Get any object       &N Bsp NSLog (@ "Anyobj:%@", [Set3 Anyobject]);               //contains an object   &NBS P     NSLog (@ "contains:%d", [Set3 containsobject:@ "Obj2"]);               &NBsp;       //whether to include objects in the specified set         NSLOG (@ "intersect obj:%d", [Set1 Intersectsset: SET3]);               //full match         NSLog (@ "IsEqual:% D ", [Set2 Isequaltoset:set3]);               //Whether it is a subset of the       &N Bsp NSLog (@ "Issubset:%d", [Set3 Issubsetofset:set1]);                & nbsp;               Nsset *set4 = [Nsset setwithobjects:@ "a", @ "B", nil];  &N Bsp     Nsarray *ary = [Nsarray arraywithobjects:@ "1", @ "2", @ "3", @ "4", nil];        Nsset *set 5 = [Set4 setbyaddingobjectsfromarray:ary];        NSLog (@ "Addfromarray:%@", Set5);   & nbsp                              &N Bsp     Nsmutableset *mutableset1 = [Nsmutableset setwithobjects:@ "1", @ "2", @ "3", nil];        Nsmutableset  *mutableset2 = [Nsmutableset setwithobjects:@ "a", @ "2", @ "B", nil];        Nsmutableset *mutableset3 = [Nsmutableset setwithobjects:@ "1", @ "C", @ "B", nil];               //Set element subtraction         [MutableSet1 minusset:mutableset2];        NSLog (@ "Minus:%@", Mutableset 1);               //leave only equal elements         [MutableSet1 intersec tset:mutableset3];        NSLog (@ "intersect:%@", MutableSet1);        & nbsp      //merge set         [MutableSet2 unionset:mutableset3];        Nslo G (@ "union:%@", MutableSet2);               //delete specified elements       &NB Sp [MutableSet2 Removeobject:@ "A"];        NSLog (@ "Removeobj:%@", MutableSet2);         & nbsp              //delete all data         [MutableSet2 removeallobjects];        NSLog (@ "RemoveAll:%@", MutableSet2);           }    R Eturn 0;}

iOS Note-nsset

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.