你能把一个函数称为对象吗?例如:
function Tip(txt){
this.content = txt;
this.shown = false;
}
Run Code Online (Sandbox Code Playgroud)
和:
var tip = new Tip(elem.attr('title'));
Run Code Online (Sandbox Code Playgroud)
我的问题:
new一个函数吗? 使用"抽象方法"有什么意义?抽象类无法实例化,但抽象方法呢?他们只是在这里说"你必须实现我",如果我们忘记它们,编译器会抛出错误吗?
这是否意味着别的什么?我还读到了一些关于"我们不必重写相同代码"的内容,但在抽象类中,我们只"声明"抽象方法,因此我们必须重写子类中的代码.
你能帮我理解一下吗?我检查了关于"抽象类/方法"的其他主题,但我没有找到答案.
我按照这个线程,但didRegisterForRemoteNotificationsWithDeviceToken仍未调用该方法:
文件说:
在调用UIApplication对象的registerForRemoteNotifications方法后,应用程序在设备注册成功完成时调用此方法
didRegisterUser看起来很好,但不是did register notif.
这是我在AppDelegate中的代码(应用程序版本是8.1):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//register notif
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
[application registerUserNotificationSettings:settings];
return YES;
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications
[application registerForRemoteNotifications];
NSLog(@"didRegisterUser");
}
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"error here : %@", error);//not called
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
/*
// Store the deviceToken in the …Run Code Online (Sandbox Code Playgroud) 我在表单的字段中有一个自定义类型的小问题:我正在尝试添加与"图像"实体相关的"ImageType",其中"url"和"alt"作为变量.
我收到此错误:
无法从"Proxies__CG __\OC\PlatformBundle\Entity\Image"类型的对象读取索引"url",因为它没有实现\ ArrayAccess.
这是类型:
<?php
// src/OC/PlatformBundle/Form/ImageType.php
namespace OC\PlatformBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class ImageType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('url', TextType::class)
->add('alt', TextType::class)
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'OC\PlatformBundle\Entity\Image'
));
}
public function getName()
{
return 'oc_platformbundle_image';
}
}
Run Code Online (Sandbox Code Playgroud)
表格:
class AdvertType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class)
->add('date', DateType::class)
->add('categories', EntityType::class, array(
'class' => …Run Code Online (Sandbox Code Playgroud) 我怎么能在swift中得到rightbarbuttonItem的框架?我发现了这个:UIBarButtonItem:我怎样才能找到它的框架?但它说无法将NSString转换为UIView,或者无法将NSString转换为String:
let str : NSString = "view" //or type String
let theView : UIView = self.navigationItem.rightBarButtonItem!.valueForKey("view")//or 'str'
Run Code Online (Sandbox Code Playgroud)
目标是删除rightBarButtonItem,改为添加imageView,并使用fadeOut效果移动它.
谢谢
有没有办法让一个月或一年的所有日子?我正在寻找这个以禁用日期选择器中的某些特定日期,我会在后台有一个页面来选择这些天来禁用.
因此,我需要在一个月内显示所有日期,并在每天下方添加"激活或取消激活"按钮.有没有办法用Date对象找到这些日子?我发现这个链接例如:显示一个月的所有日子,但我真的不明白它,加上它是Java,我试图在javascript中找到一个解决方案.
谢谢您的帮助
我想知道jQuery中的原型意味着什么?我通常会找到关于"Prototype"的信息 - 框架 - 但是这里是jQuery里面的"原型"......?你能告诉我什么时候最好用吗?
另外,你能告诉我:为什么我们在jQuery插件中使用"普通javascript"代码而不是jquery代码,就像在这个例子中一样?这是一个快速问题吗?
这是我的例子:(一个twitter的插件)
谢谢你的回答!
$.each(data, function(i, item) {
holder.append("<p>"+item.text.makeLinks()+"</p>");
});
//...further in the code
String.prototype.makeLinks = function() {
return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(str) {
return str.link(str);
});
};
Run Code Online (Sandbox Code Playgroud) 如果我们将一个对象转换为一个接口,这个对象是否能够调用自己的方法?在下面的例子中,myObj只能调用MyInterface方法?
MyInterface myObj = new Obj();
Run Code Online (Sandbox Code Playgroud)
如果这是正确的,那两个对象之间有什么区别:
MyInterface myObj = new Obj();
MyInterface mySec = new Sec();
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助
我想在FOSUserBundle(Symfony2)中创建一个新用户,但我总是得到相同的消息(我正在使用php app/console fos:user:create):
没有为帐户"MyProject\UserBundle\Entity\User"配置编码器.
进口顺序正确
public function registerBundles()
{
$bundles = array(
//...
new MyProject\UserBundle\MyProjectUserBundle(),
new FOS\UserBundle\FOSUserBundle(),
);
Run Code Online (Sandbox Code Playgroud)
安全文件:
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
Run Code Online (Sandbox Code Playgroud)
但我总是得到同样的错误......你知道如何解决这个问题吗?这里的解决方案 对我不起作用
谢谢
当你使用线程时,你有任何偏好吗?一般来说,要使用以下任何一种技术:
NSOperationQueue是否简化了所有内容,因此在我们需要创建异步函数时更好用?
iphone objective-c nsthread nsoperationqueue grand-central-dispatch