nsmutablearray

ZKImageSelectView

痞子三分冷 提交于 2019-11-30 02:00:53
// // ZKImageSelectView.h // ZKImageSelectAndBrowse // // Created by HELLO WORLD on 2019/9/18. // Copyright © 2019年 WaterProofer. All rights reserved. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface ZKImageSelectView : UIImageView //图片列表 @property (nonatomic, strong) NSMutableArray<UIImage*>* listImages; //最多可选择的图片数 @property (nonatomic, readwrite) int maxNumberOfImage; //是否允许编辑 @property (nonatomic, readwrite) BOOL allowEdit; @property (nonatomic, readwrite) BOOL allowScroll; @property (nonatomic, copy) void (^selectAddBtnCilck)(UIImage*); @property (nonatomic, copy) void (

4.7 Moving Cells and Sections in Table Views

戏子无情 提交于 2019-11-30 00:20:10
Problem 在表视图里面通过流畅而直观的动画来移动改变cell 和section 的位置 Solution 使用 moveSection: toSection 表视图方法,将部分移动到一个新的位置。您还可以使用moveRowAtIndexPath: toIndexPath: 方法移动表视图单元格从当前位置到另一个新的地方 Discussion 移动表视图细胞和部分不同于交换他们。让我们来看一个例子,这将使这个更容易理解。比方说,你有三个部分中的表视图:第A, B和C。如果您移动部分A到C组,表视图会注意到这一举动,然后将B部分转移到A段之前的位置,并将移动C节第B的前面的位置但是,如果B段被移动到C组,表视图不会有移动A节可言,因为它是坐在上面,并不会与重新定位干扰B段和C在这种情况下, B段将被移动到C段和C段第B移动单元格时,同样的逻辑也将使用表格视图。 为了证明这一点,让我么创建一个表视图,并拥有三个section,每个section包含三个预先加载的三个cell。让我们开始我们的视图控制器的实现文件: #import “ViewController.h ” static NSString *CellIdentifier = @“CellIdentifier”; @interface ViewController () <UITableViewDelegate

Objective-c for 循环 九宫格

我们两清 提交于 2019-11-30 00:02:31
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - ( void )viewDidLoad { [ super viewDidLoad ]; [ self ninePic ]; // Do any additional setup after loading the view, typically from a nib. } -( void )ninePic { NSMutableArray *_imageArr = [ NSMutableArray arrayWithCapacity : 10 ]; for ( int i = 0 ; i < 3 ; i++) { for ( int j = 0 ; j < 3 ; j++) { CGRect rect = CGRectMake ( 18.75 +j* 118.75 , 200 +i* 118.75 , 100 , 100 ); UIImageView *imageView = [[ UIImageView alloc ] initWithFrame :rect]; imageView. backgroundColor = [ UIColor purpleColor ]; [ self .

Writing a new set of data to Plist instead of overwriting it

浪子不回头ぞ 提交于 2019-11-29 23:37:59
问题 I'm trying to get a plist to store multiple sets of data, but each time I save (using a button from an ActionSheet), it overwrites the previous set. I want to add multiple 'friends' and their data. I'm not too keen on using Core Data, so I'm wondering how you can do it with a Plist. Here is the code for the save button: NSMutableDictionary *friend = [[NSMutableDictionary alloc] init]; NSMutableDictionary *array = [[NSMutableDictionary alloc]init]; [array setObject:friendName.text forKey:@

How can I sort strings in NSMutableArray into alphabetical order?

落爺英雄遲暮 提交于 2019-11-29 23:33:23
I have a list of strings in an NSMutableArray , and I want to sort them into alphabetical order before displaying them in my table view. How can I do that? There is the following Apple's working example, using sortedArrayUsingSelector: and localizedCaseInsensitiveCompare: in the Collections Documentation : sortedArray = [anArray sortedArrayUsingSelector: @selector(localizedCaseInsensitiveCompare:)]; Note that this will return a new sorted array. If you want to sort your NSMutableArray in place, then use sortUsingSelector: instead, like so: [mutableArray sortUsingSelector:@selector

how can I Add a ABRecordRef to a NSMutableArray in iPhone?

一曲冷凌霜 提交于 2019-11-29 18:21:15
问题 I want to create an array of ABRecordRef(s) to store contacts which have a valid birthday field. NSMutableArray* bContacts = [[NSMutableArray alloc] init]; ABAddressBookRef addressBook = ABAddressBookCreate(); CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook); CFIndex nPeople = ABAddressBookGetPersonCount(addressBook); for( int i = 0 ; i < nPeople ; i++ ) { ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i ); NSDate* birthdayDate = (NSDate*) ABRecordCopyValue(ref,

How to assign values from NSMutableDictionary to NSArray

折月煮酒 提交于 2019-11-29 18:15:55
I am doing JSON parsing and I want to show my parsed data in a UITableView . For that, I am trying to assign parsed data from NSMutableDictionary to NSArray to show in the table view but the array returns null . Here my array returns null value; NSMutableDictionary *tempDict1; NSArray *arr = [[tempDict1 valueForKey:@"rates"] componentsSeparatedByString:@";"]; code - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; self.responseData = nil; // NSArray

Can i have a single NSMutableArray in my multiple views application?

◇◆丶佛笑我妖孽 提交于 2019-11-29 17:56:17
I have a navigational based application which has multiple views. Is it possible to use one single NSMutableArray for the whole applicaiton? Can i add objects to that NSMutableArray in one view and then remove object from the same NSMutableArray from some other view? I tried myappAppDelegate *appDelegate = (myappAppDelegate *)[[UIApplication sharedApplication] delegate]; but it gives me null when i try to access appDelegate's array. If anyone can give me any idea or helping link or tutrorial. Thanks in advance. If you are having multiple views in your application, and in that case you want to

Random number without repeating

时间秒杀一切 提交于 2019-11-29 17:39:26
I have NSMutableArray with 50 array elements. I need to generate randomly without any repetition. Can you suggest some sample codes. here is sample to get random int less than 1000. int y = arc4random() % 1000; to stay without duplicates, just check before inserting Create a local mutablearray copy of main array, and after getting random value, remove object available at random index from local array, process it till array count is 1. James Webster I have assumed you want to generate numbers. This is the answer I have used for generating M random numbers from N. Though it doesn't add them into

Mutable Objects inside NSUserDefaults

笑着哭i 提交于 2019-11-29 16:46:33
I created a simple database and put in NSUserDefaults. My database is NSMutableArray which has dictionaries and arrays inside in it. When I create NSMutableArray from NSUSerDefaults I can't add any objects to my mutable objects inside my NSMutableArray. Here is my code: NSMutableArray *arrayOne = [NSMutableArray arrayWithContentsOfFile:[self createEditableCopyOfIfNeededWithFileName:@"Form.plist"]]; NSUserDefaults *ayarlar = [NSUserDefaults standardUserDefaults]; [ayarlar setObject:arrayOne forKey:@"form"]; NSMutableArray *arrayTwo = [NSMutableArray arrayWithArray:[[ayarlar objectForKey:@"form"