我在我的博客上设置了一个自定义帖子类型,并为分类法设置了一个特殊页面。在分类页面上,我收到以下错误。谁能给我一些有关如何解决此错误的提示?
该页面加载正常,并按我的预期工作。但是,如果我将调试设置为 true,则会出现以下错误。我想解决这个问题。我粘贴了循环中的成本,该循环在页面上以不同的标准运行了两次。
Notice: Trying to get property of non-object in /home3/ans/public_html/wp-includes/post-template.php on line 29
Run Code Online (Sandbox Code Playgroud)
代码:
<?php
query_single('dealers', 'publish', '1', $taxtype, $value);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$address=get_post_meta($post->ID, 'wpcf-street_address', TRUE);
$city=get_post_meta($post->ID, 'wpcf-city', TRUE);
$state=get_post_meta($post->ID, 'wpcf-state_abbreviation', TRUE);
$zip=get_post_meta($post->ID, 'wpcf-zip_code', TRUE);
$phone=get_post_meta($post->ID, 'wpcf-phone_number', TRUE);
$paid=get_post_meta($post->ID, 'wpcf-paid', TRUE);
$post_id=get_the_ID();
get_each_dealer_brand($post_id);?>
<?php
echo "<ul class=\"ullisting\">";
if($paid==1)
{
echo "<li><p class=\"plisting\"><strong><a href=\"";the_permalink(); echo "\">";the_title();echo "</a></strong></p></li>";
echo "<li><p class=\"plisting\">$address | $city, $state $zip</p></li>";
echo "<li><p class=\"plisting\">P: $phone</p></li>";
echo …Run Code Online (Sandbox Code Playgroud) 经过一半的挖掘,我发现我没有创建文件夹的权限,所以如何获得创建文件夹的权限?
[[NSFileManager defaultManager] createDirectoryAtPath:[NSString stringWithFormat:@"%@/%@",downloadLocation,kAmazonCatalogsPrefix]
withIntermediateDirectories:YES
attributes:nil
error:&error];
Error Domain=NSCocoaErrorDomain Code=513 "The operation couldn’t be completed. (Cocoa error 513.)" UserInfo=0x1f18a8b0 {NSFilePath=/var/mobile/Applications/AB570058-4E4A-41B2-9E40-5C93316D6307/eCatalogs, NSUnderlyingError=0x1f18a830 "The operation couldn’t be completed. Operation not permitted"}
Run Code Online (Sandbox Code Playgroud) 这是Apple Swift文档的副本:
只要超类的所有属性都具有初始值,就会认为其内存已完全初始化,并且第1阶段已完成.
超类的指定初始化程序现在有机会进一步自定义实例(尽管它没有).
一旦超类的指定初始化程序完成,子类的指定初始化程序就可以执行额外的自定义(尽管它也不需要).
所以基本上第1阶段确保所有属性都有一个值并将值赋给它们.在阶段2中,这些属性进一步定制.而这种进一步的定制确实让我感到沮丧,因为我无法想到使用进一步定制的单个例子.您能给我一个简单的初始化行为示例,或者提供第1阶段和第2阶段的其他说明吗?谢谢
这很奇怪...我向一个视图控制器添加了一个表格视图,将原型单元格的数量设置为3,但是在它们自动添加后,第一个原型单元格没有内容视图,也不能添加一个作为子视图.

我错过了什么?
我有这段代码:
if (cell == nil)
{
CGRect cellFrame = CGRectMake(0,0,300,250);
cell = [[UITableViewCell alloc] initWithFrame:cellFrame
reuseIdentifier:CellTableIndetifier];
CGRect nameLabelRect = CGRectMake(0, 5, 70, 20);
UILabel* nameLabel = [[UILabel alloc] initWithFrame:nameLabelRect];
nameLabel.textAlignment = NSTextAlignmentCenter;
nameLabel.text = @"Name";
nameLabel.font = [UIFont boldSystemFontOfSize:12];
[cell.contentView addSubview: nameLabel];
CGRect colorLabelRect = CGRectMake(0, 25, 70, 20);
UILabel* colorLabel = [[UILabel alloc] initWithFrame:colorLabelRect];
colorLabel.textAlignment = NSTextAlignmentCenter;
colorLabel.text = @"Color";
colorLabel.font = [UIFont boldSystemFontOfSize:12];
[cell.contentView addSubview: colorLabel];
CGRect priceLabelRect = CGRectMake(0, 45, 70, 20);
UILabel *priceLabel = [[UILabel alloc] …Run Code Online (Sandbox Code Playgroud) 我对正则表达式很陌生,我正在努力学习它.
这是我的字符串:
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
Run Code Online (Sandbox Code Playgroud)
我想把它分成一个看起来像这样的数组:
@[@"Mozzila", @"4.0", @"compatible", @"MSIE 5.0", @"Windows NT", @"DigExt"];
Run Code Online (Sandbox Code Playgroud)
这是我试过的代码:
NSString *expression = @"Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)";
NSRegularExpression *testExpression = [NSRegularExpression regularExpressionWithPattern: @"([a-zA-Z]+)/([1-9.]+) \(([a-z]+); ([a-zA-Z .]+); ([a-zA-Z ]+); ([a-zA-Z]+)\)" options:NSRegularExpressionCaseInsensitive error:nil];
options:NSRegularExpressionCaseInsensitive error:nil];
NSArray *matches = [testExpression matchesInString:expression
options:0
range:NSMakeRange(0, [expression length])];
NSLog(@"%@",matches);
Run Code Online (Sandbox Code Playgroud)
还试过:
[testExpression enumerateMatchesInString:expression
options:0
range:NSMakeRange(0, [expression length])
usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
NSLog(@"Value: %@", [expression substringWithRange:[result rangeAtIndex:1]]);
}];
Run Code Online (Sandbox Code Playgroud)
并且:
NSRegularExpression *testExpression = [NSRegularExpression …Run Code Online (Sandbox Code Playgroud) 如何从导航控制器而不是视图控制器设置右栏按钮?
我一直在阅读有关编写 SOLID 视图控制器的信息,该控制器仅用作控制器,而不是向其中添加所有内容。
该帖子建议将导航逻辑移至视图控制器之外(我同意)。另外,视图控制器确实不应该设置它嵌入的导航控制器,因此我尝试将设置导航栏的代码移动到我的自定义 UINavigationController 类。
我取得了部分成功,我设法更新了颜色,但无法设置rightBarButtonItem.
将这些行添加到视图控制器将起作用,但我想从 UINavigationController 子类中执行此操作。
let settingsImage = UIImage(named: "settingsButton")
self.rightBarButton = UIBarButtonItem(image: settingsImage, style: UIBarButtonItemStyle.Plain, target: self, action: "showSettings")
self.navigationItem.rightBarButtonItem = self.rightBarButton;
Run Code Online (Sandbox Code Playgroud)
我查看了问题“默认导航按钮”,建议创建父视图控制器并从中子类化所有视图控制器,但我真的不喜欢视图控制器设置导航控制器这一事实。应该是相反的。
编辑:我已经到了self.navigationBar.items。如果我将其设置为零,则不会显示任何内容。所以我可能需要改变这一点。但还不确定如何。
基本上我想建立一个简单的货币转换器,从网络上动态获取数据(Atm最好我提出的是:http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml,如果你知道有更好的JSON结果,我很感激).
现在我注意到它没有像我在一些教程中看到的XML格式,所以我考虑从URL中获取所有内容作为字符串并将其解析为字符串(我对字符串解析非常好,做了很多在C++比赛中).
我的问题是,如何从URL中获取字符串?
objective-c ×5
ios ×4
swift ×2
uitableview ×2
directory ×1
iphone ×1
nsstring ×1
permissions ×1
php ×1
regex ×1
split ×1
storyboard ×1
string ×1
subclass ×1
taxonomy ×1
url ×1
wordpress ×1