วิธีเตรียม ForSegue ด้วย NSFetchedResults เจาะลึกไปยังมุมมองตารางอื่นโดยมีวัตถุประสงค์ c

ฉันรู้ว่าอาจมีวิธีแก้ปัญหาที่ง่ายมากสำหรับเรื่องนี้ ฉันใช้ตัวอย่าง apple iphoneCoreDataRecipes ฉันกำลังพยายามเจาะลึกจากตารางเริ่มต้น (RecipeTypeTableViewController) ของ RecipeTypes (เช่น เครื่องดื่ม, ของหวาน, Entree) ไปยังมุมมองตารางถัดไปพร้อมรายการสูตรอาหารประเภทเหล่านั้น (RecipeListTableViewController) ฉันสร้างคลาส RecipeType ใหม่ โดยคิดว่าฉันสามารถใช้คลาสนี้เพื่อส่งคืนสูตรอาหารของ RecipeType ที่เลือกได้ จนถึงตอนนี้สิ่งที่ดีที่สุดที่ฉันทำได้คืออนุญาตให้เลือกได้ แต่มันแสดงรายการสูตรอาหารทั้งหมดเหมือนกัน โค้ดต้นฉบับเริ่มต้นด้วย RecipeListTableViewController โดยใช้ NSFetchedResults เพื่อแสดงสูตรอาหารทั้งหมด ตอนนี้ฉันมีมุมมองเริ่มต้นของ RecipeTypes แล้ว แต่ฉันไม่แน่ใจว่าจะส่งประเภทที่เลือกไปยัง RecipeListTableViewController ได้อย่างไร ฉันต้องเปลี่ยน RecipeListTableViewController เพื่อแสดงรายการ RecipeType ที่เลือก แต่ฉันไม่แน่ใจว่าจะนำไปใช้อย่างไร ฉันคิดว่าโดยพื้นฐานแล้วฉันต้องการส่ง NSMutableArray ของ fetchedresults ไปยัง tableview อื่น แต่ไม่แน่ใจว่าควรใช้ทิศทางใด และฉันไม่ต้องการทำให้การทำงานอื่นๆ ใน RecipeListTableViewController ยุ่งเหยิง เช่น การค้นหาและแก้ไขสูตรอาหาร นี่คือรูปภาพการทำงานของตารางจนถึงตอนนี้ [RecipeTypeTableView][1] และ [RecipeListTableview][2] ขอขอบคุณล่วงหน้าสำหรับข้อเสนอแนะใด ๆ

ลบสิ่งเหล่านี้แล้ว

ไฟล์: RecipeType.h

ไฟล์: RecipeType.m

ฉันใช้ NSManagedObject *type จากคลาสสูตรอาหารของฉัน NSManagedObject เพื่อสร้างมุมมองเริ่มต้นของประเภทสูตรอาหาร (อาหารเรียกน้ำย่อย Bev ฯลฯ) บน RecipeTypeTableViewController -

ไฟล์: Recipe.h

@interface Recipe : NSManagedObject
@property (nonatomic, strong) NSManagedObject *type;

ไฟล์: RecipeTypeTableViewController.h

//  RecipeTypeTableViewController.h
//  Recipes
#import <UIKit/UIKit.h>
@interface RecipeTypeTableViewController : UITableViewController <NSFetchedResultsControllerDelegate>
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong) NSManagedObject *type;
@end

ไฟล์: RecipeTypeTableViewController.m - การเตรียมการสำหรับส่วนที่ทำต่อ

#import "RecipeTypeTableViewController.h"
#import "Recipe.h"
#import "RecipeListTableViewController.h"
@interface RecipeTypeTableViewController () <NSFetchedResultsControllerDelegate>
@property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController;
@end

@implementation RecipeTypeTableViewController

static NSString *MyIdentifier = @"showRecipes";

- (void)viewDidLoad {
[super viewDidLoad];
// register this class for our cell to this table view under the specified identifier 'ARecipeType'
self.title = @"Category";
//[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"ARecipeType"];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangePreferredContentSize:)name:UIContentSizeCategoryDidChangeNotification object:nil];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
NSError *error = nil;
if (![[self fetchedResultsController] performFetch:&error]) {

    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    //abort();
}
}

- (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];
self.title = @"Category";

}

- (void)didChangePreferredContentSize:(NSNotification *)notification
{
[self.tableView reloadData];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIContentSizeCategoryDidChangeNotification object:nil];
}
#pragma mark - Table view data source

//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//#warning Incomplete implementation, return the number of sections
//return [[self.recipeTypeFetchedResultsController sections] count];

//    return 1;
//}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Number of rows is the number of recipe types
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];
//return self.recipeTypes.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ARecipeType" forIndexPath:indexPath];

// Configure the cell
NSManagedObject *recipeType = [self.recipeTypes objectAtIndex:indexPath.row];
cell.textLabel.text = [recipeType valueForKey:@"name"]; 
return cell;
}

#pragma mark - Fetched results controller

- (NSFetchedResultsController *)fetchedResultsController {

// Set up the fetched results controller if needed.
if (_fetchedResultsController == nil) {
    // Create the fetch request for the entity.
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    // Edit the entity name as appropriate.
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"RecipeType" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];
    NSLog(@"Setting up a Fetched Results Controller for the Entity named %@", entity);

    // Edit the sort key as appropriate.
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];

    [fetchRequest setSortDescriptors:sortDescriptors];

    // Edit the section name key path and cache name if appropriate.
    // nil for section name key path means "no sections".
    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"Recipe"];
    aFetchedResultsController.delegate = self;
    self.fetchedResultsController = aFetchedResultsController;


    NSError *error = nil;
    if (![self.fetchedResultsController performFetch:&error])
    {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    }
}

return _fetchedResultsController;
}

#pragma mark - Navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showRecipes"]) {
    NSLog(@"Setting RecipeType for the RecipeListTableViewController");
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    Recipe *selectedType = [self.fetchedResultsController objectAtIndexPath:indexPath];
    RecipeListTableViewController *recipeListViewController = segue.destinationViewController;
    recipeListViewController.type = selectedType;
    recipeListViewController.managedObjectContext = self.managedObjectContext;
}
}

ไฟล์: RecipeListTableViewController.h - ส่วน NSPredicate และแคช FRC

#import <UIKit/UIKit.h>
#import "RecipeAddViewController.h"

@interface RecipeListTableViewController : UITableViewController <RecipeAddDelegate, NSFetchedResultsControllerDelegate>

@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong) NSManagedObject *type;

ไฟล์: RecipeListTableViewController.m

#import "RecipeListTableViewController.h"
#import "RecipeDetailViewController.h"
#import "Recipe.h"
#import "RecipeTableViewCell.h"
#import "Recipe+Extensions.h"
#import "TypeSelectionViewController.h"
#import "IngredientDetailViewController.h"
#import "Ingredient.h"
#import "WhereViewController.h"
#import "FavoriteListTableViewController.h"
#import "RecipeTypeTableViewController.h"
#import "RecipeType.h"


@interface RecipeListTableViewController () <NSFetchedResultsControllerDelegate, UISearchBarDelegate, UISearchResultsUpdating>

@property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, strong) NSArray *filteredList;
@property (nonatomic, strong) NSFetchRequest *searchFetchRequest;
@property (nonatomic, strong) UISearchController *searchController;

typedef NS_ENUM(NSInteger, RecipesSearchScope)
{
searchScopeRecipe = 0,
searchScopeIngredients = 1
};


@end

@implementation RecipeListTableViewController


#pragma mark - Fetched results controller

- (NSFetchedResultsController *)fetchedResultsController {

// Set up the fetched results controller if needed.
if (_fetchedResultsController == nil) {
    // Create the fetch request for the entity.
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    // Edit the entity name as appropriate.
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Recipe" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];

[NSFetchedResultsController deleteCacheWithName:@"Recipe"];

    // Create predicate
    //if (self.type) {
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"type == %@", self.type];
    [fetchRequest setPredicate:predicate];
    //}


    // Edit the sort key as appropriate.
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];

    [fetchRequest setSortDescriptors:sortDescriptors];

    // Edit the section name key path and cache name if appropriate.
    // nil for section name key path means "no sections".
    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"Recipe"];
    aFetchedResultsController.delegate = self;
    self.fetchedResultsController = aFetchedResultsController;

    NSError *error = nil;
    if (![self.fetchedResultsController performFetch:&error])
    {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    }
}

return _fetchedResultsController;
}

/

เมื่อฉันตั้งค่าแคช FRC เป็น "สูตรอาหาร" มันขัดข้อง มันแสดงให้เห็นเบาะแสนี้เพื่อดูแคช CoreData: ข้อผิดพลาด FATAL: แคชถาวรของข้อมูลส่วนไม่ตรงกับการกำหนดค่าปัจจุบัน คุณได้กลายพันธุ์คำขอดึงข้อมูลของ NSFetchedResultsController ภาคแสดง หรือคำอธิบายการเรียงลำดับของ NSFetchedResultsController อย่างผิดกฎหมาย

หากฉันตั้งค่าแคชเป็นศูนย์ หรือเพิ่ม [NSFetchedResultsController DeleteCacheWithName:@"Recipe"]; ก่อนเซตภาคแสดง สิ่งต่างๆ ทำงานตามที่คาดไว้ ฉันมีแคชนี้ในตัวควบคุมมุมมองเริ่มต้นและตัวควบคุมมุมมองที่สอง นั่นอาจเป็นปัญหา - ฉันต้องการแคชในตัวควบคุมมุมมองเริ่มต้นเท่านั้น




คำตอบ (1)


ก่อนอื่น ฉันคิดว่าโมเดลข้อมูลของคุณต้องมีการปรับปรุงเล็กน้อย RecipeType แต่ละตัวอาจมี Recipes เชื่อมโยงกันมากมาย ดังนั้นความสัมพันธ์ตั้งแต่ RecipeType ถึง Recipe ควรเป็น ต่อกลุ่ม หากคุณเปลี่ยนแปลงสิ่งนี้ในตัวแก้ไขโมเดลข้อมูล และสร้างคลาสโมเดลใหม่ คุณควรมีคลาส RecipeType ที่มีลักษณะดังนี้:

@class Recipe;

@interface RecipeType : NSManagedObject
// not sure what purpose this property serves; it might now be superfluous...
@property (nonatomic, strong) NSManagedObject *type;

@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSSet<Recipe *> *recipes;

@end 

ฉันจะถือว่าในขณะนี้แต่ละ Recipe สามารถเป็นของ RecipeType ได้เพียงอันเดียวเท่านั้น ดังนั้นความสัมพันธ์แบบผกผันจาก Recipe ถึง RecipeType ควรเป็น to-one และคลาส Recipe จึงมีคุณสมบัติ:

*property (nonatomic, strong) RecipeType *type;

ถัดไป คุณต้องการให้ RecipeListTableViewController ของคุณแสดงเฉพาะ Recipes ที่เกี่ยวข้องกับ RecipeType ที่เกี่ยวข้อง เพื่อให้บรรลุเป้าหมายดังกล่าว คุณจะต้องเพิ่มเพรดิเคตลงในตัวควบคุมผลลัพธ์ที่ดึงมา ในเมธอด fetchedResultsController ให้เพิ่ม:

if (self.recipeType) {
    fetchRequest.predicate = [NSPredicate predicateWithFormat:@"type == %@", self.recipeType];
}

(คุณจะต้องแก้ไขการค้นหาของคุณเพื่อจำกัดการค้นหาให้อยู่ใน RecipeType ที่เกี่ยวข้องเช่นเดียวกัน) ใน RecipeTypeTableViewContoller นั้น prepareForSegue ของคุณจะต้องผ่าน RecipeType ที่ถูกต้องเท่านั้น:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {    
    if ([[segue identifier] isEqualToString:@"showRecipes"]) {
        NSLog(@"Setting RecipeType for the RecipeListTableViewController");
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        RecipeType *selectedType = [self.fetchedResultsController objectAtIndexPath:indexPath];
        RecipeListTableViewController *recipeListViewController = segue.destinationViewController;
        recipeListViewController.recipeType = selectedType;
        recipeListViewController.managedObjectContext = self.managedObjectContext;
    }
}

เมื่อใดก็ตามที่คุณเพิ่ม Recipe ใหม่ คุณจะต้องกำหนดให้กับ RecipeType ที่ถูกต้อง ดังนั้นในการ RecipeListViewController แก้ไข prepareForSegue ของคุณเพื่อกำหนดความสัมพันธ์:

...
else if ([segue.identifier isEqualToString:kAddRecipeSegueID]) {
    // add a recipe
    //
    Recipe *newRecipe = [NSEntityDescription insertNewObjectForEntityForName:@"Recipe" inManagedObjectContext:self.managedObjectContext];
    newRecipe.type = self.recipeType;

    UINavigationController *navController = segue.destinationViewController;
    RecipeAddViewController *addController = (RecipeAddViewController *)navController.topViewController;
    addController.delegate = self;  // do didAddRecipe delegate method is called when cancel or save are tapped
    addController.recipe = newRecipe;
}
person pbasdf    schedule 28.08.2016
comment
คำตอบของคุณจะได้ A เพื่อความแม่นยำ การจำโค้ดยอดนิยม ขอบคุณ....มันได้ผล แต่แล้วมันก็ไม่เป็นเช่นนั้น และฉันยอมรับว่าไม่ใช่เพราะคุณถูกหรือไม่ใช่ - person Chuck; 29.08.2016
comment
ฉันกำหนดค่า RecipeType ใหม่แล้ว การลบคลาสย่อยและใช้ NSManagedObject *type ที่มีอยู่จาก Recipe Class ฉันได้รับรายการประเภทสูตรอาหาร และเมื่อฉันเลือกของว่าง ก็จะแสดงสูตรของว่าง 2 สูตร สุดยอด. - person Chuck; 29.08.2016
comment
แต่เมื่อฉันกลับไปที่รายการหมวดหมู่และเลือกประเภทอื่นมันก็ล้มเหลว ฉันรีสตาร์ทซิมของแอปแล้วเลือกประเภทอื่นและมันก็ผ่านรายการที่ถูกต้อง แต่ฉันเลือกประเภทที่ไม่มีสูตร มันจะแสดงตารางเปล่า แล้วถ้าฉันกลับมาเลือกประเภทอื่น ถึงแม้จะมีสูตรบางสูตรมันก็ให้ตารางเปล่า ขออภัยสำหรับความคิดเห็นที่หลากหลาย - กลับมาอย่างมีความสุข - person Chuck; 29.08.2016
comment
[รหัส] @interface สูตร : NSManagedObject [รหัส]@property (ไม่ใช่อะตอมมิก แข็งแกร่ง) NSManagedObject *type; [code]@end [code]// สร้างภาคแสดง if (self.type) { fetchRequest.predicate = [NSPredicate predicateWithFormat:@type == %@, self.type]; //[fetchRequest setPredicate:ภาคแสดง]; }[รหัส] - person Chuck; 29.08.2016
comment
[code]- (void)prepareForSegue ทำได้ 100% ขอบคุณถ้า ([[segue identifier] isEqualToString:@showRecipes]) { NSLog(@Setting RecipeType for the RecipeListTableViewController); NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; สูตร *selectedType = [self.fetchedResultsController objectAtIndexPath:indexPath]; RecipeListTableViewController *recipeListViewController = segue.destinationViewController; RecipeListViewController.type = เลือกประเภท; RecipeListViewController.managedObjectContext = self.managedObjectContext; [รหัส] - person Chuck; 29.08.2016
comment
@Chuck ไม่แน่ใจว่าฉันเข้าใจความคิดเห็นของคุณ คุณได้แก้ไขปัญหาแล้วหรือยัง? แจ้งให้เราทราบหากมีอะไรที่โดดเด่น - person pbasdf; 29.08.2016
comment
ขออภัยใช่ฉันรู้ว่าฉันไป cra cra พร้อมความคิดเห็น คำตอบของคุณต่อภาคแสดงและภาคแสดงนั้นถูกต้อง ขอบคุณ - หลังจากกำหนดค่าใหม่แล้ว คลาส Recipe จะมี NSManaged Object *type ซึ่งฉันใช้และตัดการอ้างอิงคลาสย่อย RecipeType ทั้งหมดออก การกำหนดค่าใหม่แสดงรายการประเภทต่างๆ และเมื่อฉันเลือกประเภทใดประเภทหนึ่ง ก็จะแสดงสูตรอาหารประเภทที่ถูกต้อง แต่เมื่อฉันกลับไปที่รายการประเภทและเลือกประเภทอื่น มันก็ล้มเหลว ฉันสามารถรีสตาร์ทเครื่องจำลองและเลือกประเภทอื่นได้ จากนั้นเครื่องจะส่งคืนอย่างถูกต้อง - person Chuck; 30.08.2016
comment
แต่หากฉันเลือกประเภทที่ไม่มีสูตรอาหาร ก็จะได้ตารางว่างตามที่คาดไว้ และหากฉันกลับไปที่รายการประเภทและเลือกประเภทอื่น ก็จะส่งคืนประเภทอื่นๆ ทั้งหมดเป็นว่างเปล่า ดูเหมือนว่าจะได้ผลแต่เพียงครั้งเดียวเท่านั้น บางทีตารางประเภทสูตรอาจจำเป็นต้องรีเซ็ตในภาคการคืนสินค้า ข้อเสนอแนะใด ๆ ขอบคุณอีกครั้ง - person Chuck; 30.08.2016
comment
ไม่แน่ใจว่าจะใส่ @property (nonatomic, strong) NSSet <Recipe *> *recipes; ไว้ที่ไหนตอนนี้ ฉันมีมันใน RecipeTypeTVC.h นอกจากนี้ @class Recipe ที่นี่ และ @dynamic บน RecipeTypeTVC.m. และไม่แน่ใจว่าสิ่งนี้เคยใช้ที่ไหน? - person Chuck; 30.08.2016
comment
ภาคต่อที่เตรียมได้รับประเภทตอนนี้ Recipe *selectedType = [self.fetchedResultsController objectAtIndexPath:indexPath]; RecipeListTableViewController *recipeListViewController = segue.destinationViewController; recipeListViewController.type = selectedType; recipeListViewController.managedObjectContext = self.managedObjectContext; - person Chuck; 30.08.2016
comment
ตกลง ตั้งค่า NS Cache ของฉันเป็นศูนย์ - ตอนนี้ใช้งานได้อย่างมีเสน่ห์ `NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest ManagedObjectContext:self.managedObjectContext SectionNameKeyPath:nil cacheName:nil];' - person Chuck; 30.08.2016
comment
แล้วจะนำไปสู่วิธีเก็บแคชและใช้งาน DeleteCacheWithName ต่อไป? - person Chuck; 30.08.2016
comment
@Chuck คำจำกัดความคุณสมบัติ recipes ควรอยู่ใน .h สำหรับคลาสย่อยสำหรับเอนทิตี Type แต่ถ้าคุณไม่ได้ใช้คลาสย่อย ก็ไม่จำเป็นต้องใช้คำจำกัดความนี้ คุณควรตรวจสอบให้แน่ใจว่าความสัมพันธ์ระหว่าง Type และ Recipe ได้รับการตั้งค่าอย่างถูกต้องเป็น to-many ไม่แน่ใจว่าเหตุใดแคช FRC จึงส่งผลต่อสิ่งต่าง ๆ คุณสามารถแสดงข้อผิดพลาดจากความผิดพลาดได้หรือไม่? นอกจากนี้ ควรแก้ไขคำถามของคุณและเพิ่มโค้ด/ข้อผิดพลาดที่นั่น แทนที่จะเพิ่มความคิดเห็น - person pbasdf; 30.08.2016
comment
ว้าว - ขอบคุณสำหรับคำแนะนำดีๆ แบบนี้สำหรับโปสเตอร์ครั้งที่สอง ฉันกลัวมากที่จะโพสต์เพราะกลัวว่าใครจะหัวเราะแล้วบอกให้ฉันศึกษา Apple dox คุณเป็นคนดีมาก ฉันจะแก้ไขข้อผิดพลาดและโพสต์เร็วๆ นี้ และจะแสดงการแก้ไขโค้ดในคำถามของฉันตามคำแนะนำของคุณ อีกจุดเดียวเท่านั้นที่นี่ ฉันต้องการให้แคช FRC อยู่ในทั้งสองคลาส tableviews พร้อมประเภทและสูตรหรือไม่ หรือฉันต้องอ้างอิงแคชในตารางแรกเท่านั้น? และฉันต้องการแคชเลยหรือไม่? - person Chuck; 31.08.2016
comment
@Chuck รายละเอียดการเก็บแคชของ FRC ว่าวัตถุใดอยู่ในส่วนใด - ดังนั้นคุณไม่ควรใช้ชื่อแคชเดียวกันสำหรับ FRC ที่แยกจากกัน (เว้นแต่ว่าจะแสดงข้อมูล ตรงทั้งหมด เดียวกัน) ในกรณีของคุณ ข้อมูลจะแสดงข้อมูลที่แตกต่างกันโดยสิ้นเชิง ดังนั้นหากคุณต้องการให้ทั้งคู่ใช้แคช ให้ใช้ชื่อแคชที่แตกต่างกัน แต่แคชไม่จำเป็น พวกเขาเร่งความเร็วสิ่งต่าง ๆ ถ้าคุณมีวัตถุจำนวนมาก แต่ฉันสงสัยว่าสิ่งเหล่านี้จะสร้างความแตกต่างที่เห็นได้ชัดเจนในกรณีของคุณ - person pbasdf; 31.08.2016