我正在尝试做一个基本的无线电应用程序,我得到了一个URL列表:当我尝试调用无效的URL(错误的路径或没有可播放文件的正确路径)时,Observer似乎永远不会被调用.这是我的代码的一部分:
urlStream = [NSURL URLWithString:mp3URL];
self.playerItem = [AVPlayerItem playerItemWithURL:urlStream];
[playerItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil];
[playerItem addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil];
[appDelegate.player addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:nil];
[appDelegate.player replaceCurrentItemWithPlayerItem:playerItem]; //OK
[appDelegate.player play];
Run Code Online (Sandbox Code Playgroud)
在我得到的相对观察者方法中:
if (object == playerItem && [keyPath isEqualToString:@"playbackBufferEmpty"])
{
if (playerItem.playbackBufferEmpty)
{
NSLog(@"playbackBufferEmpty");
[self alertBuffer];
}
}
if (object == playerItem && [keyPath isEqualToString:@"playbackLikelyToKeepUp"])
{
if (playerItem.playbackLikelyToKeepUp)
{
NSLog(@"playbackLikelyToKeepUp");
[loadStation stopAnimating];
if (playerItem.status == AVPlayerItemStatusReadyToPlay) {
NSLog(@"AVPlayerItemStatusReadyToPlay");
}
else if (playerItem.status == AVPlayerStatusFailed) {
NSLog(@"AVPlayerStatusFailed");
}
else if (playerItem.status == AVPlayerStatusUnknown) …Run Code Online (Sandbox Code Playgroud) 在阅读了有关表情符号的所有主题之后,我有必要寻求帮助.问题似乎几乎相同:我有一个iPhone应用程序通过PHP表情符号发送到MySQL数据库,我可以看到记录上的一些符号,例如"伞"和"云",但其他没有(愤怒的脸,笑脸,和其他).
为什么有些是和其他没有?
PHP设置:
mysql_query("SET CHARACTER SET utf8mb4");
mysql_query("SET NAMES utf8mb4");
Run Code Online (Sandbox Code Playgroud)
记录中未显示的符号显示为问号"?"
iOS内存管理对我来说仍然是一个奇怪的东西,但这对我来说也是最有趣的方面,所以我在这里要求我的代码提供一些帮助.
我尝试实例化一个NSDictionary对象,我使用它然后我想发布但我得到一个对象发布错误,这是代码:
if ([jsonArray count] > 0) {
NSDictionary *commentDictionary = [[NSDictionary alloc]init];
int i;
for (i = 0; i < [jsonArray count]; i++) {
commentDictionary = [jsonArray objectAtIndex:i];
NSLog(@"debugging message here"]);
commentLabel.text = [commentDictionary objectForKey:@"commentText"];
//[commentDictionary retain];
}
//[commentDictionary release];
commentDictionary = nil;
NSLog(@"NSDictionary retainCount = %d",[commentDictionary retainCount]);
}
Run Code Online (Sandbox Code Playgroud)
没什么特别的,我从一个数组中填写一个字典,在我的代码中你可以看到我试图发布但是因为错误我注释掉了.为什么我不能发布字典?
除了设置NSDictionary与nil之间的区别是什么在retainCount和release中返回零(应该使计数为-1)?
我非常感谢你在本主题中给予的任何帮助.
法布里奇奥
avplayer ×1
cocoa ×1
emoji ×1
ios ×1
iphone ×1
mysql ×1
nsdictionary ×1
objective-c ×1
php ×1
utf8mb4 ×1