我是iOS的初学者,在桌面视图的帮助下创建了一个应用程序.我只是运行我的应用程序,在运行应用程序时,应用程序不会调用方法cellForRowIndexPath.我使用Json作为Web服务.在输出屏幕中,显示解析数据但不会在模拟器中显示.我把断点,我明白没有调用cellForRowIndexPath路径.我将datasourse和数据委托拖到xib文件的文件中.但没有任何事情发生......桌面视图显示但没有内容......我搞砸了..任何人请帮帮我...
@implementation MSPackagesController
@synthesize packageTable;
@synthesize packages;
@synthesize mainCtrl;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
}
-(void)parseData {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.animationType = MBProgressHUDAnimationFade;
hud.detailsLabelText = @"Loading...";
MSJsonParser *parser = [[MSJsonParser alloc]initWithParserType:kPackagesParsing];
parser._parserSource = self;
[parser requestParsingWithUrl:PACKAGES_LIST_URL];
}
-(void)sharePackageFromCell:(UIButton*)btn
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.animationType = MBProgressHUDAnimationFade;
hud.detailsLabelText = @"Loading...";
NSString *title = [[self.packages objectAtIndex:btn.tag] packageName]; …Run Code Online (Sandbox Code Playgroud) 我试图在 TestCoroutineDispatchers 和 runBlockingTest 的帮助下测试房间数据库的插入和获取。由于我需要创建数据库实例的上下文,因此我尝试在 androidTest 中实现测试,但出现以下错误。任何人都可以帮我解决一个问题。
我正在按照此链接中的说明进行操作,如下所示https://medium.com/@eyalg/testing-androidx-room-kotlin-coroutines-2d1faa3e674f
"未解析的参考:TestCoroutineDispatcher" "未解析的参考:TestCoroutineScope" "未解析的参考:runBlockingTest"
@ExperimentalCoroutinesApi
@RunWith(AndroidJUnit4::class)
class PokemonDatabaseTest {
private lateinit var pokemonDao : PokemonFavouriteDao
private lateinit var db : PokemonDatabase
val testDispatcher = TestCoroutineDispatcher()
val testScope = TestCoroutineScope(testDispatcher)
@Before
fun setUp() {
db = Room
.inMemoryDatabaseBuilder(InstrumentationRegistry.getInstrumentation().context, PokemonDatabase::class.java)
.setTransactionExecutor(testDispatcher.asExecutor())
.setQueryExecutor(testDispatcher.asExecutor()).build()
pokemonDao = db.pfDao
}
@Test
fun storeFavouritePokemon() = runBlockingTest {
val pokemon = DataFactory.makePokemon()
assertThat(pokemonDao.getFavouritePokemon(), null)
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用以下依赖项:
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.2'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
testImplementation 'androidx.test:core:1.2.0'
testImplementation …Run Code Online (Sandbox Code Playgroud)