एआरसी का उपयोग करने के लिए एक परियोजना को परिवर्तित करते समय "स्विच केस संरक्षित क्षेत्र में क्या होता है" का मतलब है? मैं एक्सकोड 4 एडिट -> रिफैक्टर -> ऑब्जेक्टिव-सी एआरसी में कनवर्ट करने के लिए एआरसी का उपयोग करने के लिए एक प्रोजेक्ट को परिवर्तित कर रहा हूं ... मुझे मिली त्रुटियों में से एक "स्विच केस संरक्षित क्षेत्र में है" पर "कुछ" एक स्विच मामले में स्विच।एआरसी का उपयोग करने के लिए प्रोजेक्ट को कनवर्ट करते समय "स्विच केस सुरक्षित क्षेत्र में क्या होता है" का मतलब है?
त्रुटि "डिफ़ॉल्ट" इस मामले पर चिह्नित है:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"";
UITableViewCell *cell ;
switch (tableView.tag) {
case 1:
CellIdentifier = @"CellAuthor";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[prefQueries objectAtIndex:[indexPath row]] valueForKey:@"queryString"];
break;
case 2:
CellIdentifier = @"CellJournal";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[prefJournals objectAtIndex:[indexPath row]] valueForKey:@"name"];
NSData * icon = [[prefJournals objectAtIndex:[indexPath row]] valueForKey:@"icon"];
if (!icon) {
icon = UIImagePNGRepresentation([UIImage imageNamed:@"blank72"]);
}
cell.imageView.image = [UIImage imageWithData:icon];
break;
default:
CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
break;
}
return cell;
}
वाह! इसने काम कर दिया! लेकिन क्यों?! – Ali
ब्रेसिज़ संकलक को समझने में मदद करते हैं।मुझे पता है कि जीसीसी ने चेतावनी जारी करने के लिए प्रयोग किया था यदि आपने ब्रेसिज़ के बिना केस स्टेटमेंट की पहली पंक्ति में एक नया चर घोषित किया था, और एआरसी पर डब्ल्यूडब्ल्यूडीसी 2011 वीडियो ब्रेसिज़ में मामलों को घेरने के बारे में कुछ बताता है। अगर आप जानना चाहते हैं, तो उस वीडियो को देखें- मैं अपने सिर के ऊपर से याद नहीं कर सकता। – FeifanZ
यह एक समय हो गया है, लेकिन मैं सी मानक क्योंकि कोड वास्तव में एक ब्लॉक के अंदर नहीं है कि एक मामले बयान के बाद चर काम की अनुमति नहीं दी में कुछ याद करने लगते हैं। 'केस' के बाद और 'ब्रेक' से पहले घुंघराले ब्रेसिज़ '{...} 'जोड़कर, अंदर सबकुछ एक स्कॉप्ड ब्लॉक में है और उम्मीद के अनुसार व्यवहार करेगा। मुझे इस बात की समस्या है कि इस तरह की समस्या से बचने के लिए मैं अपने 'केस' कथन से स्वचालित रूप से एक ब्लॉक बना देता हूं। – Paul