NSArray+Safety.h 1010 Bytes
//
//  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