标签: share

C++ ::与所有其他类共享类

我是OOP和C++的新手.

我有一个名为Database的类.此类的构造函数将建立与数据库的连接.然后,我有其他类,如用户,分数等.我希望所有这些类共享来自Database类的连接.我怎么做?

程序流程示例:

  • 主要功能称为数据库类,它建立与数据库的连接.

  • 我想验证用户,如下所示:

    用户a("user1","password1"); a.authenticate("user1","password1");

但在我的Users :: authenticate函数中,如何利用已经建立的连接?

编辑:

我在c ++中使用mysql ++

在阅读答案后,我将使用"传递作为参考"方法.但我遇到了几个错误:

main.cpp

mysqlpp::Connection conn(false);    

int main() {
if (conn.connect(DATANAME, HOST, DBUSER, DBPASS)) {
    Users a(conn, "test","pass");
    a.authenticate();
Run Code Online (Sandbox Code Playgroud)

这是我的用户构造函数和身份验证功能:

Users.cpp

Users::Users(mysqlpp::Connection conn, string username, string password) {
    this->conn = conn;
    this->username = username;
    this->password = password;
}

void Users::authenticate() {
    if(this->conn != NULL){
        cout << "Have connection" << endl;
    } else {
        cout << "No connection" << endl;
    }
}
Run Code Online (Sandbox Code Playgroud)

它可以编译和运行.但它命令行,它显示:

Segmentation fault.
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?我猜我的代码错了

c++ oop share class

0
推荐指数
1
解决办法
1847
查看次数

管理器中没有"共享"按钮

我有一个有效的开发人员资料.我可以在iPhone上运行和调试我的应用程序.但是,当我尝试存档和共享它时,在管理器中我只能看到验证和分发.我该怎么办?如果我必须通过撤消和创建配置文件来更改我的配置文件,我该怎么做才能正确完成.因为我已经尝试创建一个新的配置文件来撤销旧配置文件.请帮帮我.

iphone profile share provisioning

0
推荐指数
1
解决办法
1328
查看次数

Rails:是否有任何用于生成共享链接的 gem(用于联盟营销)?

是否有可以将模型扩展为可共享的宝石?例如,如果某个项目是可共享的,则每个用户都可以获得该项目的唯一共享 URL。如果存在,它可能会以这种方式运行:

class Item < ActiveRecord::Base
  act_as_shareable
end

class User < ActiveRecord::Base
  act_as_sharer
end

# Then can generate an unique share URL like this:
path = some_item.share_by(some_user).path  # "/items/1?ref=v7D3SG251a"
Run Code Online (Sandbox Code Playgroud)

[更新]

并且 gem 还生成一个中间件,该中间件依赖于任何请求params[:ref]并设置请求者的 cookie。

gem share ruby-on-rails

0
推荐指数
1
解决办法
1976
查看次数

使用Graph API通过id/url将现有帖子分享到Facebook应用程序

所以在我的应用程序中,我从预定义页面显示一些Facebook帖子.我从我的服务器上获取帖子(服务器直接从Facebook获取),这样我就避免使用Facebook SDK.

对于每个帖子,我都有id和URL,每当用户按下帖子时,我就会在该帖子上打开Facebook应用.

现在我想添加用户将这些帖子分享到他们的个人资料页面的可能性,但是当用户打开一个帖子(在Facebook应用程序上)时,它似乎没有任何共享选项(只有喜欢和评论).其他选项是使用标准的Android共享功能(ACTION_SEND),但每当我以这种方式共享帖子的URL时,应用程序只共享该帖子的图片,而不是实际帖子.

任何帮助将非常感激,

问候

share facebook facebook-graph-api

0
推荐指数
1
解决办法
1218
查看次数

与facebook sdk 4.0 + iOS共享内容

我使用iOS上的Facebook SDK(objective-c)在Facebook上分享图像.这是我使用的代码:

-(IBAction)facebookShare:(UIButton *)sender {
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = self.image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
[FBSDKShareDialog showFromViewController:self withContent:content delegate:self];  
}
Run Code Online (Sandbox Code Playgroud)

图像是我通过从用户的图库中选择它设置的UIImage.当我尝试按下我的按钮(使用此IBAction)时,应用程序崩溃会发出此错误:

7月1日10:50:23 .local pkd [917]:错误检索pid的权利922 7月1日10:50:23 - [MainViewController sharer:didFailWithError:]:无法识别的选择器发送到实例0x7fd70940efd0 7月1日10:50:23:***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [MainViewController sharer:didFailWithError:]:无法识别的选择器发送到实例0x7fd70940efd0'

这是以这种方式修复代码后的新错误

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
        photo.image = //YOUR IMAGE                                                                 photo.userGenerated = YES;
        FBSDKSharePhotoContent * photoContent = [[FBSDKSharePhotoContent alloc] init];
        photoContent.photos = @[photo];
        FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
        shareDialog.shareContent = photoContent;
        shareDialog.delegate = (id)self; …
Run Code Online (Sandbox Code Playgroud)

share facebook objective-c ios

0
推荐指数
1
解决办法
4100
查看次数

Sharing text from app to Email app in android

I have the following code which used to send text from my app to Email:

Intent mail = new Intent(Intent.ACTION_VIEW);
            mail.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmail");
                mail.putExtra(Intent.EXTRA_EMAIL, new String[] {  });
                mail.setData(Uri.parse(""));
                mail.putExtra(Intent.EXTRA_SUBJECT, "Country Decryption");
                mail.setType("plain/text");
                mail.putExtra(Intent.EXTRA_TEXT, "my text");
                ctx.startActivity(mail);  
Run Code Online (Sandbox Code Playgroud)

It works , but as you see, it uses Gmail app, how do I make it use Email application instead of Gmail?

I mean this app: 电子邮件应用程序

and what about sharing to Facebook ? I found that Facebook does not support sharing using intent anymore, and …

email android share android-intent

0
推荐指数
1
解决办法
3077
查看次数

Android共享应用专用文件

是否有可能通过Intent将一些音频文件分享给其他应用,如电报​​,谷歌驱动器,whatsapp?我的文件正在下载并保存到我的app私人文件夹中,例如:/data/user/0/myPackage/app_NameOfFolder/file.mp3

我写了这个简单的方法:

    public void sendSound(String fileToSend){
    try{

        Log.d(TAG,"Sending: " + fileToSend);
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        Uri audioUri = Uri.parse(fileToSend);
        sharingIntent.setType("audio/*");
        sharingIntent.putExtra(Intent.EXTRA_STREAM, audioUri);
        startActivity(Intent.createChooser(sharingIntent, "Share"));

    }catch (Exception e){
        Log.d("TAG",e.getMessage());
        Log.d("TAG",e.toString());
    }

}
Run Code Online (Sandbox Code Playgroud)

但是我无法分享它,收到错误:"无法分享请重试"如果我将文件移动到公共目录中,例如: Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() +"/file.mp3";

它有效,所以我认为它与许可相关,所以这是我的清单:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
Run Code Online (Sandbox Code Playgroud)

不知道我做错了什么.

android share private file

0
推荐指数
1
解决办法
928
查看次数

安卓系统如何共享文件

我创建了一个应用程序,将使用操作发送发送文件,一小时后我的代码不起作用。

当它打开其他应用程序时,我收到一条错误“传输此类内容类型不受支持”,对于 shareIt 和蓝牙文件 iamafile 未发送到...这是我的代码,我尝试了很多代码但不起作用。请帮忙

File root = new File(Environment.getExternalStorageDirectory(), "/QuizApp/MyAnswer/"+sharedPreferenceUsername +"/"+ editTitle);
                        Uri uri = Uri.fromFile(root);


                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_SEND);

                        intent.setType("*/*");
                        intent.putExtra(Intent.EXTRA_STREAM, uri);

                        startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

顺便说一下,editTitle 是一个文件。

android share android-intent

0
推荐指数
1
解决办法
3275
查看次数

分享 Whatsapp 链接在哈希后中断

因此,我尝试通过 Whatsapp 分享包含主题标签的链接。

<a href="whatsapp://send?text=www.google.com#test" data-action="share/whatsapp/share">Share via Whatsapp</a>
Run Code Online (Sandbox Code Playgroud)

不知何故,它会发送 www.google.com 但它会忽略 # 之后的所有内容。有人有解决方案吗?你会震撼我的世界!

附言。我尝试对 #test 进行编码,但这也不起作用。

html share href whatsapp

0
推荐指数
1
解决办法
1773
查看次数

从照片库共享图像时的 iOS 共享扩展问题

下面是我用来在“ShareViewController.m”中共享图像的代码。

NSExtensionItem *item = [self.extensionContext.inputItems objectAtIndex:i];
NSItemProvider *itemProvider = item.attachments.firstObject;

if ([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypeURL]) {
     [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeURL options:nil completionHandler:^(NSData *data, NSError *error) {

           NSLog(@"%@", data);

           // the rest of uploading script goes here

     }];
}
Run Code Online (Sandbox Code Playgroud)

如果我从 WhatsApp 共享图像,一切正常。但如果我想从 Photo Library 或 Facebook Messenger 共享图像,它就不起作用

有谁知道问题可能是什么?

谢谢

xcode share objective-c ios share-extension

0
推荐指数
1
解决办法
1526
查看次数