字符串截取

字符串的截取

NSString* index=@"/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip";

对路径截取的9种操作
    NSLog(@"1=%@",[index lastPathComponent]);
    NSLog(@"2=%@",[index stringByDeletingLastPathComponent]);
    NSLog(@"3=%@",[index pathExtension]);
    NSLog(@"4=%@",[index stringByDeletingPathExtension]);
    NSLog(@"5=%@",[index stringByAbbreviatingWithTildeInPath]);
    NSLog(@"6=%@",[index stringByExpandingTildeInPath]);
    NSLog(@"7=%@",[index stringByStandardizingPath]);
    NSLog(@"8=%@",[index stringByResolvingSymlinksInPath]);
    NSLog(@"9=%@",[[index lastPathComponent] stringByDeletingPathExtension]);


对应结果
 1=2013_50.zip
 2=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books
3=zip
 4=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50
5=~/Documents/DownLoad/books/2013_50.zip
 6=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip
 7=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip
8=/Users/junzoo/Library/Application Support/iPhone Simulator/7.0.3/Applications/63925F20-AF97-4610-AF1C-B6B4157D1D92/Documents/DownLoad/books/2013_50.zip
9=2013_50


网络字节顺序(也就是大端模式)
htonl()     //32位无符号整型的主机字节顺序到网络字节顺序的转换(小端->>大端)
htons()     //16位无符号短整型的主机字节顺序到网络字节顺序的转换  (小端->>大端)
ntohl()     //32位无符号整型的网络字节顺序到主机字节顺序的转换  (大端->>小端)
ntohs()     //16位无符号短整型的网络字节顺序到主机字节顺序的转换  (大端->>小端)

typedef unsigned int uint_32 ;
typedef unsigned short uint_16 ;
//16位
#define BSWAP_16(x) \
(uint_16)((((uint_16)(x) & 0x00ff) << 8) | \
(((uint_16)(x) & 0xff00) >> 8) \
)
//32位
#define BSWAP_32(x) \
(uint_32)((((uint_32)(x) & 0xff000000) >> 24) | \
(((uint_32)(x) & 0x00ff0000) >> 8) | \
(((uint_32)(x) & 0x0000ff00) << 8) | \
(((uint_32)(x) & 0x000000ff) << 24) \
)
//无符号整型16位  
uint_16 bswap_16(uint_16 x)
{
    return (((uint_16)(x) & 0x00ff) << 8) |
    (((uint_16)(x) & 0xff00) >> 8) ;
    
}
//无符号整型32位
uint_32 bswap_32(uint_32 x)
{
    return (((uint_32)(x) & 0xff000000) >> 24) |
    (((uint_32)(x) & 0x00ff0000) >> 8) |
    (((uint_32)(x) & 0x0000ff00) << 8) |
    (((uint_32)(x) & 0x000000ff) << 24) ;
    
}  


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值