zoukankan      html  css  js  c++  java
  • objective-c 快速学习1-字符串处理和集合

    参考快速学习指南

    为了快速掌握oc的基本语法,按照上面文章速度学习oc .大概用了4~5天时间。粗越了解下oc.只是粗越了解。

    目的主要还是实践 这个 “学习理论”。并完善这个学习理论。

    鬼知道以后还要学习多少语言呢?

    1.数字处理:四则运算。

    2.字符串处理:分割和组合。

    3.集合处理:可变和不可变集合。 dictionary(oc没写例子)

    4.对象和继承:人,雇员,老板, 放入集合并多态的表示他们的薪水和税收。

    5.意图和实现的分离(事件):单个函数指针的实现(c风格和block)。一组函数指针的实现(protocal)

    6.io的处理。没写

    7.内存管理

    //
    //  main.m
    //  practice
    //
    //  Created by liangshun on 18/5/30.
    //  Copyright © 2018年 liangshun. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    NSString*  ComposeString(NSArray<NSString*> *array,char sign)
    {
        NSString * ret=[NSString new];
        NSString * signStr=[[NSString alloc] initWithFormat:@"%c",sign];
        for(int i=0;i<[array count];i++)
        {
            NSString *tempStr2=[(NSString *)array[i] stringByReplacingOccurrencesOfString:signStr withString:@" "];
            if(i==[array count]-1)
            {
                
                tempStr2=[NSString stringWithFormat:@"%@",tempStr2];
            }
            else
            {
                tempStr2=[NSString stringWithFormat:@"%@%c",tempStr2,sign];
            }
            ret=[ret stringByAppendingString:tempStr2];
        }
        return  ret;
    }
    
    
    
    int main(int argc, const char * argv[]) {
        NSMutableArray *array=[NSMutableArray new];
        [array addObject:@"c"++"];
        [array addObject:@"c,"];
        [array addObject:@"c#"];
        char sign=',';
    
        NSString *tempret=ComposeString(array, sign);
        NSLog(@"{%@}",tempret);
        
        
        NSArray<NSString*> *tempArray=[tempret componentsSeparatedByString:@","];
        
        for(int i=0;i<[tempArray count];i++)
        {
            NSLog(@"%@",tempArray[i]);
        }
        return 0;
    }
  • 相关阅读:
    JavaScript节点介绍
    JavaScript DOM操作案例tab切换案例
    Binder系列10—总结
    Binder系列9—如何使用AIDL
    Binder系列8—如何使用Binder
    Binder系列7—framework层分析
    Binder系列2—Binder Driver再探
    Binder系列1—Binder Driver初探
    Binder系列3—启动ServiceManager
    Binder系列4—获取ServiceManager
  • 原文地址:https://www.cnblogs.com/lsfv/p/9127973.html
Copyright © 2011-2022 走看看