NSArray+Safety.h
1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// NSArray+Safety.h
// BBAFoundation
//
// Created by Zhu,Yusong on 2018/9/24.
// Copyright © 2018年 Baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BDPFoundationDefines.h"
/*
* 数组的安全相关的扩展
* 详细介绍请看README-SafeAPI
*/
NS_ASSUME_NONNULL_BEGIN
@interface NSArray (Safety)
/**
* @brief 安全的获取数组内index位置的对象
*
* @param index index
* @return index位置的对象,index不合法则返回nil
*/
- (nullable id)safe_objectAtIndex:(NSUInteger)index BDP_FOUNDATION_DEPRECATED("please use bdp_safeObjectAtIndex:");
- (nullable id)bdp_safeObjectAtIndex:(NSUInteger)index;
/**
* @brief安全的获取某一段数组里面的对象
*
* @param range 所要截取的range区间
* @return array
*/
- (nullable NSArray *)safe_subarrayWithRange:(NSRange)range BDP_FOUNDATION_DEPRECATED("please use bdp_safeSubarrayWithRange:");
- (nullable NSArray *)bdp_safeSubarrayWithRange:(NSRange)range;
@end
NS_ASSUME_NONNULL_END